@chayns-components/devalue-slider 5.0.0-beta.734
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +18 -0
- package/lib/cjs/components/DevalueSlider.js +57 -0
- package/lib/cjs/components/DevalueSlider.js.map +1 -0
- package/lib/cjs/components/slider/Slider.js +207 -0
- package/lib/cjs/components/slider/Slider.js.map +1 -0
- package/lib/cjs/components/slider/Slider.styles.js +265 -0
- package/lib/cjs/components/slider/Slider.styles.js.map +1 -0
- package/lib/cjs/components/timer/Timer.js +57 -0
- package/lib/cjs/components/timer/Timer.js.map +1 -0
- package/lib/cjs/components/timer/Timer.styles.js +42 -0
- package/lib/cjs/components/timer/Timer.styles.js.map +1 -0
- package/lib/cjs/hooks/design.js +29 -0
- package/lib/cjs/hooks/design.js.map +1 -0
- package/lib/cjs/index.js +14 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/utils/common.js +11 -0
- package/lib/cjs/utils/common.js.map +1 -0
- package/lib/esm/components/DevalueSlider.js +47 -0
- package/lib/esm/components/DevalueSlider.js.map +1 -0
- package/lib/esm/components/slider/Slider.js +199 -0
- package/lib/esm/components/slider/Slider.js.map +1 -0
- package/lib/esm/components/slider/Slider.styles.js +293 -0
- package/lib/esm/components/slider/Slider.styles.js.map +1 -0
- package/lib/esm/components/timer/Timer.js +50 -0
- package/lib/esm/components/timer/Timer.js.map +1 -0
- package/lib/esm/components/timer/Timer.styles.js +41 -0
- package/lib/esm/components/timer/Timer.styles.js.map +1 -0
- package/lib/esm/hooks/design.js +22 -0
- package/lib/esm/hooks/design.js.map +1 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/utils/common.js +4 -0
- package/lib/esm/utils/common.js.map +1 -0
- package/lib/types/components/DevalueSlider.d.ts +46 -0
- package/lib/types/components/slider/Slider.d.ts +19 -0
- package/lib/types/components/slider/Slider.styles.d.ts +1877 -0
- package/lib/types/components/timer/Timer.d.ts +8 -0
- package/lib/types/components/timer/Timer.styles.d.ts +267 -0
- package/lib/types/hooks/design.d.ts +6 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/utils/common.d.ts +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { motion } from 'framer-motion';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const Container = styled(motion.div)``;
|
|
4
|
+
export const Track = styled(motion.div)`
|
|
5
|
+
user-select: none;
|
|
6
|
+
position: relative;
|
|
7
|
+
z-index: 3;
|
|
8
|
+
height: ${_ref => {
|
|
9
|
+
let {
|
|
10
|
+
$height
|
|
11
|
+
} = _ref;
|
|
12
|
+
return $height;
|
|
13
|
+
}}px;
|
|
14
|
+
border-radius: ${_ref2 => {
|
|
15
|
+
let {
|
|
16
|
+
$height
|
|
17
|
+
} = _ref2;
|
|
18
|
+
return $height / 2;
|
|
19
|
+
}}px;
|
|
20
|
+
background-color: ${_ref3 => {
|
|
21
|
+
let {
|
|
22
|
+
$backgroundColor
|
|
23
|
+
} = _ref3;
|
|
24
|
+
return $backgroundColor;
|
|
25
|
+
}};
|
|
26
|
+
`;
|
|
27
|
+
export const TrackBackground = styled(motion.div)`
|
|
28
|
+
position: absolute;
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
border-radius: ${_ref4 => {
|
|
32
|
+
let {
|
|
33
|
+
$height
|
|
34
|
+
} = _ref4;
|
|
35
|
+
return $height / 2;
|
|
36
|
+
}}px;
|
|
37
|
+
z-index: 2;
|
|
38
|
+
`;
|
|
39
|
+
export const Thumb = styled(motion.div)`
|
|
40
|
+
height: ${_ref5 => {
|
|
41
|
+
let {
|
|
42
|
+
$size
|
|
43
|
+
} = _ref5;
|
|
44
|
+
return $size;
|
|
45
|
+
}}px;
|
|
46
|
+
width: ${_ref6 => {
|
|
47
|
+
let {
|
|
48
|
+
$size
|
|
49
|
+
} = _ref6;
|
|
50
|
+
return $size;
|
|
51
|
+
}}px;
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
background-color: white;
|
|
54
|
+
left: ${_ref7 => {
|
|
55
|
+
let {
|
|
56
|
+
$size,
|
|
57
|
+
$trackHeight
|
|
58
|
+
} = _ref7;
|
|
59
|
+
return ($trackHeight - $size - 2) / 2;
|
|
60
|
+
}}px;
|
|
61
|
+
bottom: ${_ref8 => {
|
|
62
|
+
let {
|
|
63
|
+
$size,
|
|
64
|
+
$trackHeight
|
|
65
|
+
} = _ref8;
|
|
66
|
+
return ($trackHeight - $size - 2) / 2 + 1;
|
|
67
|
+
}}px;
|
|
68
|
+
position: absolute;
|
|
69
|
+
z-index: 3;
|
|
70
|
+
box-shadow: rgba(0, 0, 0, 0.2) 1px 1px 2px 0;
|
|
71
|
+
`;
|
|
72
|
+
export const TrackText = styled(motion.div)`
|
|
73
|
+
position: absolute;
|
|
74
|
+
line-height: 1.15;
|
|
75
|
+
font-size: ${_ref9 => {
|
|
76
|
+
let {
|
|
77
|
+
$baseFontSize
|
|
78
|
+
} = _ref9;
|
|
79
|
+
return $baseFontSize;
|
|
80
|
+
}}px;
|
|
81
|
+
font-weight: 700;
|
|
82
|
+
color: ${_ref10 => {
|
|
83
|
+
let {
|
|
84
|
+
$color
|
|
85
|
+
} = _ref10;
|
|
86
|
+
return $color;
|
|
87
|
+
}};
|
|
88
|
+
top: 50%;
|
|
89
|
+
left: 50%;
|
|
90
|
+
transform: translate(-50%, -50%);
|
|
91
|
+
white-space: nowrap;
|
|
92
|
+
text-overflow: ellipsis;
|
|
93
|
+
z-index: 1;
|
|
94
|
+
font-family:
|
|
95
|
+
Roboto Regular,
|
|
96
|
+
sans-serif;
|
|
97
|
+
|
|
98
|
+
@font-face {
|
|
99
|
+
font-family: 'Roboto Regular';
|
|
100
|
+
font-style: normal;
|
|
101
|
+
font-weight: normal;
|
|
102
|
+
src:
|
|
103
|
+
local('Roboto Regular'),
|
|
104
|
+
local('Roboto Regular'),
|
|
105
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.woff2) format('woff2'),
|
|
106
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.woff) format('woff'),
|
|
107
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.ttf)
|
|
108
|
+
format('truetype'),
|
|
109
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.svg) format('svg');
|
|
110
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@font-face {
|
|
114
|
+
font-family: 'Roboto Regular';
|
|
115
|
+
font-style: italic;
|
|
116
|
+
font-weight: normal;
|
|
117
|
+
src:
|
|
118
|
+
local('Roboto Regular Italic'),
|
|
119
|
+
local('Roboto Regular-Italic'),
|
|
120
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.woff2) format('woff2'),
|
|
121
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.woff) format('woff'),
|
|
122
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.ttf) format('truetype'),
|
|
123
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.svg) format('svg');
|
|
124
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@font-face {
|
|
128
|
+
font-family: 'Roboto Regular';
|
|
129
|
+
font-style: normal;
|
|
130
|
+
font-weight: bold;
|
|
131
|
+
src:
|
|
132
|
+
local('Roboto Regular Bold'),
|
|
133
|
+
local('Roboto Regular-Bold'),
|
|
134
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.woff2) format('woff2'),
|
|
135
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.woff) format('woff'),
|
|
136
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.ttf) format('truetype'),
|
|
137
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.svg) format('svg');
|
|
138
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@font-face {
|
|
142
|
+
font-family: 'Roboto Regular';
|
|
143
|
+
font-style: italic;
|
|
144
|
+
font-weight: bold;
|
|
145
|
+
src:
|
|
146
|
+
local('Roboto Regular Bold Italic'),
|
|
147
|
+
local('Roboto Regular-BoldItalic'),
|
|
148
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.woff2)
|
|
149
|
+
format('woff2'),
|
|
150
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.woff)
|
|
151
|
+
format('woff'),
|
|
152
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.ttf)
|
|
153
|
+
format('truetype'),
|
|
154
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.svg) format('svg');
|
|
155
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@font-face {
|
|
159
|
+
font-family: 'Roboto Bold';
|
|
160
|
+
font-style: normal;
|
|
161
|
+
font-weight: normal;
|
|
162
|
+
src:
|
|
163
|
+
local('Roboto Bold'),
|
|
164
|
+
local('Roboto Bold'),
|
|
165
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.woff2) format('woff2'),
|
|
166
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.woff) format('woff'),
|
|
167
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.ttf) format('truetype'),
|
|
168
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.svg) format('svg');
|
|
169
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@font-face {
|
|
173
|
+
font-family: 'Roboto Bold';
|
|
174
|
+
font-style: italic;
|
|
175
|
+
font-weight: normal;
|
|
176
|
+
src:
|
|
177
|
+
local('Roboto Bold Italic'),
|
|
178
|
+
local('Roboto Bold-Italic'),
|
|
179
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.woff2) format('woff2'),
|
|
180
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.woff) format('woff'),
|
|
181
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.ttf) format('truetype'),
|
|
182
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.svg) format('svg');
|
|
183
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@font-face {
|
|
187
|
+
font-family: 'Roboto Bold';
|
|
188
|
+
font-style: normal;
|
|
189
|
+
font-weight: bold;
|
|
190
|
+
src:
|
|
191
|
+
local('Roboto Bold Bold'),
|
|
192
|
+
local('Roboto Bold-Bold'),
|
|
193
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.woff2) format('woff2'),
|
|
194
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.woff) format('woff'),
|
|
195
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.ttf) format('truetype'),
|
|
196
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.svg) format('svg');
|
|
197
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@font-face {
|
|
201
|
+
font-family: 'Roboto Bold';
|
|
202
|
+
font-style: italic;
|
|
203
|
+
font-weight: bold;
|
|
204
|
+
src:
|
|
205
|
+
local('Roboto Bold Bold Italic'),
|
|
206
|
+
local('Roboto Bold-BoldItalic'),
|
|
207
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.woff2) format('woff2'),
|
|
208
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.woff) format('woff'),
|
|
209
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.ttf)
|
|
210
|
+
format('truetype'),
|
|
211
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.svg) format('svg');
|
|
212
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
215
|
+
export const ThumbIconContainer = styled.div`
|
|
216
|
+
position: relative;
|
|
217
|
+
width: 100%;
|
|
218
|
+
height: 100%;
|
|
219
|
+
display: flex;
|
|
220
|
+
flex-direction: row;
|
|
221
|
+
justify-content: center;
|
|
222
|
+
align-items: center;
|
|
223
|
+
`;
|
|
224
|
+
export const ThumbIcon = styled(motion.i).attrs(_ref11 => {
|
|
225
|
+
let {
|
|
226
|
+
icon
|
|
227
|
+
} = _ref11;
|
|
228
|
+
return {
|
|
229
|
+
className: `react-chayns-icon ${icon}`
|
|
230
|
+
};
|
|
231
|
+
})`
|
|
232
|
+
font-size: 22px;
|
|
233
|
+
z-index: 1;
|
|
234
|
+
color: black;
|
|
235
|
+
padding: 5px;
|
|
236
|
+
`;
|
|
237
|
+
export const createThumbVariants = _ref12 => {
|
|
238
|
+
let {
|
|
239
|
+
thumbSize,
|
|
240
|
+
trackWidth,
|
|
241
|
+
scaleFactor
|
|
242
|
+
} = _ref12;
|
|
243
|
+
return {
|
|
244
|
+
base: {
|
|
245
|
+
x: 0,
|
|
246
|
+
backgroundColor: 'white',
|
|
247
|
+
transition: {
|
|
248
|
+
duration: 0.2
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
completed: {
|
|
252
|
+
x: (trackWidth - thumbSize * scaleFactor) / 2,
|
|
253
|
+
backgroundColor: 'transparent',
|
|
254
|
+
boxShadow: 'none',
|
|
255
|
+
transition: {
|
|
256
|
+
duration: 0.3
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
leaving: {
|
|
260
|
+
scale: [1, 2.4, 1],
|
|
261
|
+
boxShadow: 'none'
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
export const THUMB_ICON_VARIANTS = {
|
|
266
|
+
base: {
|
|
267
|
+
x: [0, 8, 0, 8, 0],
|
|
268
|
+
transition: {
|
|
269
|
+
duration: 1,
|
|
270
|
+
ease: 'easeInOut',
|
|
271
|
+
repeat: Infinity,
|
|
272
|
+
repeatDelay: 5
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
dragging: {
|
|
276
|
+
x: 0
|
|
277
|
+
},
|
|
278
|
+
completed: {
|
|
279
|
+
opacity: 1,
|
|
280
|
+
transition: {
|
|
281
|
+
duration: 0
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
leaving: {
|
|
285
|
+
opacity: 1,
|
|
286
|
+
scale: [1, 2.4, 1],
|
|
287
|
+
transition: {
|
|
288
|
+
duration: 0.4,
|
|
289
|
+
ease: 'easeInOut'
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
//# sourceMappingURL=Slider.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Slider.styles.js","names":["motion","styled","Container","div","Track","_ref","$height","_ref2","_ref3","$backgroundColor","TrackBackground","_ref4","Thumb","_ref5","$size","_ref6","_ref7","$trackHeight","_ref8","TrackText","_ref9","$baseFontSize","_ref10","$color","ThumbIconContainer","ThumbIcon","i","attrs","_ref11","icon","className","createThumbVariants","_ref12","thumbSize","trackWidth","scaleFactor","base","x","backgroundColor","transition","duration","completed","boxShadow","leaving","scale","THUMB_ICON_VARIANTS","ease","repeat","Infinity","repeatDelay","dragging","opacity"],"sources":["../../../../src/components/slider/Slider.styles.ts"],"sourcesContent":["import { motion, Variant, Variants } from 'framer-motion';\nimport styled from 'styled-components';\n\ninterface IBaseVariant extends Variants {\n base: Variant;\n}\n\ninterface IDraggingVariant extends Variants {\n dragging: Variant;\n}\n\ninterface ICompletedVariant extends Variants {\n completed: Variant;\n}\n\ninterface ILeavingVariant extends Variants {\n leaving: Variant;\n}\n\nexport const Container = styled(motion.div)``;\n\nexport type TrackProps = {\n $height: number;\n $borderSize: number;\n $backgroundColor: string;\n};\n\nexport const Track = styled(motion.div)<TrackProps>`\n user-select: none;\n position: relative;\n z-index: 3;\n height: ${({ $height }) => $height}px;\n border-radius: ${({ $height }) => $height / 2}px;\n background-color: ${({ $backgroundColor }) => $backgroundColor};\n`;\n\nexport const TrackBackground = styled(motion.div)<{ $height: number }>`\n position: absolute;\n width: 100%;\n height: 100%;\n border-radius: ${({ $height }) => $height / 2}px;\n z-index: 2;\n`;\n\nexport const Thumb = styled(motion.div)<{\n $size: number;\n $trackHeight: number;\n}>`\n height: ${({ $size }) => $size}px;\n width: ${({ $size }) => $size}px;\n border-radius: 50%;\n background-color: white;\n left: ${({ $size, $trackHeight }) => ($trackHeight - $size - 2) / 2}px;\n bottom: ${({ $size, $trackHeight }) => ($trackHeight - $size - 2) / 2 + 1}px;\n position: absolute;\n z-index: 3;\n box-shadow: rgba(0, 0, 0, 0.2) 1px 1px 2px 0;\n`;\n\nexport const TrackText = styled(motion.div)<{ $color: string; $baseFontSize: number }>`\n position: absolute;\n line-height: 1.15;\n font-size: ${({ $baseFontSize }) => $baseFontSize}px;\n font-weight: 700;\n color: ${({ $color }) => $color};\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n white-space: nowrap;\n text-overflow: ellipsis;\n z-index: 1;\n font-family:\n Roboto Regular,\n sans-serif;\n\n @font-face {\n font-family: 'Roboto Regular';\n font-style: normal;\n font-weight: normal;\n src:\n local('Roboto Regular'),\n local('Roboto Regular'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.woff2) format('woff2'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.woff) format('woff'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.ttf)\n format('truetype'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.svg) format('svg');\n unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;\n }\n\n @font-face {\n font-family: 'Roboto Regular';\n font-style: italic;\n font-weight: normal;\n src:\n local('Roboto Regular Italic'),\n local('Roboto Regular-Italic'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.woff2) format('woff2'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.woff) format('woff'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.ttf) format('truetype'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.svg) format('svg');\n unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;\n }\n\n @font-face {\n font-family: 'Roboto Regular';\n font-style: normal;\n font-weight: bold;\n src:\n local('Roboto Regular Bold'),\n local('Roboto Regular-Bold'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.woff2) format('woff2'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.woff) format('woff'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.ttf) format('truetype'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.svg) format('svg');\n unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;\n }\n\n @font-face {\n font-family: 'Roboto Regular';\n font-style: italic;\n font-weight: bold;\n src:\n local('Roboto Regular Bold Italic'),\n local('Roboto Regular-BoldItalic'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.woff2)\n format('woff2'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.woff)\n format('woff'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.ttf)\n format('truetype'),\n url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.svg) format('svg');\n unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;\n }\n\n @font-face {\n font-family: 'Roboto Bold';\n font-style: normal;\n font-weight: normal;\n src:\n local('Roboto Bold'),\n local('Roboto Bold'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.woff2) format('woff2'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.woff) format('woff'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.ttf) format('truetype'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.svg) format('svg');\n unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;\n }\n\n @font-face {\n font-family: 'Roboto Bold';\n font-style: italic;\n font-weight: normal;\n src:\n local('Roboto Bold Italic'),\n local('Roboto Bold-Italic'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.woff2) format('woff2'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.woff) format('woff'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.ttf) format('truetype'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.svg) format('svg');\n unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;\n }\n\n @font-face {\n font-family: 'Roboto Bold';\n font-style: normal;\n font-weight: bold;\n src:\n local('Roboto Bold Bold'),\n local('Roboto Bold-Bold'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.woff2) format('woff2'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.woff) format('woff'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.ttf) format('truetype'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.svg) format('svg');\n unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;\n }\n\n @font-face {\n font-family: 'Roboto Bold';\n font-style: italic;\n font-weight: bold;\n src:\n local('Roboto Bold Bold Italic'),\n local('Roboto Bold-BoldItalic'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.woff2) format('woff2'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.woff) format('woff'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.ttf)\n format('truetype'),\n url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.svg) format('svg');\n unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;\n }\n`;\n\nexport const ThumbIconContainer = styled.div`\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n`;\n\nexport const ThumbIcon = styled(motion.i).attrs<{ icon: string }>(({ icon }) => ({\n className: `react-chayns-icon ${icon}`,\n}))`\n font-size: 22px;\n z-index: 1;\n color: black;\n padding: 5px;\n`;\n\nexport type CreateThumbVariantsArgs = {\n trackWidth: number;\n thumbSize: number;\n scaleFactor: number;\n};\n\nexport const createThumbVariants = ({\n thumbSize,\n trackWidth,\n scaleFactor,\n}: CreateThumbVariantsArgs): IBaseVariant & ICompletedVariant & ILeavingVariant => ({\n base: {\n x: 0,\n backgroundColor: 'white',\n transition: { duration: 0.2 },\n },\n completed: {\n x: (trackWidth - thumbSize * scaleFactor) / 2,\n backgroundColor: 'transparent',\n boxShadow: 'none',\n transition: { duration: 0.3 },\n },\n leaving: {\n scale: [1, 2.4, 1],\n boxShadow: 'none',\n },\n});\n\nexport const THUMB_ICON_VARIANTS: IBaseVariant &\n IDraggingVariant &\n ICompletedVariant &\n ILeavingVariant = {\n base: {\n x: [0, 8, 0, 8, 0],\n transition: {\n duration: 1,\n ease: 'easeInOut',\n repeat: Infinity,\n repeatDelay: 5,\n },\n },\n dragging: {\n x: 0,\n },\n completed: {\n opacity: 1,\n transition: { duration: 0 },\n },\n leaving: {\n opacity: 1,\n scale: [1, 2.4, 1],\n transition: { duration: 0.4, ease: 'easeInOut' },\n },\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAA2B,eAAe;AACzD,OAAOC,MAAM,MAAM,mBAAmB;AAkBtC,OAAO,MAAMC,SAAS,GAAGD,MAAM,CAACD,MAAM,CAACG,GAAG,CAAC,EAAE;AAQ7C,OAAO,MAAMC,KAAK,GAAGH,MAAM,CAACD,MAAM,CAACG,GAAG,CAAa;AACnD;AACA;AACA;AACA,cAAcE,IAAA;EAAA,IAAC;IAAEC;EAAQ,CAAC,GAAAD,IAAA;EAAA,OAAKC,OAAO;AAAA;AACtC,qBAAqBC,KAAA;EAAA,IAAC;IAAED;EAAQ,CAAC,GAAAC,KAAA;EAAA,OAAKD,OAAO,GAAG,CAAC;AAAA;AACjD,wBAAwBE,KAAA;EAAA,IAAC;IAAEC;EAAiB,CAAC,GAAAD,KAAA;EAAA,OAAKC,gBAAgB;AAAA;AAClE,CAAC;AAED,OAAO,MAAMC,eAAe,GAAGT,MAAM,CAACD,MAAM,CAACG,GAAG,CAAsB;AACtE;AACA;AACA;AACA,qBAAqBQ,KAAA;EAAA,IAAC;IAAEL;EAAQ,CAAC,GAAAK,KAAA;EAAA,OAAKL,OAAO,GAAG,CAAC;AAAA;AACjD;AACA,CAAC;AAED,OAAO,MAAMM,KAAK,GAAGX,MAAM,CAACD,MAAM,CAACG,GAAG,CAGpC;AACF,cAAcU,KAAA;EAAA,IAAC;IAAEC;EAAM,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK;AAAA;AAClC,aAAaC,KAAA;EAAA,IAAC;IAAED;EAAM,CAAC,GAAAC,KAAA;EAAA,OAAKD,KAAK;AAAA;AACjC;AACA;AACA,YAAYE,KAAA;EAAA,IAAC;IAAEF,KAAK;IAAEG;EAAa,CAAC,GAAAD,KAAA;EAAA,OAAK,CAACC,YAAY,GAAGH,KAAK,GAAG,CAAC,IAAI,CAAC;AAAA;AACvE,cAAcI,KAAA;EAAA,IAAC;IAAEJ,KAAK;IAAEG;EAAa,CAAC,GAAAC,KAAA;EAAA,OAAK,CAACD,YAAY,GAAGH,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AAAA;AAC7E;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMK,SAAS,GAAGlB,MAAM,CAACD,MAAM,CAACG,GAAG,CAA4C;AACtF;AACA;AACA,iBAAiBiB,KAAA;EAAA,IAAC;IAAEC;EAAc,CAAC,GAAAD,KAAA;EAAA,OAAKC,aAAa;AAAA;AACrD;AACA,aAAaC,MAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,MAAA;EAAA,OAAKC,MAAM;AAAA;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAGvB,MAAM,CAACE,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMsB,SAAS,GAAGxB,MAAM,CAACD,MAAM,CAAC0B,CAAC,CAAC,CAACC,KAAK,CAAmBC,MAAA;EAAA,IAAC;IAAEC;EAAK,CAAC,GAAAD,MAAA;EAAA,OAAM;IAC7EE,SAAS,EAAE,qBAAqBD,IAAI;EACxC,CAAC;AAAA,CAAC,CAAC;AACH;AACA;AACA;AACA;AACA,CAAC;AAQD,OAAO,MAAME,mBAAmB,GAAGC,MAAA;EAAA,IAAC;IAChCC,SAAS;IACTC,UAAU;IACVC;EACqB,CAAC,GAAAH,MAAA;EAAA,OAA0D;IAChFI,IAAI,EAAE;MACFC,CAAC,EAAE,CAAC;MACJC,eAAe,EAAE,OAAO;MACxBC,UAAU,EAAE;QAAEC,QAAQ,EAAE;MAAI;IAChC,CAAC;IACDC,SAAS,EAAE;MACPJ,CAAC,EAAE,CAACH,UAAU,GAAGD,SAAS,GAAGE,WAAW,IAAI,CAAC;MAC7CG,eAAe,EAAE,aAAa;MAC9BI,SAAS,EAAE,MAAM;MACjBH,UAAU,EAAE;QAAEC,QAAQ,EAAE;MAAI;IAChC,CAAC;IACDG,OAAO,EAAE;MACLC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;MAClBF,SAAS,EAAE;IACf;EACJ,CAAC;AAAA,CAAC;AAEF,OAAO,MAAMG,mBAGM,GAAG;EAClBT,IAAI,EAAE;IACFC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClBE,UAAU,EAAE;MACRC,QAAQ,EAAE,CAAC;MACXM,IAAI,EAAE,WAAW;MACjBC,MAAM,EAAEC,QAAQ;MAChBC,WAAW,EAAE;IACjB;EACJ,CAAC;EACDC,QAAQ,EAAE;IACNb,CAAC,EAAE;EACP,CAAC;EACDI,SAAS,EAAE;IACPU,OAAO,EAAE,CAAC;IACVZ,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAE;EAC9B,CAAC;EACDG,OAAO,EAAE;IACLQ,OAAO,EAAE,CAAC;IACVP,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAClBL,UAAU,EAAE;MAAEC,QAAQ,EAAE,GAAG;MAAEM,IAAI,EAAE;IAAY;EACnD;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { format, intervalToDuration } from 'date-fns';
|
|
2
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { vibrate } from 'chayns-api';
|
|
4
|
+
import { Container } from './Timer.styles';
|
|
5
|
+
const Timer = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
devalueTime,
|
|
8
|
+
color,
|
|
9
|
+
textColor = 'white'
|
|
10
|
+
} = _ref;
|
|
11
|
+
const [distance, setDistance] = useState(intervalToDuration({
|
|
12
|
+
start: devalueTime,
|
|
13
|
+
end: new Date()
|
|
14
|
+
}));
|
|
15
|
+
const minutesShowValue = useMemo(() => (distance.minutes || 0).toString(), [distance.minutes]);
|
|
16
|
+
const secondsShowValue = useMemo(() => (distance.seconds || 0).toString(), [distance.seconds]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const interval = setInterval(() => {
|
|
19
|
+
setDistance(intervalToDuration({
|
|
20
|
+
start: devalueTime,
|
|
21
|
+
end: new Date()
|
|
22
|
+
}));
|
|
23
|
+
}, 500);
|
|
24
|
+
return () => clearInterval(interval);
|
|
25
|
+
}, [devalueTime]);
|
|
26
|
+
const handlePointerDownCapture = useCallback(() => {
|
|
27
|
+
void vibrate({
|
|
28
|
+
pattern: [50],
|
|
29
|
+
iOSFeedbackVibration: 7
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
const label = useMemo(() => {
|
|
33
|
+
let text = 'Vor ##SECONDS## Sek. (##TIME## Uhr)';
|
|
34
|
+
if (distance.minutes) {
|
|
35
|
+
text = 'Vor ##MINUTES## Min. ##SECONDS## Sek. (##TIME## Uhr)';
|
|
36
|
+
}
|
|
37
|
+
return text.replace('##MINUTES##', minutesShowValue).replace('##SECONDS##', secondsShowValue).replace('##TIME##', format(devalueTime, 'HH:mm'));
|
|
38
|
+
}, [distance.minutes, minutesShowValue, secondsShowValue, devalueTime]);
|
|
39
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
40
|
+
$baseFontSize: 17,
|
|
41
|
+
$borderSize: 2,
|
|
42
|
+
$height: 50,
|
|
43
|
+
$color: color,
|
|
44
|
+
$textColor: textColor,
|
|
45
|
+
$backgroundColor: color,
|
|
46
|
+
onPointerDownCapture: handlePointerDownCapture
|
|
47
|
+
}, label);
|
|
48
|
+
};
|
|
49
|
+
export default Timer;
|
|
50
|
+
//# sourceMappingURL=Timer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Timer.js","names":["format","intervalToDuration","React","useCallback","useEffect","useMemo","useState","vibrate","Container","Timer","_ref","devalueTime","color","textColor","distance","setDistance","start","end","Date","minutesShowValue","minutes","toString","secondsShowValue","seconds","interval","setInterval","clearInterval","handlePointerDownCapture","pattern","iOSFeedbackVibration","label","text","replace","createElement","$baseFontSize","$borderSize","$height","$color","$textColor","$backgroundColor","onPointerDownCapture"],"sources":["../../../../src/components/timer/Timer.tsx"],"sourcesContent":["import { format, intervalToDuration } from 'date-fns';\nimport React, { FunctionComponent, useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { vibrate } from 'chayns-api';\n\nimport { Container } from './Timer.styles';\n\nexport type TimerProps = {\n color: string;\n devalueTime: Date;\n textColor?: string;\n};\n\nconst Timer: FunctionComponent<TimerProps> = ({ devalueTime, color, textColor = 'white' }) => {\n const [distance, setDistance] = useState(\n intervalToDuration({\n start: devalueTime,\n end: new Date(),\n }),\n );\n const minutesShowValue = useMemo(() => (distance.minutes || 0).toString(), [distance.minutes]);\n const secondsShowValue = useMemo(() => (distance.seconds || 0).toString(), [distance.seconds]);\n\n useEffect(() => {\n const interval = setInterval(() => {\n setDistance(\n intervalToDuration({\n start: devalueTime,\n end: new Date(),\n }),\n );\n }, 500);\n return () => clearInterval(interval);\n }, [devalueTime]);\n\n const handlePointerDownCapture = useCallback(() => {\n void vibrate({ pattern: [50], iOSFeedbackVibration: 7 });\n }, []);\n\n const label = useMemo(() => {\n let text = 'Vor ##SECONDS## Sek. (##TIME## Uhr)';\n if (distance.minutes) {\n text = 'Vor ##MINUTES## Min. ##SECONDS## Sek. (##TIME## Uhr)';\n }\n\n return text\n .replace('##MINUTES##', minutesShowValue)\n .replace('##SECONDS##', secondsShowValue)\n .replace('##TIME##', format(devalueTime, 'HH:mm'));\n }, [distance.minutes, minutesShowValue, secondsShowValue, devalueTime]);\n\n return (\n <Container\n $baseFontSize={17}\n $borderSize={2}\n $height={50}\n $color={color}\n $textColor={textColor}\n $backgroundColor={color}\n onPointerDownCapture={handlePointerDownCapture}\n >\n {label}\n </Container>\n );\n};\n\nexport default Timer;\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,kBAAkB,QAAQ,UAAU;AACrD,OAAOC,KAAK,IAAuBC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAE3F,SAASC,OAAO,QAAQ,YAAY;AAEpC,SAASC,SAAS,QAAQ,gBAAgB;AAQ1C,MAAMC,KAAoC,GAAGC,IAAA,IAAiD;EAAA,IAAhD;IAAEC,WAAW;IAAEC,KAAK;IAAEC,SAAS,GAAG;EAAQ,CAAC,GAAAH,IAAA;EACrF,MAAM,CAACI,QAAQ,EAAEC,WAAW,CAAC,GAAGT,QAAQ,CACpCL,kBAAkB,CAAC;IACfe,KAAK,EAAEL,WAAW;IAClBM,GAAG,EAAE,IAAIC,IAAI,CAAC;EAClB,CAAC,CACL,CAAC;EACD,MAAMC,gBAAgB,GAAGd,OAAO,CAAC,MAAM,CAACS,QAAQ,CAACM,OAAO,IAAI,CAAC,EAAEC,QAAQ,CAAC,CAAC,EAAE,CAACP,QAAQ,CAACM,OAAO,CAAC,CAAC;EAC9F,MAAME,gBAAgB,GAAGjB,OAAO,CAAC,MAAM,CAACS,QAAQ,CAACS,OAAO,IAAI,CAAC,EAAEF,QAAQ,CAAC,CAAC,EAAE,CAACP,QAAQ,CAACS,OAAO,CAAC,CAAC;EAE9FnB,SAAS,CAAC,MAAM;IACZ,MAAMoB,QAAQ,GAAGC,WAAW,CAAC,MAAM;MAC/BV,WAAW,CACPd,kBAAkB,CAAC;QACfe,KAAK,EAAEL,WAAW;QAClBM,GAAG,EAAE,IAAIC,IAAI,CAAC;MAClB,CAAC,CACL,CAAC;IACL,CAAC,EAAE,GAAG,CAAC;IACP,OAAO,MAAMQ,aAAa,CAACF,QAAQ,CAAC;EACxC,CAAC,EAAE,CAACb,WAAW,CAAC,CAAC;EAEjB,MAAMgB,wBAAwB,GAAGxB,WAAW,CAAC,MAAM;IAC/C,KAAKI,OAAO,CAAC;MAAEqB,OAAO,EAAE,CAAC,EAAE,CAAC;MAAEC,oBAAoB,EAAE;IAAE,CAAC,CAAC;EAC5D,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,KAAK,GAAGzB,OAAO,CAAC,MAAM;IACxB,IAAI0B,IAAI,GAAG,qCAAqC;IAChD,IAAIjB,QAAQ,CAACM,OAAO,EAAE;MAClBW,IAAI,GAAG,sDAAsD;IACjE;IAEA,OAAOA,IAAI,CACNC,OAAO,CAAC,aAAa,EAAEb,gBAAgB,CAAC,CACxCa,OAAO,CAAC,aAAa,EAAEV,gBAAgB,CAAC,CACxCU,OAAO,CAAC,UAAU,EAAEhC,MAAM,CAACW,WAAW,EAAE,OAAO,CAAC,CAAC;EAC1D,CAAC,EAAE,CAACG,QAAQ,CAACM,OAAO,EAAED,gBAAgB,EAAEG,gBAAgB,EAAEX,WAAW,CAAC,CAAC;EAEvE,oBACIT,KAAA,CAAA+B,aAAA,CAACzB,SAAS;IACN0B,aAAa,EAAE,EAAG;IAClBC,WAAW,EAAE,CAAE;IACfC,OAAO,EAAE,EAAG;IACZC,MAAM,EAAEzB,KAAM;IACd0B,UAAU,EAAEzB,SAAU;IACtB0B,gBAAgB,EAAE3B,KAAM;IACxB4B,oBAAoB,EAAEb;EAAyB,GAE9CG,KACM,CAAC;AAEpB,CAAC;AAED,eAAerB,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Track } from '../slider/Slider.styles';
|
|
3
|
+
export const Container = styled(Track)`
|
|
4
|
+
height: ${_ref => {
|
|
5
|
+
let {
|
|
6
|
+
$height
|
|
7
|
+
} = _ref;
|
|
8
|
+
return $height;
|
|
9
|
+
}}px !important;
|
|
10
|
+
background-color: ${_ref2 => {
|
|
11
|
+
let {
|
|
12
|
+
$color
|
|
13
|
+
} = _ref2;
|
|
14
|
+
return $color;
|
|
15
|
+
}};
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: row;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
font-size: 4.5vw;
|
|
21
|
+
font-weight: 700;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
color: white;
|
|
24
|
+
|
|
25
|
+
@media (min-width: 450px) {
|
|
26
|
+
font-size: 4vw;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@media (min-width: 768px) {
|
|
30
|
+
font-size: 2vw;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@media (min-width: 1024px) {
|
|
34
|
+
font-size: 1.5vw;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@media (min-width: 1200px) {
|
|
38
|
+
font-size: 25px;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
//# sourceMappingURL=Timer.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Timer.styles.js","names":["styled","Track","Container","_ref","$height","_ref2","$color"],"sources":["../../../../src/components/timer/Timer.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { Track } from '../slider/Slider.styles';\n\nexport const Container = styled(Track)<{\n $color: string;\n $textColor: string;\n $baseFontSize: number;\n}>`\n height: ${({ $height }) => $height}px !important;\n background-color: ${({ $color }) => $color};\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n font-size: 4.5vw;\n font-weight: 700;\n cursor: pointer;\n color: white;\n\n @media (min-width: 450px) {\n font-size: 4vw;\n }\n\n @media (min-width: 768px) {\n font-size: 2vw;\n }\n\n @media (min-width: 1024px) {\n font-size: 1.5vw;\n }\n\n @media (min-width: 1200px) {\n font-size: 25px;\n }\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AACtC,SAASC,KAAK,QAAQ,yBAAyB;AAE/C,OAAO,MAAMC,SAAS,GAAGF,MAAM,CAACC,KAAK,CAInC;AACF,cAAcE,IAAA;EAAA,IAAC;IAAEC;EAAQ,CAAC,GAAAD,IAAA;EAAA,OAAKC,OAAO;AAAA;AACtC,wBAAwBC,KAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,KAAA;EAAA,OAAKC,MAAM;AAAA;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useTransform } from 'framer-motion';
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
export const useThumbIcon = (x, iconColor) => {
|
|
4
|
+
const [icon, setIcon] = useState('fas fa-arrow-right');
|
|
5
|
+
const opacity = useTransform(x, [0, 5, 6, 200], [1, 0, 0, 1]);
|
|
6
|
+
const styles = useMemo(() => ({
|
|
7
|
+
opacity,
|
|
8
|
+
color: iconColor
|
|
9
|
+
}), [iconColor, opacity]);
|
|
10
|
+
useEffect(() => x.on('change', value => {
|
|
11
|
+
if (value > 5) {
|
|
12
|
+
setIcon('fas fa-check');
|
|
13
|
+
} else {
|
|
14
|
+
setIcon('fas fa-arrow-right');
|
|
15
|
+
}
|
|
16
|
+
}), [x]);
|
|
17
|
+
return useMemo(() => ({
|
|
18
|
+
icon,
|
|
19
|
+
styles
|
|
20
|
+
}), [icon, styles]);
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=design.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design.js","names":["useTransform","useEffect","useMemo","useState","useThumbIcon","x","iconColor","icon","setIcon","opacity","styles","color","on","value"],"sources":["../../../src/hooks/design.ts"],"sourcesContent":["import { MotionStyle, MotionValue, useTransform } from 'framer-motion';\nimport { useEffect, useMemo, useState } from 'react';\n\nexport type UseThumbIconRes = {\n icon: string;\n styles: MotionStyle;\n};\nexport const useThumbIcon = (x: MotionValue<number>, iconColor: string): UseThumbIconRes => {\n const [icon, setIcon] = useState('fas fa-arrow-right');\n const opacity = useTransform(x, [0, 5, 6, 200], [1, 0, 0, 1]);\n const styles = useMemo<MotionStyle>(\n () => ({\n opacity,\n color: iconColor,\n }),\n [iconColor, opacity],\n );\n\n useEffect(\n () =>\n x.on('change', (value) => {\n if (value > 5) {\n setIcon('fas fa-check');\n } else {\n setIcon('fas fa-arrow-right');\n }\n }),\n [x],\n );\n\n return useMemo(() => ({ icon, styles }), [icon, styles]);\n};\n"],"mappings":"AAAA,SAAmCA,YAAY,QAAQ,eAAe;AACtE,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAMpD,OAAO,MAAMC,YAAY,GAAGA,CAACC,CAAsB,EAAEC,SAAiB,KAAsB;EACxF,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGL,QAAQ,CAAC,oBAAoB,CAAC;EACtD,MAAMM,OAAO,GAAGT,YAAY,CAACK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;EAC7D,MAAMK,MAAM,GAAGR,OAAO,CAClB,OAAO;IACHO,OAAO;IACPE,KAAK,EAAEL;EACX,CAAC,CAAC,EACF,CAACA,SAAS,EAAEG,OAAO,CACvB,CAAC;EAEDR,SAAS,CACL,MACII,CAAC,CAACO,EAAE,CAAC,QAAQ,EAAGC,KAAK,IAAK;IACtB,IAAIA,KAAK,GAAG,CAAC,EAAE;MACXL,OAAO,CAAC,cAAc,CAAC;IAC3B,CAAC,MAAM;MACHA,OAAO,CAAC,oBAAoB,CAAC;IACjC;EACJ,CAAC,CAAC,EACN,CAACH,CAAC,CACN,CAAC;EAED,OAAOH,OAAO,CAAC,OAAO;IAAEK,IAAI;IAAEG;EAAO,CAAC,CAAC,EAAE,CAACH,IAAI,EAAEG,MAAM,CAAC,CAAC;AAC5D,CAAC","ignoreList":[]}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","DevalueSlider"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as DevalueSlider } from './components/DevalueSlider';\nexport type {\n DevalueSliderOnChangeHandler,\n DevalueSliderOnCompleteHandler,\n DevalueSliderOnDevalueHandler,\n DevalueSliderProps,\n} from './components/DevalueSlider';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,aAAa,QAAQ,4BAA4B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","names":["sleep","ms","Promise","resolve","setTimeout"],"sources":["../../../src/utils/common.ts"],"sourcesContent":["export const sleep = (ms: number) =>\n new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n"],"mappings":"AAAA,OAAO,MAAMA,KAAK,GAAIC,EAAU,IAC5B,IAAIC,OAAO,CAAEC,OAAO,IAAK;EACrBC,UAAU,CAACD,OAAO,EAAEF,EAAE,CAAC;AAC3B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { type CSSProperties } from 'react';
|
|
2
|
+
export type DevalueSliderOnDevalueHandlerResult = {
|
|
3
|
+
success: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type DevalueSliderOnDevalueHandler = () => Promise<DevalueSliderOnDevalueHandlerResult>;
|
|
6
|
+
export type DevalueSliderOnChangeHandler = (relativeValue: number) => void;
|
|
7
|
+
export type DevalueSliderOnCompleteHandler = () => void;
|
|
8
|
+
export type DevalueSliderProps = {
|
|
9
|
+
/**
|
|
10
|
+
* The basic color of the slider.
|
|
11
|
+
* This color is the background of the track before the slider is devalued.
|
|
12
|
+
*/
|
|
13
|
+
backgroundColor?: CSSProperties['backgroundColor'];
|
|
14
|
+
/**
|
|
15
|
+
* The devalue color of the slider.
|
|
16
|
+
* This color fills the track from the left on user movement.
|
|
17
|
+
* This color is the background of the timer after the slider is devalued.
|
|
18
|
+
*/
|
|
19
|
+
devalueBackgroundColor?: CSSProperties['backgroundColor'];
|
|
20
|
+
/**
|
|
21
|
+
* If this slider was devalued, provide the time when it was devalued.
|
|
22
|
+
* This will show a timer.
|
|
23
|
+
*/
|
|
24
|
+
devalueTime?: Date;
|
|
25
|
+
/**
|
|
26
|
+
* Disables the slider and cancels any active drags.
|
|
27
|
+
*/
|
|
28
|
+
isDisabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* This function is called when the slider is devalued.
|
|
31
|
+
*/
|
|
32
|
+
onDevalue?: DevalueSliderOnDevalueHandler;
|
|
33
|
+
/**
|
|
34
|
+
* This function is called when the slider value changes.
|
|
35
|
+
* With this function you can keep track of the movement of the slider.
|
|
36
|
+
*/
|
|
37
|
+
onChange?: DevalueSliderOnChangeHandler;
|
|
38
|
+
/**
|
|
39
|
+
* This function is called when the slider is completed.
|
|
40
|
+
* The slider is completed when the user devalues the slider
|
|
41
|
+
* and the animation is completed.
|
|
42
|
+
*/
|
|
43
|
+
onComplete?: DevalueSliderOnCompleteHandler;
|
|
44
|
+
};
|
|
45
|
+
declare const DevalueSlider: React.FC<DevalueSliderProps>;
|
|
46
|
+
export default DevalueSlider;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DevalueSliderProps } from '../DevalueSlider';
|
|
3
|
+
export type SliderProps = {
|
|
4
|
+
color: NonNullable<DevalueSliderProps['backgroundColor']>;
|
|
5
|
+
devalueColor: NonNullable<DevalueSliderProps['devalueBackgroundColor']>;
|
|
6
|
+
thumbSize?: number;
|
|
7
|
+
trackHeight?: number;
|
|
8
|
+
trackText?: string;
|
|
9
|
+
borderSize?: number;
|
|
10
|
+
onChange: DevalueSliderProps['onChange'];
|
|
11
|
+
onDevalue: DevalueSliderProps['onDevalue'];
|
|
12
|
+
onComplete: DevalueSliderProps['onComplete'];
|
|
13
|
+
};
|
|
14
|
+
export type SliderRef = {
|
|
15
|
+
disable: () => void;
|
|
16
|
+
enable: () => void;
|
|
17
|
+
};
|
|
18
|
+
declare const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<SliderRef>>;
|
|
19
|
+
export default Slider;
|