This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
PhoneSlider.js
78 lines (73 loc) · 1.77 KB
/
PhoneSlider.js
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
import { Box, Heading, Image, Text } from 'grommet';
import Slider from 'react-slick';
const SliderImage = ({ imageLink, count, caption }) => (
<Box align="center" pad="medium">
<Box
background="dark-1"
style={{ borderRadius: '50%' }}
pad="14px"
width="72px"
height="72px"
margin={{ bottom: 'small' }}
>
<Heading textAlign="center" style={{ marginTop: 0 }}>
{count}
</Heading>
</Box>
<Box
style={{ maxWidth: 240 }}
pad={{ horizontal: 'medium', bottom: 'small' }}
>
<Text weight="bold" size="small" textAlign="center">
{caption}
</Text>
</Box>
<Box
pad={{ horizontal: 'large' }}
margin={{ bottom: 'medium' }}
height="medium"
>
<Image src={imageLink} alt={caption} height="100%" fit="contain" />
</Box>
</Box>
);
const sliderSettings = {
dots: true,
infinite: true,
arrows: false,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
lazyLoad: false,
};
const PhoneSlider = ({ sliderContent, large }) => {
if (large) {
return (
<Box direction="row" align="start" justify="center" gap="medium">
{sliderContent.map((slider) => (
<SliderImage
key={slider.caption}
count={slider.count}
caption={slider.caption}
imageLink={slider.imageLink}
/>
))}
</Box>
);
}
return (
<Box width="medium" alignSelf="center">
<Slider {...sliderSettings}>
{sliderContent.map((slider) => (
<SliderImage
key={slider.caption}
count={slider.count}
caption={slider.caption}
imageLink={slider.imageLink}
/>
))}
</Slider>
</Box>
);
};
export default PhoneSlider;