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
|
import * as React from 'react';
import Flickity from 'react-flickity-component'
import styled from 'styled-components';
import { colors } from 'ts/style/colors';
import { Icon } from 'ts/@next/components/icon';
import { Paragraph, Heading } from 'ts/@next/components/text';
interface SliderProps {
}
interface SlideProps {
icon: string;
heading: string;
text: string;
href?: string;
}
const flickityOptions = {
initialIndex: 0,
cellAlign: 'left',
arrowShape: 'M0 50.766L42.467 93.58l5.791-5.839-32.346-32.61H100V46.84H15.48L50.2 11.838 44.409 6 5.794 44.93l-.003-.003z',
prevNextButtons: true,
};
export const Slide: React.StatelessComponent<SlideProps> = (props: SlideProps) => {
const { heading, text, href, icon } = props;
return (
<StyledSlide>
<SlideHead>
<Icon name={icon} size="large" margin="auto" />
</SlideHead>
<SlideContent>
<Heading asElement="h4" size="small" marginBottom="15px">{heading}</Heading>
<Paragraph isMuted={true}>{text}</Paragraph>
</SlideContent>
</StyledSlide>
);
};
export const Slider: React.StatelessComponent<SliderProps> = props => {
return (
<StyledSlider>
<Flickity
className={'carousel'} // default ''
elementType={'div'} // default 'div'
options={flickityOptions} // takes flickity options {}
disableImagesLoaded={false} // default false
>
{props.children}
</Flickity>
</StyledSlider>
);
};
const StyledSlider = styled.div`
//overflow: hidden;
width: 100%;
height: 520px;
@media (max-width: 500px) {
height: 450px;
}
.carousel {
display: block;
user-select: none;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
outline: none;
}
.flickity-viewport {
outline: none;
}
.flickity-button {
cursor: pointer;
position: absolute;
width: 74px;
height: 74px;
background-color: #000;
display: flex;
outline: 0;
top: calc(50% - 37px);
border: 0;
padding: 0;
transition: background-color .40s ease-in-out, visibility .40s ease-in-out, opacity .40s ease-in-out;
&:disabled {
opacity: 0;
visibility: hidden;
}
&:hover {
background-color: hsla(0, 0%, 10%, 1);
}
&.previous {
left: 0;
}
&.next {
right: 0;
}
svg {
margin: auto;
width: 28px;
height: auto;
}
path {
fill: #fff;
}
}
`;
const SliderInner = styled.div`
position: absolute;
display: flex;
width: 100%;
`;
const StyledSlide = styled.div`
background-color: ${colors.backgroundDark};
width: 560px;
height: 520px;
flex: 0 0 auto;
opacity: 0.3;
transition: opacity .40s ease-in-out;
@media (max-width: 500px) {
width: calc(100vw - 10px - 32px);
height: 450px;
}
&.is-selected {
opacity: 1;
}
& + & {
margin-left: 30px;
}
`;
const SlideHead = styled.div`
background-color: ${colors.brandDark};
height: 300px;
display: flex;
justify-content: center;
align-items: center;
@media (max-width: 500px) {
height: 240px;
}
`;
const SlideContent = styled.div`
padding: 30px;
@media (max-width: 500px) {
padding: 20px;
}
`;
|