Skip to content

Commit 5879912

Browse files
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]>
1 parent 74dd208 commit 5879912

File tree

11 files changed

+218
-32
lines changed

11 files changed

+218
-32
lines changed
1.54 MB
Loading
22.4 KB
Loading
14.8 KB
Loading

client/src/assets/placeholder/guide.js

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
/* eslint-disable */
22
import img from '../../assets/images/carousel.png';
3+
import imgPrint from '../images/guide/mini-print1.png';
4+
import nitR_1 from '../images/guide/nitR-101.png';
5+
import nitR_2 from '../images/guide/nitR-101(2).png';
36

47
export const OPTIONS = Object.freeze({
58
tags: [
6-
'NITR-101',
9+
// 'NITR-101',
710
'Commn. Directory',
811
'Print Issue',
912
'SAC & Clubs Info',
10-
'Hall Info',
1113
'Health Info',
12-
'Archives',
14+
// 'Hall Info',
15+
// 'Archives',
1316
],
1417
});
1518

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

4043
export const CAROUSEL = Object.freeze([img, img, img, img, img]);
44+
45+
export const MINI_PRINT = Object.freeze([
46+
{
47+
img: imgPrint,
48+
link: 'https://drive.google.com/file/d/1wK9g_auqkSnFZdQpKdyHCQA8ECF33FFA/view?usp=sharing',
49+
desc: '',
50+
},
51+
{
52+
img: nitR_1,
53+
link: 'https://drive.google.com/file/d/1vs_Uel9_ARSc9w1DPnowKau5Z9OAy4Kc/view?usp=sharing',
54+
desc: '',
55+
},
56+
{
57+
img: nitR_2,
58+
link: 'https://mondaymorning.nitrkl.ac.in/article/62c492847b0cb908870f747a/NITR-101-Making-Your-Choice-Of-NIT-Rourkela-Simpler',
59+
desc: '',
60+
},
61+
]);
+174
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
import React, { useState } from 'react';
2+
import Image from 'next/image';
3+
import makeStyles from '@mui/styles/makeStyles';
4+
import { IconButton, Typography, useMediaQuery } from '@mui/material';
5+
import ArrowLeft from '@mui/icons-material/ArrowCircleLeftOutlined';
6+
import ArrowRight from '@mui/icons-material/ArrowCircleRightOutlined';
7+
8+
// Utils
9+
import theme from '../../config/themes/light';
10+
11+
const Carousel = ({ content }) => {
12+
const classes = useStyles();
13+
const length = content.length;
14+
15+
const [current, setCurrent] = useState(0);
16+
17+
const nextSlide = () => {
18+
setCurrent(current === length - 1 ? 0 : current + 1);
19+
};
20+
const prevSlide = () => {
21+
setCurrent(current === 0 ? length - 1 : current - 1);
22+
};
23+
24+
if (!Array.isArray(content) || content.length <= 0) {
25+
return null;
26+
}
27+
28+
const Desktop = useMediaQuery(theme.breakpoints.up('sm'));
29+
30+
return (
31+
<section className={classes.wrapper}>
32+
<div className={classes.imgContainer}>
33+
{Desktop && (
34+
<Image
35+
className={classes.sideImage}
36+
src={
37+
current === 0 ? content[length - 1].img : content[current - 1].img
38+
}
39+
alt='image'
40+
width='400px'
41+
height='300px'
42+
objectFit='contain'
43+
/>
44+
)}
45+
<div className={classes.midSlide}>
46+
<a
47+
target='_blank'
48+
href={content[current].link}
49+
rel='noopener noreferrer'
50+
>
51+
<Image
52+
className={classes.centreImage}
53+
src={content[current].img}
54+
alt='image'
55+
width='600px'
56+
height='400px'
57+
/>
58+
</a>
59+
{content[current].desc && (
60+
<div className={classes.textWrapper}>
61+
<Typography
62+
variant='body2'
63+
textAlign='center'
64+
className={classes.text}
65+
>
66+
{content[current].desc}
67+
</Typography>
68+
</div>
69+
)}
70+
</div>
71+
{Desktop && (
72+
<Image
73+
className={classes.sideImage}
74+
src={
75+
current === length - 1 ? content[0].img : content[current + 1].img
76+
}
77+
alt='image'
78+
width='400px'
79+
height='300px'
80+
objectFit='contain'
81+
/>
82+
)}
83+
</div>
84+
85+
<span className={classes.navIconWrapper}>
86+
<IconButton
87+
className={classes.navIcon}
88+
onClick={prevSlide}
89+
size='large'
90+
>
91+
<ArrowLeft />
92+
</IconButton>
93+
<IconButton
94+
className={classes.navIcon}
95+
onClick={nextSlide}
96+
size='large'
97+
>
98+
<ArrowRight />
99+
</IconButton>
100+
</span>
101+
</section>
102+
);
103+
};
104+
105+
export default Carousel;
106+
107+
const useStyles = makeStyles((theme) => ({
108+
wrapper: {
109+
maxWidth: '100%',
110+
position: 'relative',
111+
backgroundColor: theme.palette.secondary.main,
112+
},
113+
114+
carousel: {
115+
display: 'flex',
116+
overflowX: 'scroll',
117+
overflowY: 'none',
118+
scrollBehavior: 'smooth',
119+
},
120+
121+
imgContainer: {
122+
display: 'flex',
123+
justifyContent: 'center',
124+
marginTop: '1em',
125+
gap: 20,
126+
},
127+
128+
centreImage: {
129+
borderRadius: '16px',
130+
},
131+
132+
sideImage: {
133+
borderRadius: '16px',
134+
opacity: '0.5',
135+
},
136+
137+
midSlide: {
138+
display: 'flex',
139+
flexDirection: 'column',
140+
alignItems: 'center',
141+
borderRadius: '16px',
142+
},
143+
144+
bottomContainer: {
145+
display: 'flex',
146+
flexDirection: 'column',
147+
alignItems: 'center',
148+
justifyContent: 'center',
149+
bottom: '3%',
150+
position: 'absolute',
151+
},
152+
153+
textWrapper: {
154+
justifyContent: 'justify',
155+
alignItems: 'justify',
156+
marginTop: '15px',
157+
color: theme.palette.common.white,
158+
[theme.breakpoints.down('sm')]: {
159+
paddingLeft: '15px',
160+
paddingRight: '15px',
161+
},
162+
},
163+
164+
navIconWrapper: {
165+
display: 'flex',
166+
justifyContent: 'center',
167+
alignItems: 'center',
168+
color: theme.palette.secondary.neutral70,
169+
},
170+
171+
navIcon: {
172+
color: theme.palette.secondary.neutral70,
173+
},
174+
}));

client/src/components/guide/Options.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import React from 'react';
22
import Link from 'next/link';
33

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

78
// placeholder
89
import { OPTIONS } from '../../assets/placeholder/guide';
@@ -45,7 +46,9 @@ const Options = () => {
4546
Communication Directory
4647
</Typography>
4748
<span className={classes.link}>
48-
<a href='#'>Download</a>
49+
<Button href='https://drive.google.com/file/d/1ppdhllH19r6j7iOSYXRvJRU-pSOXhh3_/view'>
50+
<DownloadIcon className={classes.DownloadIcon} />
51+
</Button>
4952
</span>
5053
</div>
5154
<Link href='/sac' className={classes.links} passHref>
@@ -59,15 +62,15 @@ const Options = () => {
5962
</Typography>
6063
</div>
6164
</Link>
62-
<div className={classes.optionWrapper}>
65+
{/* <div className={classes.optionWrapper}>
6366
<Image src={icon3} alt='Icon' className={classes.icons} />
6467
<Typography variant='h3' className={classes.option2}>
6568
Hall Info
6669
</Typography>
6770
<Typography variant='h3' className={classes.arrow}>
6871
<i className='fas fa-chevron-right'></i>
6972
</Typography>
70-
</div>
73+
</div> */}
7174
<Link href='/info/health' passHref>
7275
<div className={classes.optionWrapper}>
7376
<Image src={icon4} alt='Icon' className={classes.icons} />
@@ -132,11 +135,11 @@ const useStyles = makeStyles((theme) => ({
132135
color: theme.palette.secondary.main,
133136
},
134137
link: {
135-
fontSize: '18px',
136138
marginLeft: '32px',
139+
backgroundColor: '#f0f6fa',
140+
borderRadius: '8px',
137141
[theme.breakpoints.down('sm')]: {
138-
visibility: 'hidden',
139-
width: '0px',
142+
marginLeft: '12px',
140143
},
141144
},
142145
option2: {

client/src/components/photostory/Carousel.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const Carousel = ({ content }) => {
4444
STORES[content[left].media.store] +
4545
encodeURI(content[left].media.storePath)
4646
}
47-
alt='travel image'
47+
alt='image'
4848
width='400px'
4949
height='300px'
5050
objectFit='contain'
@@ -57,7 +57,7 @@ const Carousel = ({ content }) => {
5757
STORES[content[current].media.store] +
5858
encodeURI(content[current].media.storePath)
5959
}
60-
alt='travel image'
60+
alt='image'
6161
width='600px'
6262
height={Desktop ? '400px' : '700px'}
6363
objectFit='contain'
@@ -81,7 +81,7 @@ const Carousel = ({ content }) => {
8181
STORES[content[right].media.store] +
8282
encodeURI(content[right].media.storePath)
8383
}
84-
alt='travel image'
84+
alt='image'
8585
width='400px'
8686
height='300px'
8787
objectFit='contain'

client/src/components/widgets/BigCarousel.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import React from 'react';
33
import makeStyles from '@mui/styles/makeStyles';
44
import { Typography } from '@mui/material';
55

6-
import PhotoCarousel from './PhotoCarousel';
6+
import Carousel from '../guide/Carousel';
77

8-
const BigCarousel = ({ head, navigator, IMAGE }) => {
8+
const BigCarousel = ({ head, navigator, content }) => {
99
const classes = useStyles();
1010
return (
1111
<div className={classes.wrapper}>
@@ -14,9 +14,7 @@ const BigCarousel = ({ head, navigator, IMAGE }) => {
1414
{head}
1515
</Typography>
1616
</div>
17-
<div>
18-
<PhotoCarousel navigator={navigator} IMAGE={IMAGE} />
19-
</div>
17+
<Carousel content={content} />
2018
</div>
2119
);
2220
};
@@ -34,11 +32,10 @@ const useStyles = makeStyles((theme) => ({
3432
},
3533
textWrapper: {
3634
display: 'flex',
37-
direction: 'row',
3835
justifyContent: 'center',
3936
},
4037
text: {
38+
fontSize: '28px',
4139
color: theme.palette.common.white,
42-
alignSelf: 'center',
4340
},
4441
}));

client/src/pages/guide.jsx

-9
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,4 @@ const GuidePage = ({ issues }) => {
8989
);
9090
};
9191

92-
export async function getServerSideProps() {
93-
return {
94-
redirect: {
95-
destination: '/comingSoon',
96-
permanent: false,
97-
},
98-
};
99-
}
100-
10192
export default GuidePage;

client/src/screens/Guide.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import BigCarousel from '../components/widgets/BigCarousel';
88
import BackButton from '../components/shared/button/BackButton';
99

1010
// placeholder
11-
import { CAROUSEL } from '../assets/placeholder/guide';
11+
import { MINI_PRINT } from '../assets/placeholder/guide';
1212

1313
function Contact({ issues }) {
1414
// const latestIssue = issues[0];
@@ -27,7 +27,7 @@ function Contact({ issues }) {
2727
<BackButton path='/' goTo='Home' />
2828
<Options />
2929
</Container>
30-
<BigCarousel head='Issues' IMAGE={CAROUSEL} navigator='2020-2021' />
30+
<BigCarousel head='Print Issues' content={MINI_PRINT} />
3131
{/* <Archives issues={articles} /> */}
3232
</div>
3333
);

client/src/screens/HealthInfo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Contact() {
1313
return (
1414
<div>
1515
<Container>
16-
<BackButton path='/' goTo='Home' />
16+
<BackButton path='/guide' goTo='Guide' />
1717
<Typography variant='h1' className={classes.head}>
1818
Health and Emergency Info
1919
</Typography>

0 commit comments

Comments
 (0)