@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Tobit Laboratories AG
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# `devalue-slider`
|
|
2
|
+
|
|
3
|
+
This is a slider component that can be devalued.For a normal devalue the user will drag the slider
|
|
4
|
+
to the right and release it. It will show a loading cursor and call the onDevalue handler. If the
|
|
5
|
+
onDevalue handler does not give a successful response the thumb will snap back to the left. This
|
|
6
|
+
gives feedback to the user and the person who validates the devalue.
|
|
7
|
+
|
|
8
|
+
The developer should care about some additional security measures to prevent fraud. For example this
|
|
9
|
+
could be an offline detection. For this you can disable the Slider with the isDisabled prop. This
|
|
10
|
+
will also cancel the current user drag.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
import { DevalueSlider } from '@chayns-components/devalue-slider';
|
|
16
|
+
|
|
17
|
+
<DevalueSlider />
|
|
18
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _Slider = _interopRequireDefault(require("./slider/Slider"));
|
|
9
|
+
var _Timer = _interopRequireDefault(require("./timer/Timer"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
const DevalueSlider = ({
|
|
14
|
+
backgroundColor = 'red',
|
|
15
|
+
devalueBackgroundColor = 'green',
|
|
16
|
+
devalueTime,
|
|
17
|
+
isDisabled,
|
|
18
|
+
onDevalue,
|
|
19
|
+
onChange,
|
|
20
|
+
onComplete
|
|
21
|
+
}) => {
|
|
22
|
+
const [timerDevalueTime, setTimerDevalueTime] = (0, _react.useState)(devalueTime);
|
|
23
|
+
const sliderRef = (0, _react.useRef)(null);
|
|
24
|
+
(0, _react.useEffect)(() => {
|
|
25
|
+
if (devalueTime) return;
|
|
26
|
+
setTimerDevalueTime(devalueTime);
|
|
27
|
+
}, [devalueTime]);
|
|
28
|
+
const handleCompleted = (0, _react.useCallback)(() => {
|
|
29
|
+
setTimerDevalueTime(new Date());
|
|
30
|
+
onComplete === null || onComplete === void 0 || onComplete();
|
|
31
|
+
}, [onComplete]);
|
|
32
|
+
(0, _react.useEffect)(() => {
|
|
33
|
+
var _sliderRef$current2;
|
|
34
|
+
if (isDisabled) {
|
|
35
|
+
var _sliderRef$current;
|
|
36
|
+
(_sliderRef$current = sliderRef.current) === null || _sliderRef$current === void 0 || _sliderRef$current.disable();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
(_sliderRef$current2 = sliderRef.current) === null || _sliderRef$current2 === void 0 || _sliderRef$current2.enable();
|
|
40
|
+
}, [isDisabled]);
|
|
41
|
+
if (timerDevalueTime) {
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_Timer.default, {
|
|
43
|
+
color: devalueBackgroundColor,
|
|
44
|
+
devalueTime: timerDevalueTime
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(_Slider.default, {
|
|
48
|
+
ref: sliderRef,
|
|
49
|
+
onDevalue: onDevalue,
|
|
50
|
+
color: backgroundColor,
|
|
51
|
+
devalueColor: devalueBackgroundColor,
|
|
52
|
+
onComplete: handleCompleted,
|
|
53
|
+
onChange: onChange
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var _default = exports.default = DevalueSlider;
|
|
57
|
+
//# sourceMappingURL=DevalueSlider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevalueSlider.js","names":["_react","_interopRequireWildcard","require","_Slider","_interopRequireDefault","_Timer","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DevalueSlider","backgroundColor","devalueBackgroundColor","devalueTime","isDisabled","onDevalue","onChange","onComplete","timerDevalueTime","setTimerDevalueTime","useState","sliderRef","useRef","useEffect","handleCompleted","useCallback","Date","_sliderRef$current2","_sliderRef$current","current","disable","enable","createElement","color","ref","devalueColor","_default","exports"],"sources":["../../../src/components/DevalueSlider.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState, type CSSProperties } from 'react';\nimport Slider, { type SliderRef } from './slider/Slider';\nimport Timer from './timer/Timer';\n\nexport type DevalueSliderOnDevalueHandlerResult = { success: boolean };\nexport type DevalueSliderOnDevalueHandler = () => Promise<DevalueSliderOnDevalueHandlerResult>;\n\nexport type DevalueSliderOnChangeHandler = (relativeValue: number) => void;\nexport type DevalueSliderOnCompleteHandler = () => void;\n\nexport type DevalueSliderProps = {\n /**\n * The basic color of the slider.\n * This color is the background of the track before the slider is devalued.\n */\n backgroundColor?: CSSProperties['backgroundColor'];\n /**\n * The devalue color of the slider.\n * This color fills the track from the left on user movement.\n * This color is the background of the timer after the slider is devalued.\n */\n devalueBackgroundColor?: CSSProperties['backgroundColor'];\n /**\n * If this slider was devalued, provide the time when it was devalued.\n * This will show a timer.\n */\n devalueTime?: Date;\n /**\n * Disables the slider and cancels any active drags.\n */\n isDisabled?: boolean;\n /**\n * This function is called when the slider is devalued.\n */\n onDevalue?: DevalueSliderOnDevalueHandler;\n /**\n * This function is called when the slider value changes.\n * With this function you can keep track of the movement of the slider.\n */\n onChange?: DevalueSliderOnChangeHandler;\n /**\n * This function is called when the slider is completed.\n * The slider is completed when the user devalues the slider\n * and the animation is completed.\n */\n onComplete?: DevalueSliderOnCompleteHandler;\n};\n\nconst DevalueSlider: React.FC<DevalueSliderProps> = ({\n backgroundColor = 'red',\n devalueBackgroundColor = 'green',\n devalueTime,\n isDisabled,\n onDevalue,\n onChange,\n onComplete,\n}) => {\n const [timerDevalueTime, setTimerDevalueTime] = useState(devalueTime);\n\n const sliderRef = useRef<SliderRef>(null);\n\n useEffect(() => {\n if (devalueTime) return;\n\n setTimerDevalueTime(devalueTime);\n }, [devalueTime]);\n\n const handleCompleted = useCallback(() => {\n setTimerDevalueTime(new Date());\n\n onComplete?.();\n }, [onComplete]);\n\n useEffect(() => {\n if (isDisabled) {\n sliderRef.current?.disable();\n\n return;\n }\n\n sliderRef.current?.enable();\n }, [isDisabled]);\n\n if (timerDevalueTime) {\n return <Timer color={devalueBackgroundColor} devalueTime={timerDevalueTime} />;\n }\n\n return (\n <Slider\n ref={sliderRef}\n onDevalue={onDevalue}\n color={backgroundColor}\n devalueColor={devalueBackgroundColor}\n onComplete={handleCompleted}\n onChange={onChange}\n />\n );\n};\n\nexport default DevalueSlider;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAAkC,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,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var _core = require("@chayns-components/core");
|
|
8
|
+
var _size = _interopRequireDefault(require("@react-hook/size"));
|
|
9
|
+
var _chaynsApi = require("chayns-api");
|
|
10
|
+
var _framerMotion = require("framer-motion");
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _design = require("../../hooks/design");
|
|
13
|
+
var _common = require("../../utils/common");
|
|
14
|
+
var _Slider = require("./Slider.styles");
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
const Slider = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
19
|
+
color,
|
|
20
|
+
devalueColor,
|
|
21
|
+
trackHeight = 50,
|
|
22
|
+
thumbSize = 40,
|
|
23
|
+
borderSize = 2,
|
|
24
|
+
trackText = 'EINLÖSEN',
|
|
25
|
+
onChange = () => {},
|
|
26
|
+
onDevalue = () => Promise.resolve({
|
|
27
|
+
success: true
|
|
28
|
+
}),
|
|
29
|
+
onComplete
|
|
30
|
+
}, ref) => {
|
|
31
|
+
const [trackRef, setTrackRef] = (0, _react.useState)(null);
|
|
32
|
+
const [trackWidth] = (0, _size.default)(trackRef, {
|
|
33
|
+
initialWidth: 300,
|
|
34
|
+
initialHeight: 50
|
|
35
|
+
});
|
|
36
|
+
const [iconColor, setIconColor] = (0, _react.useState)('black');
|
|
37
|
+
const [isCompleted, setIsCompleted] = (0, _react.useState)(false);
|
|
38
|
+
const [isDisabled, setIsDisabled] = (0, _react.useState)(false);
|
|
39
|
+
const isCompletedRef = (0, _react.useRef)(isCompleted);
|
|
40
|
+
const [showWaitCursor, setShowWaitCursor] = (0, _react.useState)(false);
|
|
41
|
+
const scaleFactor = (0, _react.useMemo)(() => trackHeight / thumbSize, [thumbSize, trackHeight]);
|
|
42
|
+
const x = (0, _framerMotion.useMotionValue)(0);
|
|
43
|
+
const {
|
|
44
|
+
icon,
|
|
45
|
+
styles: iconStyles
|
|
46
|
+
} = (0, _design.useThumbIcon)(x, iconColor);
|
|
47
|
+
const dragControls = (0, _framerMotion.useDragControls)();
|
|
48
|
+
const vibrationTrigger = (0, _framerMotion.useTransform)(x,
|
|
49
|
+
// round to 10 to avoid unnecessary vibrate calls
|
|
50
|
+
value => Math.round(value / 10) * 10);
|
|
51
|
+
const lastVibrationValue = (0, _react.useRef)(0);
|
|
52
|
+
(0, _react.useEffect)(() => {
|
|
53
|
+
vibrationTrigger.on('change', value => {
|
|
54
|
+
if (!isCompletedRef.current && value !== lastVibrationValue.current) {
|
|
55
|
+
lastVibrationValue.current = value;
|
|
56
|
+
void (0, _chaynsApi.vibrate)({
|
|
57
|
+
pattern: [10]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}, [vibrationTrigger]);
|
|
62
|
+
const containerAnimation = (0, _framerMotion.useAnimation)();
|
|
63
|
+
const thumbVariants = (0, _react.useMemo)(() => (0, _Slider.createThumbVariants)({
|
|
64
|
+
thumbSize,
|
|
65
|
+
trackWidth,
|
|
66
|
+
scaleFactor
|
|
67
|
+
}), [scaleFactor, thumbSize, trackWidth]);
|
|
68
|
+
const textOpacity = (0, _framerMotion.useTransform)(x, [0, 120], [1, 0]);
|
|
69
|
+
|
|
70
|
+
// this is the relative value of the right edge of the thumb
|
|
71
|
+
const relativeValue = (0, _framerMotion.useTransform)(x, value => {
|
|
72
|
+
if (!value) return 0;
|
|
73
|
+
const thumbRadius = thumbSize * scaleFactor;
|
|
74
|
+
return parseFloat(((value + thumbRadius) / trackWidth * 100).toPrecision(2));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// this is the relative value of the center of the thumb, it is used for the background gradient
|
|
78
|
+
const relativeBackgroundValue = (0, _framerMotion.useTransform)(x, value => {
|
|
79
|
+
if (!value) return 0;
|
|
80
|
+
const thumbRadius = thumbSize * scaleFactor / 2;
|
|
81
|
+
return parseFloat(((value + thumbRadius) / trackWidth * 100).toPrecision(2));
|
|
82
|
+
});
|
|
83
|
+
const trackBackground = (0, _framerMotion.useTransform)(relativeBackgroundValue, value => {
|
|
84
|
+
if (isCompleted) return devalueColor;
|
|
85
|
+
if (!value) return 'transparent';
|
|
86
|
+
return `linear-gradient(to right, ${devalueColor} ${value}%, transparent ${value}%)`;
|
|
87
|
+
});
|
|
88
|
+
const handlePointerDownCapture = (0, _react.useCallback)(() => {
|
|
89
|
+
void (0, _chaynsApi.invokeCall)({
|
|
90
|
+
action: 19,
|
|
91
|
+
value: {
|
|
92
|
+
pattern: [50],
|
|
93
|
+
iOSFeedbackVibration: 7
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}, []);
|
|
97
|
+
const handleRedeem = (0, _react.useCallback)(async () => {
|
|
98
|
+
setShowWaitCursor(true);
|
|
99
|
+
setIsCompleted(true);
|
|
100
|
+
isCompletedRef.current = true;
|
|
101
|
+
const devaluePromise = onDevalue();
|
|
102
|
+
const sleepPromise = (0, _common.sleep)(1000);
|
|
103
|
+
const [devalued] = await Promise.all([devaluePromise, sleepPromise]);
|
|
104
|
+
if (!devalued.success) {
|
|
105
|
+
setShowWaitCursor(false);
|
|
106
|
+
setIsCompleted(false);
|
|
107
|
+
isCompletedRef.current = false;
|
|
108
|
+
await containerAnimation.start('base');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
setShowWaitCursor(false);
|
|
112
|
+
setIconColor('white');
|
|
113
|
+
void (0, _chaynsApi.invokeCall)({
|
|
114
|
+
action: 19,
|
|
115
|
+
value: {
|
|
116
|
+
iOSFeedbackVibration: 3,
|
|
117
|
+
pattern: [100, 200, 100]
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
await containerAnimation.start('completed');
|
|
121
|
+
await containerAnimation.start('leaving');
|
|
122
|
+
onComplete === null || onComplete === void 0 || onComplete();
|
|
123
|
+
}, [containerAnimation, onComplete, onDevalue]);
|
|
124
|
+
const handleTrackRef = (0, _react.useCallback)(node => {
|
|
125
|
+
setTrackRef(node);
|
|
126
|
+
}, []);
|
|
127
|
+
const handleDragStart = (0, _react.useCallback)(() => {
|
|
128
|
+
void containerAnimation.start('dragging');
|
|
129
|
+
}, [containerAnimation]);
|
|
130
|
+
const handleDragEnd = (0, _react.useCallback)(() => {
|
|
131
|
+
if (relativeValue.get() > 98) {
|
|
132
|
+
void handleRedeem();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
void containerAnimation.start('base');
|
|
136
|
+
}, [relativeValue, containerAnimation, handleRedeem]);
|
|
137
|
+
(0, _react.useEffect)(() => {
|
|
138
|
+
void containerAnimation.start('base');
|
|
139
|
+
}, [containerAnimation]);
|
|
140
|
+
(0, _react.useEffect)(() => {
|
|
141
|
+
if (isCompleted) return () => {};
|
|
142
|
+
return relativeValue.on('change', onChange);
|
|
143
|
+
}, [isCompleted, onChange, relativeValue]);
|
|
144
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
145
|
+
disable: () => {
|
|
146
|
+
setIsDisabled(true);
|
|
147
|
+
setShowWaitCursor(false);
|
|
148
|
+
setIsCompleted(false);
|
|
149
|
+
isCompletedRef.current = false;
|
|
150
|
+
void containerAnimation.start('base');
|
|
151
|
+
},
|
|
152
|
+
enable: () => {
|
|
153
|
+
setIsDisabled(false);
|
|
154
|
+
}
|
|
155
|
+
}), [containerAnimation]);
|
|
156
|
+
const baseFontSize = (0, _react.useMemo)(() => 22, []);
|
|
157
|
+
return /*#__PURE__*/_react.default.createElement(_Slider.Container, {
|
|
158
|
+
animate: containerAnimation
|
|
159
|
+
}, /*#__PURE__*/_react.default.createElement(_Slider.Track, {
|
|
160
|
+
$height: trackHeight,
|
|
161
|
+
$borderSize: borderSize,
|
|
162
|
+
$backgroundColor: color,
|
|
163
|
+
ref: handleTrackRef
|
|
164
|
+
}, /*#__PURE__*/_react.default.createElement(_Slider.TrackBackground, {
|
|
165
|
+
$height: trackHeight,
|
|
166
|
+
style: {
|
|
167
|
+
background: trackBackground
|
|
168
|
+
}
|
|
169
|
+
}), /*#__PURE__*/_react.default.createElement(_Slider.Thumb, {
|
|
170
|
+
variants: thumbVariants,
|
|
171
|
+
$size: thumbSize,
|
|
172
|
+
$trackHeight: trackHeight,
|
|
173
|
+
style: {
|
|
174
|
+
x
|
|
175
|
+
},
|
|
176
|
+
drag: isCompleted || isDisabled ? false : 'x',
|
|
177
|
+
dragElastic: 0,
|
|
178
|
+
onPointerDownCapture: handlePointerDownCapture,
|
|
179
|
+
whileTap: {
|
|
180
|
+
scale: 1.4,
|
|
181
|
+
cursor: 'grabbing'
|
|
182
|
+
},
|
|
183
|
+
onDragStart: handleDragStart,
|
|
184
|
+
onDragEnd: handleDragEnd,
|
|
185
|
+
dragControls: dragControls,
|
|
186
|
+
dragConstraints: {
|
|
187
|
+
right: trackWidth - thumbSize * scaleFactor,
|
|
188
|
+
left: 0
|
|
189
|
+
}
|
|
190
|
+
}, /*#__PURE__*/_react.default.createElement(_Slider.ThumbIconContainer, null, !showWaitCursor && /*#__PURE__*/_react.default.createElement(_Slider.ThumbIcon, {
|
|
191
|
+
key: "thumb-icon",
|
|
192
|
+
icon: icon,
|
|
193
|
+
variants: _Slider.THUMB_ICON_VARIANTS,
|
|
194
|
+
style: iconStyles
|
|
195
|
+
}), showWaitCursor && /*#__PURE__*/_react.default.createElement(_core.SmallWaitCursor, {
|
|
196
|
+
shouldHideBackground: true,
|
|
197
|
+
color: "black"
|
|
198
|
+
}))), /*#__PURE__*/_react.default.createElement(_Slider.TrackText, {
|
|
199
|
+
style: {
|
|
200
|
+
opacity: textOpacity
|
|
201
|
+
},
|
|
202
|
+
$color: "white",
|
|
203
|
+
$baseFontSize: baseFontSize
|
|
204
|
+
}, trackText)));
|
|
205
|
+
});
|
|
206
|
+
var _default = exports.default = Slider;
|
|
207
|
+
//# sourceMappingURL=Slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Slider.js","names":["_core","require","_size","_interopRequireDefault","_chaynsApi","_framerMotion","_react","_interopRequireWildcard","_design","_common","_Slider","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Slider","forwardRef","color","devalueColor","trackHeight","thumbSize","borderSize","trackText","onChange","onDevalue","Promise","resolve","success","onComplete","ref","trackRef","setTrackRef","useState","trackWidth","useSize","initialWidth","initialHeight","iconColor","setIconColor","isCompleted","setIsCompleted","isDisabled","setIsDisabled","isCompletedRef","useRef","showWaitCursor","setShowWaitCursor","scaleFactor","useMemo","x","useMotionValue","icon","styles","iconStyles","useThumbIcon","dragControls","useDragControls","vibrationTrigger","useTransform","value","Math","round","lastVibrationValue","useEffect","on","current","vibrate","pattern","containerAnimation","useAnimation","thumbVariants","createThumbVariants","textOpacity","relativeValue","thumbRadius","parseFloat","toPrecision","relativeBackgroundValue","trackBackground","handlePointerDownCapture","useCallback","invokeCall","action","iOSFeedbackVibration","handleRedeem","devaluePromise","sleepPromise","sleep","devalued","all","start","handleTrackRef","node","handleDragStart","handleDragEnd","useImperativeHandle","disable","enable","baseFontSize","createElement","Container","animate","Track","$height","$borderSize","$backgroundColor","TrackBackground","style","background","Thumb","variants","$size","$trackHeight","drag","dragElastic","onPointerDownCapture","whileTap","scale","cursor","onDragStart","onDragEnd","dragConstraints","right","left","ThumbIconContainer","ThumbIcon","key","THUMB_ICON_VARIANTS","SmallWaitCursor","shouldHideBackground","TrackText","opacity","$color","$baseFontSize","_default","exports"],"sources":["../../../../src/components/slider/Slider.tsx"],"sourcesContent":["import { SmallWaitCursor } from '@chayns-components/core';\nimport useSize from '@react-hook/size';\nimport { invokeCall, vibrate } from 'chayns-api';\nimport {\n useAnimation,\n useDragControls,\n useMotionValue,\n useTransform,\n type DragHandlers,\n} from 'framer-motion';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useThumbIcon } from '../../hooks/design';\nimport { sleep } from '../../utils/common';\nimport type { DevalueSliderProps } from '../DevalueSlider';\nimport {\n Container,\n createThumbVariants,\n Thumb,\n ThumbIcon,\n ThumbIconContainer,\n THUMB_ICON_VARIANTS,\n Track,\n TrackBackground,\n TrackText,\n} from './Slider.styles';\n\nexport type SliderProps = {\n color: NonNullable<DevalueSliderProps['backgroundColor']>;\n devalueColor: NonNullable<DevalueSliderProps['devalueBackgroundColor']>;\n thumbSize?: number;\n trackHeight?: number;\n trackText?: string;\n borderSize?: number;\n onChange: DevalueSliderProps['onChange'];\n onDevalue: DevalueSliderProps['onDevalue'];\n onComplete: DevalueSliderProps['onComplete'];\n};\n\nexport type SliderRef = {\n disable: () => void;\n enable: () => void;\n};\n\nconst Slider = forwardRef<SliderRef, SliderProps>(\n (\n {\n color,\n devalueColor,\n trackHeight = 50,\n thumbSize = 40,\n borderSize = 2,\n trackText = 'EINLÖSEN',\n onChange = () => {},\n onDevalue = () => Promise.resolve({ success: true }),\n onComplete,\n },\n ref,\n ) => {\n const [trackRef, setTrackRef] = useState<HTMLDivElement | null>(null);\n const [trackWidth] = useSize(trackRef, { initialWidth: 300, initialHeight: 50 });\n const [iconColor, setIconColor] = useState('black');\n const [isCompleted, setIsCompleted] = useState(false);\n const [isDisabled, setIsDisabled] = useState(false);\n const isCompletedRef = useRef(isCompleted);\n const [showWaitCursor, setShowWaitCursor] = useState(false);\n const scaleFactor = useMemo(() => trackHeight / thumbSize, [thumbSize, trackHeight]);\n\n const x = useMotionValue(0);\n const { icon, styles: iconStyles } = useThumbIcon(x, iconColor);\n const dragControls = useDragControls();\n\n const vibrationTrigger = useTransform(\n x,\n // round to 10 to avoid unnecessary vibrate calls\n (value) => Math.round(value / 10) * 10,\n );\n const lastVibrationValue = useRef(0);\n useEffect(() => {\n vibrationTrigger.on('change', (value) => {\n if (!isCompletedRef.current && value !== lastVibrationValue.current) {\n lastVibrationValue.current = value;\n void vibrate({ pattern: [10] });\n }\n });\n }, [vibrationTrigger]);\n\n const containerAnimation = useAnimation();\n const thumbVariants = useMemo(\n () =>\n createThumbVariants({\n thumbSize,\n trackWidth,\n scaleFactor,\n }),\n [scaleFactor, thumbSize, trackWidth],\n );\n\n const textOpacity = useTransform(x, [0, 120], [1, 0]);\n\n // this is the relative value of the right edge of the thumb\n const relativeValue = useTransform(x, (value) => {\n if (!value) return 0;\n const thumbRadius = thumbSize * scaleFactor;\n return parseFloat((((value + thumbRadius) / trackWidth) * 100).toPrecision(2));\n });\n\n // this is the relative value of the center of the thumb, it is used for the background gradient\n const relativeBackgroundValue = useTransform(x, (value) => {\n if (!value) return 0;\n const thumbRadius = (thumbSize * scaleFactor) / 2;\n return parseFloat((((value + thumbRadius) / trackWidth) * 100).toPrecision(2));\n });\n\n const trackBackground = useTransform(relativeBackgroundValue, (value) => {\n if (isCompleted) return devalueColor;\n if (!value) return 'transparent';\n return `linear-gradient(to right, ${devalueColor} ${value}%, transparent ${value}%)`;\n });\n\n const handlePointerDownCapture = useCallback(() => {\n void invokeCall({\n action: 19,\n value: {\n pattern: [50],\n iOSFeedbackVibration: 7,\n },\n });\n }, []);\n\n const handleRedeem = useCallback(async () => {\n setShowWaitCursor(true);\n setIsCompleted(true);\n isCompletedRef.current = true;\n\n const devaluePromise = onDevalue();\n const sleepPromise = sleep(1000);\n const [devalued] = await Promise.all([devaluePromise, sleepPromise]);\n\n if (!devalued.success) {\n setShowWaitCursor(false);\n setIsCompleted(false);\n isCompletedRef.current = false;\n await containerAnimation.start('base');\n return;\n }\n\n setShowWaitCursor(false);\n setIconColor('white');\n void invokeCall({\n action: 19,\n value: {\n iOSFeedbackVibration: 3,\n pattern: [100, 200, 100],\n },\n });\n\n await containerAnimation.start('completed');\n await containerAnimation.start('leaving');\n onComplete?.();\n }, [containerAnimation, onComplete, onDevalue]);\n\n const handleTrackRef = useCallback((node: HTMLDivElement | null) => {\n setTrackRef(node);\n }, []);\n\n const handleDragStart = useCallback<NonNullable<DragHandlers['onDragStart']>>(() => {\n void containerAnimation.start('dragging');\n }, [containerAnimation]);\n\n const handleDragEnd = useCallback<NonNullable<DragHandlers['onDragEnd']>>(() => {\n if (relativeValue.get() > 98) {\n void handleRedeem();\n return;\n }\n\n void containerAnimation.start('base');\n }, [relativeValue, containerAnimation, handleRedeem]);\n\n useEffect(() => {\n void containerAnimation.start('base');\n }, [containerAnimation]);\n\n useEffect(() => {\n if (isCompleted) return () => {};\n return relativeValue.on('change', onChange);\n }, [isCompleted, onChange, relativeValue]);\n\n useImperativeHandle(\n ref,\n () => ({\n disable: () => {\n setIsDisabled(true);\n setShowWaitCursor(false);\n setIsCompleted(false);\n isCompletedRef.current = false;\n void containerAnimation.start('base');\n },\n enable: () => {\n setIsDisabled(false);\n },\n }),\n [containerAnimation],\n );\n\n const baseFontSize = useMemo(() => 22, []);\n\n return (\n <Container animate={containerAnimation}>\n <Track\n $height={trackHeight}\n $borderSize={borderSize}\n $backgroundColor={color}\n ref={handleTrackRef}\n >\n <TrackBackground\n $height={trackHeight}\n style={{ background: trackBackground }}\n />\n <Thumb\n variants={thumbVariants}\n $size={thumbSize}\n $trackHeight={trackHeight}\n style={{ x }}\n drag={isCompleted || isDisabled ? false : 'x'}\n dragElastic={0}\n onPointerDownCapture={handlePointerDownCapture}\n whileTap={{ scale: 1.4, cursor: 'grabbing' }}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n dragControls={dragControls}\n dragConstraints={{\n right: trackWidth - thumbSize * scaleFactor,\n left: 0,\n }}\n >\n <ThumbIconContainer>\n {!showWaitCursor && (\n <ThumbIcon\n key=\"thumb-icon\"\n icon={icon}\n variants={THUMB_ICON_VARIANTS}\n style={iconStyles}\n />\n )}\n {showWaitCursor && (\n <SmallWaitCursor shouldHideBackground color=\"black\" />\n )}\n </ThumbIconContainer>\n </Thumb>\n <TrackText\n style={{ opacity: textOpacity }}\n $color=\"white\"\n $baseFontSize={baseFontSize}\n >\n {trackText}\n </TrackText>\n </Track>\n </Container>\n );\n },\n);\n\nexport default Slider;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAOA,IAAAK,MAAA,GAAAC,uBAAA,CAAAN,OAAA;AASA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAEA,IAAAS,OAAA,GAAAT,OAAA;AAUyB,SAAAU,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAA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;IACzBvC,YAAY,EAAEA,YAAa;IAC3BkE,eAAe,EAAE;MACbC,KAAK,EAAEzF,UAAU,GAAGb,SAAS,GAAG2B,WAAW;MAC3C4E,IAAI,EAAE;IACV;EAAE,gBAEFrI,MAAA,CAAAW,OAAA,CAAAkG,aAAA,CAACzG,OAAA,CAAAkI,kBAAkB,QACd,CAAC/E,cAAc,iBACZvD,MAAA,CAAAW,OAAA,CAAAkG,aAAA,CAACzG,OAAA,CAAAmI,SAAS;IACNC,GAAG,EAAC,YAAY;IAChB3E,IAAI,EAAEA,IAAK;IACX2D,QAAQ,EAAEiB,2BAAoB;IAC9BpB,KAAK,EAAEtD;EAAW,CACrB,CACJ,EACAR,cAAc,iBACXvD,MAAA,CAAAW,OAAA,CAAAkG,aAAA,CAACnH,KAAA,CAAAgJ,eAAe;IAACC,oBAAoB;IAAChH,KAAK,EAAC;EAAO,CAAE,CAEzC,CACjB,CAAC,eACR3B,MAAA,CAAAW,OAAA,CAAAkG,aAAA,CAACzG,OAAA,CAAAwI,SAAS;IACNvB,KAAK,EAAE;MAAEwB,OAAO,EAAE3D;IAAY,CAAE;IAChC4D,MAAM,EAAC,OAAO;IACdC,aAAa,EAAEnC;EAAa,GAE3B5E,SACM,CACR,CACA,CAAC;AAEpB,CACJ,CAAC;AAAC,IAAAgH,QAAA,GAAAC,OAAA,CAAAtI,OAAA,GAEac,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createThumbVariants = exports.TrackText = exports.TrackBackground = exports.Track = exports.ThumbIconContainer = exports.ThumbIcon = exports.Thumb = exports.THUMB_ICON_VARIANTS = exports.Container = void 0;
|
|
7
|
+
var _framerMotion = require("framer-motion");
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const Container = exports.Container = (0, _styledComponents.default)(_framerMotion.motion.div)``;
|
|
11
|
+
const Track = exports.Track = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
12
|
+
user-select: none;
|
|
13
|
+
position: relative;
|
|
14
|
+
z-index: 3;
|
|
15
|
+
height: ${({
|
|
16
|
+
$height
|
|
17
|
+
}) => $height}px;
|
|
18
|
+
border-radius: ${({
|
|
19
|
+
$height
|
|
20
|
+
}) => $height / 2}px;
|
|
21
|
+
background-color: ${({
|
|
22
|
+
$backgroundColor
|
|
23
|
+
}) => $backgroundColor};
|
|
24
|
+
`;
|
|
25
|
+
const TrackBackground = exports.TrackBackground = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
26
|
+
position: absolute;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
border-radius: ${({
|
|
30
|
+
$height
|
|
31
|
+
}) => $height / 2}px;
|
|
32
|
+
z-index: 2;
|
|
33
|
+
`;
|
|
34
|
+
const Thumb = exports.Thumb = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
35
|
+
height: ${({
|
|
36
|
+
$size
|
|
37
|
+
}) => $size}px;
|
|
38
|
+
width: ${({
|
|
39
|
+
$size
|
|
40
|
+
}) => $size}px;
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
background-color: white;
|
|
43
|
+
left: ${({
|
|
44
|
+
$size,
|
|
45
|
+
$trackHeight
|
|
46
|
+
}) => ($trackHeight - $size - 2) / 2}px;
|
|
47
|
+
bottom: ${({
|
|
48
|
+
$size,
|
|
49
|
+
$trackHeight
|
|
50
|
+
}) => ($trackHeight - $size - 2) / 2 + 1}px;
|
|
51
|
+
position: absolute;
|
|
52
|
+
z-index: 3;
|
|
53
|
+
box-shadow: rgba(0, 0, 0, 0.2) 1px 1px 2px 0;
|
|
54
|
+
`;
|
|
55
|
+
const TrackText = exports.TrackText = (0, _styledComponents.default)(_framerMotion.motion.div)`
|
|
56
|
+
position: absolute;
|
|
57
|
+
line-height: 1.15;
|
|
58
|
+
font-size: ${({
|
|
59
|
+
$baseFontSize
|
|
60
|
+
}) => $baseFontSize}px;
|
|
61
|
+
font-weight: 700;
|
|
62
|
+
color: ${({
|
|
63
|
+
$color
|
|
64
|
+
}) => $color};
|
|
65
|
+
top: 50%;
|
|
66
|
+
left: 50%;
|
|
67
|
+
transform: translate(-50%, -50%);
|
|
68
|
+
white-space: nowrap;
|
|
69
|
+
text-overflow: ellipsis;
|
|
70
|
+
z-index: 1;
|
|
71
|
+
font-family:
|
|
72
|
+
Roboto Regular,
|
|
73
|
+
sans-serif;
|
|
74
|
+
|
|
75
|
+
@font-face {
|
|
76
|
+
font-family: 'Roboto Regular';
|
|
77
|
+
font-style: normal;
|
|
78
|
+
font-weight: normal;
|
|
79
|
+
src:
|
|
80
|
+
local('Roboto Regular'),
|
|
81
|
+
local('Roboto Regular'),
|
|
82
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.woff2) format('woff2'),
|
|
83
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.woff) format('woff'),
|
|
84
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.ttf)
|
|
85
|
+
format('truetype'),
|
|
86
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Regular.svg) format('svg');
|
|
87
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@font-face {
|
|
91
|
+
font-family: 'Roboto Regular';
|
|
92
|
+
font-style: italic;
|
|
93
|
+
font-weight: normal;
|
|
94
|
+
src:
|
|
95
|
+
local('Roboto Regular Italic'),
|
|
96
|
+
local('Roboto Regular-Italic'),
|
|
97
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.woff2) format('woff2'),
|
|
98
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.woff) format('woff'),
|
|
99
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.ttf) format('truetype'),
|
|
100
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Italic.svg) format('svg');
|
|
101
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@font-face {
|
|
105
|
+
font-family: 'Roboto Regular';
|
|
106
|
+
font-style: normal;
|
|
107
|
+
font-weight: bold;
|
|
108
|
+
src:
|
|
109
|
+
local('Roboto Regular Bold'),
|
|
110
|
+
local('Roboto Regular-Bold'),
|
|
111
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.woff2) format('woff2'),
|
|
112
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.woff) format('woff'),
|
|
113
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.ttf) format('truetype'),
|
|
114
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/Bold.svg) format('svg');
|
|
115
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@font-face {
|
|
119
|
+
font-family: 'Roboto Regular';
|
|
120
|
+
font-style: italic;
|
|
121
|
+
font-weight: bold;
|
|
122
|
+
src:
|
|
123
|
+
local('Roboto Regular Bold Italic'),
|
|
124
|
+
local('Roboto Regular-BoldItalic'),
|
|
125
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.woff2)
|
|
126
|
+
format('woff2'),
|
|
127
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.woff)
|
|
128
|
+
format('woff'),
|
|
129
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.ttf)
|
|
130
|
+
format('truetype'),
|
|
131
|
+
url(https://api.chayns-static.space/font/Roboto%20Regular/ItalicBold.svg) format('svg');
|
|
132
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@font-face {
|
|
136
|
+
font-family: 'Roboto Bold';
|
|
137
|
+
font-style: normal;
|
|
138
|
+
font-weight: normal;
|
|
139
|
+
src:
|
|
140
|
+
local('Roboto Bold'),
|
|
141
|
+
local('Roboto Bold'),
|
|
142
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.woff2) format('woff2'),
|
|
143
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.woff) format('woff'),
|
|
144
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.ttf) format('truetype'),
|
|
145
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Regular.svg) format('svg');
|
|
146
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@font-face {
|
|
150
|
+
font-family: 'Roboto Bold';
|
|
151
|
+
font-style: italic;
|
|
152
|
+
font-weight: normal;
|
|
153
|
+
src:
|
|
154
|
+
local('Roboto Bold Italic'),
|
|
155
|
+
local('Roboto Bold-Italic'),
|
|
156
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.woff2) format('woff2'),
|
|
157
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.woff) format('woff'),
|
|
158
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.ttf) format('truetype'),
|
|
159
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Italic.svg) format('svg');
|
|
160
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@font-face {
|
|
164
|
+
font-family: 'Roboto Bold';
|
|
165
|
+
font-style: normal;
|
|
166
|
+
font-weight: bold;
|
|
167
|
+
src:
|
|
168
|
+
local('Roboto Bold Bold'),
|
|
169
|
+
local('Roboto Bold-Bold'),
|
|
170
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.woff2) format('woff2'),
|
|
171
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.woff) format('woff'),
|
|
172
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.ttf) format('truetype'),
|
|
173
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/Bold.svg) format('svg');
|
|
174
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@font-face {
|
|
178
|
+
font-family: 'Roboto Bold';
|
|
179
|
+
font-style: italic;
|
|
180
|
+
font-weight: bold;
|
|
181
|
+
src:
|
|
182
|
+
local('Roboto Bold Bold Italic'),
|
|
183
|
+
local('Roboto Bold-BoldItalic'),
|
|
184
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.woff2) format('woff2'),
|
|
185
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.woff) format('woff'),
|
|
186
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.ttf)
|
|
187
|
+
format('truetype'),
|
|
188
|
+
url(https://api.chayns-static.space/font/Roboto%20Bold/ItalicBold.svg) format('svg');
|
|
189
|
+
unicode-range: U+0020-00FF, U+20A0-20CF, U+2122, U+2000-206F;
|
|
190
|
+
}
|
|
191
|
+
`;
|
|
192
|
+
const ThumbIconContainer = exports.ThumbIconContainer = _styledComponents.default.div`
|
|
193
|
+
position: relative;
|
|
194
|
+
width: 100%;
|
|
195
|
+
height: 100%;
|
|
196
|
+
display: flex;
|
|
197
|
+
flex-direction: row;
|
|
198
|
+
justify-content: center;
|
|
199
|
+
align-items: center;
|
|
200
|
+
`;
|
|
201
|
+
const ThumbIcon = exports.ThumbIcon = (0, _styledComponents.default)(_framerMotion.motion.i).attrs(({
|
|
202
|
+
icon
|
|
203
|
+
}) => ({
|
|
204
|
+
className: `react-chayns-icon ${icon}`
|
|
205
|
+
}))`
|
|
206
|
+
font-size: 22px;
|
|
207
|
+
z-index: 1;
|
|
208
|
+
color: black;
|
|
209
|
+
padding: 5px;
|
|
210
|
+
`;
|
|
211
|
+
const createThumbVariants = ({
|
|
212
|
+
thumbSize,
|
|
213
|
+
trackWidth,
|
|
214
|
+
scaleFactor
|
|
215
|
+
}) => ({
|
|
216
|
+
base: {
|
|
217
|
+
x: 0,
|
|
218
|
+
backgroundColor: 'white',
|
|
219
|
+
transition: {
|
|
220
|
+
duration: 0.2
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
completed: {
|
|
224
|
+
x: (trackWidth - thumbSize * scaleFactor) / 2,
|
|
225
|
+
backgroundColor: 'transparent',
|
|
226
|
+
boxShadow: 'none',
|
|
227
|
+
transition: {
|
|
228
|
+
duration: 0.3
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
leaving: {
|
|
232
|
+
scale: [1, 2.4, 1],
|
|
233
|
+
boxShadow: 'none'
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
exports.createThumbVariants = createThumbVariants;
|
|
237
|
+
const THUMB_ICON_VARIANTS = exports.THUMB_ICON_VARIANTS = {
|
|
238
|
+
base: {
|
|
239
|
+
x: [0, 8, 0, 8, 0],
|
|
240
|
+
transition: {
|
|
241
|
+
duration: 1,
|
|
242
|
+
ease: 'easeInOut',
|
|
243
|
+
repeat: Infinity,
|
|
244
|
+
repeatDelay: 5
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
dragging: {
|
|
248
|
+
x: 0
|
|
249
|
+
},
|
|
250
|
+
completed: {
|
|
251
|
+
opacity: 1,
|
|
252
|
+
transition: {
|
|
253
|
+
duration: 0
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
leaving: {
|
|
257
|
+
opacity: 1,
|
|
258
|
+
scale: [1, 2.4, 1],
|
|
259
|
+
transition: {
|
|
260
|
+
duration: 0.4,
|
|
261
|
+
ease: 'easeInOut'
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
//# sourceMappingURL=Slider.styles.js.map
|