back to top, main card

This commit is contained in:
2022-05-31 22:45:38 +02:00
parent 7c17607c27
commit 6f247c37fd
6 changed files with 73 additions and 68 deletions
+7 -11
View File
@@ -20,17 +20,13 @@ const MainCard = ({ imageURL, title, description, url }) => {
const options = { const options = {
reverse: true, reverse: true,
speed: 1200, speed: 1200,
reset: false, easing: 'cubic-bezier(.09,.67,.54,.76)'
// reset: false,
}; };
return ( return (
<a
href={url}
target='_blank'
rel='noopener noreferrer'
style={{ textDecoration: 'none' }}>
<Tilt <Tilt
// onClick={(e) => handleClick(e)} // style={{ padding: 0, margin: 0 }}
options={options} options={options}
children={ children={
<Card <Card
@@ -44,14 +40,16 @@ const MainCard = ({ imageURL, title, description, url }) => {
// boxShadow: `1px 1px 20px 10px ${shadowColor}`, // boxShadow: `1px 1px 20px 10px ${shadowColor}`,
// }, // },
}}> }}>
<CardActionArea>
<CardMedia <CardMedia
component='img' component='img'
height='150' height='150'
image={imageURL} image={imageURL}
alt={title} alt={title}
/> />
<CardContent color='white'> <CardActionArea>
<CardContent
color='white'
onClick={() => window.open(url, '_blank')}>
<Typography gutterBottom variant='h6' component='div'> <Typography gutterBottom variant='h6' component='div'>
{title} {title}
</Typography> </Typography>
@@ -63,9 +61,7 @@ const MainCard = ({ imageURL, title, description, url }) => {
</CardActionArea> </CardActionArea>
</Card> </Card>
} }
style={{ padding: 0, margin: 0 }}
/> />
</a>
); );
}; };
@@ -1,14 +1,15 @@
import React from 'react'; import React from 'react';
import useScrollTrigger from '@mui/material/useScrollTrigger'; import { Grid, Grow, useScrollTrigger } from '@mui/material';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import { Grid, Grow, Box } from '@mui/material';
import { useTheme } from '@mui/material/styles'; import { useTheme } from '@mui/material/styles';
function ScrollTop(props) { function ScrollTop(props) {
const { children, window } = props; const { children, window } = props;
// Note that you normally won't need to set the window ref as useScrollTrigger
// will default to window.
// This is only being set here because the demo is in an iframe.
const trigger = useScrollTrigger({ const trigger = useScrollTrigger({
target: window ? window() : undefined, target: window ? window() : undefined,
disableHysteresis: true, disableHysteresis: true,
@@ -26,21 +27,27 @@ function ScrollTop(props) {
}; };
return ( return (
<Grow <Grow in={trigger}>
in={trigger} <div onClick={handleClick} role='presentation'>
style={{ transformOrigin: '0 0 0' }}
{...(trigger ? { timeout: 1000 } : {})}>
<Box onClick={handleClick} role='presentation'>
{children} {children}
</Box> </div>
</Grow> </Grow>
); );
} }
const Footer = (props) => { const BackToTop = (props) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
<Grid container justifyContent='center' alignItems='center' id='footer'> <Grid
sx={{
position: 'fixed',
bottom: theme.spacing(2),
right: theme.spacing(2),
}}
container
justifyContent='center'
alignItems='center'
id='footer'>
<ScrollTop {...props}> <ScrollTop {...props}>
<KeyboardArrowUpIcon <KeyboardArrowUpIcon
sx={{ sx={{
@@ -53,4 +60,4 @@ const Footer = (props) => {
</Grid> </Grid>
); );
}; };
export default Footer; export default BackToTop;
+1
View File
@@ -0,0 +1 @@
export { default } from './BackToTop';
+5 -3
View File
@@ -6,7 +6,7 @@ import { ColorModeContext } from 'App';
import { LandingWhite } from 'themes/Theme'; import { LandingWhite } from 'themes/Theme';
import FullScreenContainer from 'layouts/common/fullScreenContainer'; import FullScreenContainer from 'layouts/common/fullScreenContainer';
import Footer from './components/footer'; import BackToTop from '../common/backToTop';
import Header from './components/header'; import Header from './components/header';
const LandingLayout = (props) => { const LandingLayout = (props) => {
@@ -19,8 +19,10 @@ const LandingLayout = (props) => {
<ThemeProvider theme={LandingWhite}> <ThemeProvider theme={LandingWhite}>
<div id='back-to-top-anchor' /> <div id='back-to-top-anchor' />
<Header /> <Header />
<FullScreenContainer>{children}</FullScreenContainer> <FullScreenContainer>
<Footer /> {children}
<BackToTop />
</FullScreenContainer>
</ThemeProvider> </ThemeProvider>
</ColorModeContext.Provider> </ColorModeContext.Provider>
); );
@@ -1 +0,0 @@
export { default } from './Footer';
+8 -8
View File
@@ -3,21 +3,21 @@ import React from 'react';
import Header from './components/header'; import Header from './components/header';
import Footer from './components/footer'; import Footer from './components/footer';
import FullScreenContainer from 'layouts/common/fullScreenContainer'; import FullScreenContainer from 'layouts/common/fullScreenContainer';
import BackToTop from '../common/backToTop';
const MainLayout = (props) => { const MainLayout = (props) => {
const { children } = props; const { children } = props;
return ( return (
<div <>
sx={{ <div id='back-to-top-anchor' />
minHeight: '100vh',
display: 'flex',
flexDirection: 'column',
}}>
<Header /> <Header />
<FullScreenContainer>{children}</FullScreenContainer> <FullScreenContainer>
{children}
<BackToTop />
</FullScreenContainer>
<Footer /> <Footer />
</div> </>
); );
}; };