Skip to content

Commit

Permalink
feat(guide): add mini print carousel (#374)
Browse files Browse the repository at this point in the history
* 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
Anish-Sarawgi and Shurtu-gal authored Jan 5, 2023
1 parent 74dd208 commit 5879912
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 32 deletions.
Binary file added client/src/assets/images/guide/mini-print1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/guide/nitR-101(2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/images/guide/nitR-101.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 24 additions & 3 deletions client/src/assets/placeholder/guide.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/* eslint-disable */
import img from '../../assets/images/carousel.png';
import imgPrint from '../images/guide/mini-print1.png';
import nitR_1 from '../images/guide/nitR-101.png';
import nitR_2 from '../images/guide/nitR-101(2).png';

export const OPTIONS = Object.freeze({
tags: [
'NITR-101',
// 'NITR-101',
'Commn. Directory',
'Print Issue',
'SAC & Clubs Info',
'Hall Info',
'Health Info',
'Archives',
// 'Hall Info',
// 'Archives',
],
});

Expand Down Expand Up @@ -38,3 +41,21 @@ export const ARCHIVES = Object.freeze({
});

export const CAROUSEL = Object.freeze([img, img, img, img, img]);

export const MINI_PRINT = Object.freeze([
{
img: imgPrint,
link: 'https://drive.google.com/file/d/1wK9g_auqkSnFZdQpKdyHCQA8ECF33FFA/view?usp=sharing',
desc: '',
},
{
img: nitR_1,
link: 'https://drive.google.com/file/d/1vs_Uel9_ARSc9w1DPnowKau5Z9OAy4Kc/view?usp=sharing',
desc: '',
},
{
img: nitR_2,
link: 'https://mondaymorning.nitrkl.ac.in/article/62c492847b0cb908870f747a/NITR-101-Making-Your-Choice-Of-NIT-Rourkela-Simpler',
desc: '',
},
]);
174 changes: 174 additions & 0 deletions client/src/components/guide/Carousel.js
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,
},
}));
17 changes: 10 additions & 7 deletions client/src/components/guide/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';
import Link from 'next/link';

import makeStyles from '@mui/styles/makeStyles';
import { Typography, Grid } from '@mui/material';
import { Typography, Grid, Button } from '@mui/material';
import DownloadIcon from '@mui/icons-material/Download';

// placeholder
import { OPTIONS } from '../../assets/placeholder/guide';
Expand Down Expand Up @@ -45,7 +46,9 @@ const Options = () => {
Communication Directory
</Typography>
<span className={classes.link}>
<a href='#'>Download</a>
<Button href='https://drive.google.com/file/d/1ppdhllH19r6j7iOSYXRvJRU-pSOXhh3_/view'>
<DownloadIcon className={classes.DownloadIcon} />
</Button>
</span>
</div>
<Link href='/sac' className={classes.links} passHref>
Expand All @@ -59,15 +62,15 @@ const Options = () => {
</Typography>
</div>
</Link>
<div className={classes.optionWrapper}>
{/* <div className={classes.optionWrapper}>
<Image src={icon3} alt='Icon' className={classes.icons} />
<Typography variant='h3' className={classes.option2}>
Hall Info
</Typography>
<Typography variant='h3' className={classes.arrow}>
<i className='fas fa-chevron-right'></i>
</Typography>
</div>
</div> */}
<Link href='/info/health' passHref>
<div className={classes.optionWrapper}>
<Image src={icon4} alt='Icon' className={classes.icons} />
Expand Down Expand Up @@ -132,11 +135,11 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.secondary.main,
},
link: {
fontSize: '18px',
marginLeft: '32px',
backgroundColor: '#f0f6fa',
borderRadius: '8px',
[theme.breakpoints.down('sm')]: {
visibility: 'hidden',
width: '0px',
marginLeft: '12px',
},
},
option2: {
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/photostory/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Carousel = ({ content }) => {
STORES[content[left].media.store] +
encodeURI(content[left].media.storePath)
}
alt='travel image'
alt='image'
width='400px'
height='300px'
objectFit='contain'
Expand All @@ -57,7 +57,7 @@ const Carousel = ({ content }) => {
STORES[content[current].media.store] +
encodeURI(content[current].media.storePath)
}
alt='travel image'
alt='image'
width='600px'
height={Desktop ? '400px' : '700px'}
objectFit='contain'
Expand All @@ -81,7 +81,7 @@ const Carousel = ({ content }) => {
STORES[content[right].media.store] +
encodeURI(content[right].media.storePath)
}
alt='travel image'
alt='image'
width='400px'
height='300px'
objectFit='contain'
Expand Down
11 changes: 4 additions & 7 deletions client/src/components/widgets/BigCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React from 'react';
import makeStyles from '@mui/styles/makeStyles';
import { Typography } from '@mui/material';

import PhotoCarousel from './PhotoCarousel';
import Carousel from '../guide/Carousel';

const BigCarousel = ({ head, navigator, IMAGE }) => {
const BigCarousel = ({ head, navigator, content }) => {
const classes = useStyles();
return (
<div className={classes.wrapper}>
Expand All @@ -14,9 +14,7 @@ const BigCarousel = ({ head, navigator, IMAGE }) => {
{head}
</Typography>
</div>
<div>
<PhotoCarousel navigator={navigator} IMAGE={IMAGE} />
</div>
<Carousel content={content} />
</div>
);
};
Expand All @@ -34,11 +32,10 @@ const useStyles = makeStyles((theme) => ({
},
textWrapper: {
display: 'flex',
direction: 'row',
justifyContent: 'center',
},
text: {
fontSize: '28px',
color: theme.palette.common.white,
alignSelf: 'center',
},
}));
9 changes: 0 additions & 9 deletions client/src/pages/guide.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,4 @@ const GuidePage = ({ issues }) => {
);
};

export async function getServerSideProps() {
return {
redirect: {
destination: '/comingSoon',
permanent: false,
},
};
}

export default GuidePage;
4 changes: 2 additions & 2 deletions client/src/screens/Guide.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import BigCarousel from '../components/widgets/BigCarousel';
import BackButton from '../components/shared/button/BackButton';

// placeholder
import { CAROUSEL } from '../assets/placeholder/guide';
import { MINI_PRINT } from '../assets/placeholder/guide';

function Contact({ issues }) {
// const latestIssue = issues[0];
Expand All @@ -27,7 +27,7 @@ function Contact({ issues }) {
<BackButton path='/' goTo='Home' />
<Options />
</Container>
<BigCarousel head='Issues' IMAGE={CAROUSEL} navigator='2020-2021' />
<BigCarousel head='Print Issues' content={MINI_PRINT} />
{/* <Archives issues={articles} /> */}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion client/src/screens/HealthInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Contact() {
return (
<div>
<Container>
<BackButton path='/' goTo='Home' />
<BackButton path='/guide' goTo='Guide' />
<Typography variant='h1' className={classes.head}>
Health and Emergency Info
</Typography>
Expand Down

0 comments on commit 5879912

Please sign in to comment.