-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMyCarousel.js
More file actions
181 lines (170 loc) · 5.05 KB
/
Copy pathMyCarousel.js
File metadata and controls
181 lines (170 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import { useTheme } from '@mui/material/styles';
import React, { useState } from 'react';
import Box from '@mui/material/Box';
import MobileStepper from '@mui/material/MobileStepper';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';
import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft';
import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight';
import SwipeableViews from 'react-swipeable-views';
import { createTheme, ThemeProvider, styled } from '@mui/material/styles';
import { Montserrat } from 'next/font/google';
import { autoPlay } from 'react-swipeable-views-utils';
const montserrat = Montserrat({
weight: '600',
subsets: ['latin']
});
const AutoPlaySwipeableViews = autoPlay(SwipeableViews);
const theme = createTheme({
typography: {
fontFamily: [
montserrat
]
},
palette: {
primary: {
main: '#324E4B'
// light: will be calculated from palette.primary.main,
// dark: will be calculated from palette.primary.main,
// contrastText: will be calculated to contrast with palette.primary.main
},
secondary: {
main: '#F5C9C6'
},
warning: {
main: '#893F04'
},
info: {
main: '#fff'
}
},
});
const images = [
{
label: 'San Francisco – Oakland Bay Bridge, United States',
imgPath: '/swiper/backdrop.jpg',
},
{
label: 'Bird',
imgPath: '/swiper/woman.jpg',
},
{
label: 'Bali, Indonesia',
imgPath: '/swiper/girl.jpg',
},
{
label: 'Goč, Serbia',
imgPath: '/swiper/boho-art.jpg',
},
{
label: 'Bright Watercolour',
imgPath: '/swiper/watercolor.jpg',
},
];
function SwipeableTextMobileStepper() {
const theme = useTheme();
const [activeStep, setActiveStep] = useState(0);
const maxSteps = images.length;
const handleNext = () => {
setActiveStep((prevActiveStep) => prevActiveStep + 1);
};
const handleBack = () => {
setActiveStep((prevActiveStep) => prevActiveStep - 1);
};
const handleStepChange = (step) => {
setActiveStep(step);
};
return (
<ThemeProvider theme={theme}>
<Box sx={{ maxWidth: '100vw', flexGrow: 1 }}>
<AutoPlaySwipeableViews
axis={theme.direction === 'rtl' ? 'x-reverse' : 'x'}
index={activeStep}
onChangeIndex={handleStepChange}
enableMouseEvents
interval={5000}
>
{images.map((step, index) => (
<div key={step.label}>
{Math.abs(activeStep - index) <= 2 ? (
<Box
component="div"
sx={{
width: '100%',
height: '700px',
display: 'block',
maxWidth: '100%',
objectFit: 'cover',
position: 'relative',
opacity: 0.8,
}}
>
<img
src={step.imgPath}
alt={step.label}
style={{
width: '100%',
height: '100%',
objectFit: 'cover',
}}
/>
{/* Add text overlay here */}
<Typography
variant="h4"
sx={{
position: 'absolute',
bottom: '10%', // Adjust the bottom value to position it as desired
left: '50%',
transform: 'translateX(-50%)',
backgroundColor: 'transperent', // Semi-transparent background
color: 'white',
padding: '20px',
fontSize: '70px',
fontWeight: 'bold',
textShadow: '2px 2px 4px rgba(0, 0, 0, 0.5)',
borderRadius: '10px',
whiteSpace: 'nowrap',
}}
>
Discover Art You Love
</Typography>
</Box>
) : null}
</div>
))}
</AutoPlaySwipeableViews>
<MobileStepper
steps={maxSteps}
position="static"
activeStep={activeStep}
nextButton={
<Button
size="small"
onClick={handleNext}
disabled={activeStep === maxSteps - 1}
>
Next
{theme.direction === 'rtl' ? (
<KeyboardArrowLeft />
) : (
<KeyboardArrowRight />
)}
</Button>
}
backButton={
<Button size="small" onClick={handleBack} disabled={activeStep === 0}>
{theme.direction === 'rtl' ? (
<KeyboardArrowRight />
) : (
<KeyboardArrowLeft />
)}
Back
</Button>
}
/>
</Box>
</ThemeProvider>
);
}
export default SwipeableTextMobileStepper;