-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(guide): add mini print carousel (#374)
* feat(guide): add mini print carousel * fix: add link in mobile view * fix: back button routing in healthInfo Page * chore: redirect live page (#391) * Merge branch 'main' into guide-miniPrint * chore: reduce no. of state * fix: remove coming soon Co-authored-by: Ashish Padhy <[email protected]>
- Loading branch information
1 parent
74dd208
commit 5879912
Showing
11 changed files
with
218 additions
and
32 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
import React, { useState } from 'react'; | ||
import Image from 'next/image'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import { IconButton, Typography, useMediaQuery } from '@mui/material'; | ||
import ArrowLeft from '@mui/icons-material/ArrowCircleLeftOutlined'; | ||
import ArrowRight from '@mui/icons-material/ArrowCircleRightOutlined'; | ||
|
||
// Utils | ||
import theme from '../../config/themes/light'; | ||
|
||
const Carousel = ({ content }) => { | ||
const classes = useStyles(); | ||
const length = content.length; | ||
|
||
const [current, setCurrent] = useState(0); | ||
|
||
const nextSlide = () => { | ||
setCurrent(current === length - 1 ? 0 : current + 1); | ||
}; | ||
const prevSlide = () => { | ||
setCurrent(current === 0 ? length - 1 : current - 1); | ||
}; | ||
|
||
if (!Array.isArray(content) || content.length <= 0) { | ||
return null; | ||
} | ||
|
||
const Desktop = useMediaQuery(theme.breakpoints.up('sm')); | ||
|
||
return ( | ||
<section className={classes.wrapper}> | ||
<div className={classes.imgContainer}> | ||
{Desktop && ( | ||
<Image | ||
className={classes.sideImage} | ||
src={ | ||
current === 0 ? content[length - 1].img : content[current - 1].img | ||
} | ||
alt='image' | ||
width='400px' | ||
height='300px' | ||
objectFit='contain' | ||
/> | ||
)} | ||
<div className={classes.midSlide}> | ||
<a | ||
target='_blank' | ||
href={content[current].link} | ||
rel='noopener noreferrer' | ||
> | ||
<Image | ||
className={classes.centreImage} | ||
src={content[current].img} | ||
alt='image' | ||
width='600px' | ||
height='400px' | ||
/> | ||
</a> | ||
{content[current].desc && ( | ||
<div className={classes.textWrapper}> | ||
<Typography | ||
variant='body2' | ||
textAlign='center' | ||
className={classes.text} | ||
> | ||
{content[current].desc} | ||
</Typography> | ||
</div> | ||
)} | ||
</div> | ||
{Desktop && ( | ||
<Image | ||
className={classes.sideImage} | ||
src={ | ||
current === length - 1 ? content[0].img : content[current + 1].img | ||
} | ||
alt='image' | ||
width='400px' | ||
height='300px' | ||
objectFit='contain' | ||
/> | ||
)} | ||
</div> | ||
|
||
<span className={classes.navIconWrapper}> | ||
<IconButton | ||
className={classes.navIcon} | ||
onClick={prevSlide} | ||
size='large' | ||
> | ||
<ArrowLeft /> | ||
</IconButton> | ||
<IconButton | ||
className={classes.navIcon} | ||
onClick={nextSlide} | ||
size='large' | ||
> | ||
<ArrowRight /> | ||
</IconButton> | ||
</span> | ||
</section> | ||
); | ||
}; | ||
|
||
export default Carousel; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
wrapper: { | ||
maxWidth: '100%', | ||
position: 'relative', | ||
backgroundColor: theme.palette.secondary.main, | ||
}, | ||
|
||
carousel: { | ||
display: 'flex', | ||
overflowX: 'scroll', | ||
overflowY: 'none', | ||
scrollBehavior: 'smooth', | ||
}, | ||
|
||
imgContainer: { | ||
display: 'flex', | ||
justifyContent: 'center', | ||
marginTop: '1em', | ||
gap: 20, | ||
}, | ||
|
||
centreImage: { | ||
borderRadius: '16px', | ||
}, | ||
|
||
sideImage: { | ||
borderRadius: '16px', | ||
opacity: '0.5', | ||
}, | ||
|
||
midSlide: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
borderRadius: '16px', | ||
}, | ||
|
||
bottomContainer: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
bottom: '3%', | ||
position: 'absolute', | ||
}, | ||
|
||
textWrapper: { | ||
justifyContent: 'justify', | ||
alignItems: 'justify', | ||
marginTop: '15px', | ||
color: theme.palette.common.white, | ||
[theme.breakpoints.down('sm')]: { | ||
paddingLeft: '15px', | ||
paddingRight: '15px', | ||
}, | ||
}, | ||
|
||
navIconWrapper: { | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
color: theme.palette.secondary.neutral70, | ||
}, | ||
|
||
navIcon: { | ||
color: theme.palette.secondary.neutral70, | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters