@mmb-digital/design-system-web 0.1.0

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.
Files changed (127) hide show
  1. package/.babelrc.json +16 -0
  2. package/.eslintrc.js +165 -0
  3. package/.prettierrc.js +15 -0
  4. package/.storybook/main.ts +23 -0
  5. package/.storybook/preview.tsx +27 -0
  6. package/dist/cjs/index.js +131 -0
  7. package/dist/cjs/index.js.map +1 -0
  8. package/dist/cjs/types/jest.config.d.ts +7 -0
  9. package/dist/cjs/types/src/components/button/button.d.ts +4 -0
  10. package/dist/cjs/types/src/components/button/button.styles.d.ts +4 -0
  11. package/dist/cjs/types/src/components/button/button.test.d.ts +1 -0
  12. package/dist/cjs/types/src/components/button/button.types.d.ts +29 -0
  13. package/dist/cjs/types/src/components/form/hint/formHint.d.ts +4 -0
  14. package/dist/cjs/types/src/components/form/hint/formHint.style.d.ts +1 -0
  15. package/dist/cjs/types/src/components/form/hint/formHint.types.d.ts +4 -0
  16. package/dist/cjs/types/src/components/slider/slider/slider.d.ts +5 -0
  17. package/dist/cjs/types/src/components/slider/slider/slider.style.d.ts +5 -0
  18. package/dist/cjs/types/src/components/slider/slider/slider.types.d.ts +47 -0
  19. package/dist/cjs/types/src/components/slider/slider/sliderFunction/default/sliderFunctionDefault.d.ts +2 -0
  20. package/dist/cjs/types/src/components/slider/slider/sliderFunction/default/sliderStep.d.ts +7 -0
  21. package/dist/cjs/types/src/components/slider/slider/sliderFunction/default/sliderStep.test.d.ts +1 -0
  22. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderFunctionLinearVisualSteps.d.ts +2 -0
  23. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.d.ts +8 -0
  24. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.test.d.ts +1 -0
  25. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.d.ts +9 -0
  26. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.test.d.ts +1 -0
  27. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.d.ts +2 -0
  28. package/dist/cjs/types/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.test.d.ts +1 -0
  29. package/dist/cjs/types/src/components/slider/slider/sliderHandleSvgHandler.d.ts +2 -0
  30. package/dist/cjs/types/src/components/storeButton/assets/androidSvg.d.ts +8 -0
  31. package/dist/cjs/types/src/components/storeButton/assets/appleSvg.d.ts +8 -0
  32. package/dist/cjs/types/src/components/storeButton/storeButton.d.ts +4 -0
  33. package/dist/cjs/types/src/components/storeButton/storeButton.styles.d.ts +3 -0
  34. package/dist/cjs/types/src/components/storeButton/storeButton.test.d.ts +1 -0
  35. package/dist/cjs/types/src/components/storeButton/storeButton.types.d.ts +13 -0
  36. package/dist/cjs/types/src/icons/systemIcon.d.ts +8 -0
  37. package/dist/cjs/types/src/index.d.ts +1 -0
  38. package/dist/cjs/types/src/provider/storybook/storybookProvider.d.ts +4 -0
  39. package/dist/cjs/types/src/provider/storybook/storybookProvider.types.d.ts +4 -0
  40. package/dist/cjs/types/src/provider/styledComponents/theme/styledComponentsThemeProvider.d.ts +4 -0
  41. package/dist/cjs/types/src/provider/styledComponents/theme/styledComponentsThemeProvider.types..d.ts +4 -0
  42. package/dist/cjs/types/src/style/styledComponents/theme.d.ts +441 -0
  43. package/dist/esm/index.js +131 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/types/jest.config.d.ts +7 -0
  46. package/dist/esm/types/src/components/button/button.d.ts +4 -0
  47. package/dist/esm/types/src/components/button/button.styles.d.ts +4 -0
  48. package/dist/esm/types/src/components/button/button.test.d.ts +1 -0
  49. package/dist/esm/types/src/components/button/button.types.d.ts +29 -0
  50. package/dist/esm/types/src/components/form/hint/formHint.d.ts +4 -0
  51. package/dist/esm/types/src/components/form/hint/formHint.style.d.ts +1 -0
  52. package/dist/esm/types/src/components/form/hint/formHint.types.d.ts +4 -0
  53. package/dist/esm/types/src/components/slider/slider/slider.d.ts +5 -0
  54. package/dist/esm/types/src/components/slider/slider/slider.style.d.ts +5 -0
  55. package/dist/esm/types/src/components/slider/slider/slider.types.d.ts +47 -0
  56. package/dist/esm/types/src/components/slider/slider/sliderFunction/default/sliderFunctionDefault.d.ts +2 -0
  57. package/dist/esm/types/src/components/slider/slider/sliderFunction/default/sliderStep.d.ts +7 -0
  58. package/dist/esm/types/src/components/slider/slider/sliderFunction/default/sliderStep.test.d.ts +1 -0
  59. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderFunctionLinearVisualSteps.d.ts +2 -0
  60. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.d.ts +8 -0
  61. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.test.d.ts +1 -0
  62. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.d.ts +9 -0
  63. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.test.d.ts +1 -0
  64. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.d.ts +2 -0
  65. package/dist/esm/types/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.test.d.ts +1 -0
  66. package/dist/esm/types/src/components/slider/slider/sliderHandleSvgHandler.d.ts +2 -0
  67. package/dist/esm/types/src/components/storeButton/assets/androidSvg.d.ts +8 -0
  68. package/dist/esm/types/src/components/storeButton/assets/appleSvg.d.ts +8 -0
  69. package/dist/esm/types/src/components/storeButton/storeButton.d.ts +4 -0
  70. package/dist/esm/types/src/components/storeButton/storeButton.styles.d.ts +3 -0
  71. package/dist/esm/types/src/components/storeButton/storeButton.test.d.ts +1 -0
  72. package/dist/esm/types/src/components/storeButton/storeButton.types.d.ts +13 -0
  73. package/dist/esm/types/src/icons/systemIcon.d.ts +8 -0
  74. package/dist/esm/types/src/index.d.ts +1 -0
  75. package/dist/esm/types/src/provider/storybook/storybookProvider.d.ts +4 -0
  76. package/dist/esm/types/src/provider/storybook/storybookProvider.types.d.ts +4 -0
  77. package/dist/esm/types/src/provider/styledComponents/theme/styledComponentsThemeProvider.d.ts +4 -0
  78. package/dist/esm/types/src/provider/styledComponents/theme/styledComponentsThemeProvider.types..d.ts +4 -0
  79. package/dist/esm/types/src/style/styledComponents/theme.d.ts +441 -0
  80. package/jest.config.ts +197 -0
  81. package/package.json +97 -0
  82. package/readme.md +39 -0
  83. package/rollup.config.js +33 -0
  84. package/src/@types/json.d.ts +5 -0
  85. package/src/@types/styledComponentCssProps.d.ts +11 -0
  86. package/src/@types/styledComponentTheme.d.ts +9 -0
  87. package/src/components/button/button.stories.tsx +97 -0
  88. package/src/components/button/button.styles.ts +162 -0
  89. package/src/components/button/button.test.tsx +25 -0
  90. package/src/components/button/button.tsx +31 -0
  91. package/src/components/button/button.types.ts +33 -0
  92. package/src/components/form/hint/formHint.style.ts +10 -0
  93. package/src/components/form/hint/formHint.tsx +13 -0
  94. package/src/components/form/hint/formHint.types.ts +5 -0
  95. package/src/components/slider/slider/slider.stories.tsx +176 -0
  96. package/src/components/slider/slider/slider.style.ts +29 -0
  97. package/src/components/slider/slider/slider.tsx +136 -0
  98. package/src/components/slider/slider/slider.types.ts +58 -0
  99. package/src/components/slider/slider/sliderFunction/default/sliderFunctionDefault.ts +21 -0
  100. package/src/components/slider/slider/sliderFunction/default/sliderStep.test.ts +90 -0
  101. package/src/components/slider/slider/sliderFunction/default/sliderStep.ts +18 -0
  102. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderFunctionLinearVisualSteps.ts +28 -0
  103. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.test.ts +83 -0
  104. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax.ts +34 -0
  105. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.test.ts +249 -0
  106. package/src/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue.ts +41 -0
  107. package/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.test.ts +204 -0
  108. package/src/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue.ts +35 -0
  109. package/src/components/slider/slider/sliderHandleSvgHandler.ts +26 -0
  110. package/src/components/storeButton/assets/androidSvg.tsx +159 -0
  111. package/src/components/storeButton/assets/appleSvg.tsx +31 -0
  112. package/src/components/storeButton/storeButton.stories.tsx +67 -0
  113. package/src/components/storeButton/storeButton.styles.ts +36 -0
  114. package/src/components/storeButton/storeButton.test.tsx +22 -0
  115. package/src/components/storeButton/storeButton.tsx +30 -0
  116. package/src/components/storeButton/storeButton.types.tsx +15 -0
  117. package/src/icons/systemIcon.tsx +26 -0
  118. package/src/index.ts +1 -0
  119. package/src/provider/storybook/storybookProvider.tsx +11 -0
  120. package/src/provider/storybook/storybookProvider.types.ts +5 -0
  121. package/src/provider/styledComponents/theme/styledComponentsThemeProvider.tsx +14 -0
  122. package/src/provider/styledComponents/theme/styledComponentsThemeProvider.types..ts +5 -0
  123. package/src/style/styledComponents/mmb_variables-5224.json +958 -0
  124. package/src/style/styledComponents/theme.ts +450 -0
  125. package/stylelint.config.js +15 -0
  126. package/tsconfig.json +29 -0
  127. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,83 @@
1
+ import { getSliderMax } from '@/components/slider/slider/sliderFunction/linearVisualSteps/sliderMax';
2
+ import { SliderSteps } from '@/components/slider/slider/slider.types';
3
+
4
+ describe('Running Test for slider linear visual step sliderMax', () => {
5
+ test('linear step', () => {
6
+ const linerStep: SliderSteps = {
7
+ baseStep: 1,
8
+ breakpointList: [],
9
+ };
10
+
11
+ expect(
12
+ getSliderMax({
13
+ min: 10,
14
+ max: 20,
15
+ steps: linerStep,
16
+ }),
17
+ ).toBe(20);
18
+ });
19
+
20
+ test('multiple step 1', () => {
21
+ const linerStep: SliderSteps = {
22
+ baseStep: 1,
23
+ breakpointList: [
24
+ {
25
+ step: 2,
26
+ bottomBreakpoint: 20,
27
+ },
28
+ ],
29
+ };
30
+
31
+ expect(
32
+ getSliderMax({
33
+ min: 10,
34
+ max: 30,
35
+ steps: linerStep,
36
+ }),
37
+ ).toBe(25);
38
+ });
39
+
40
+ test('multiple step 2', () => {
41
+ const linerStep: SliderSteps = {
42
+ baseStep: 1,
43
+ breakpointList: [
44
+ {
45
+ step: 2,
46
+ bottomBreakpoint: 19,
47
+ },
48
+ ],
49
+ };
50
+
51
+ expect(
52
+ getSliderMax({
53
+ min: 10,
54
+ max: 30,
55
+ steps: linerStep,
56
+ }),
57
+ ).toBe(25);
58
+ });
59
+
60
+ test('multiple step 3', () => {
61
+ const linerStep: SliderSteps = {
62
+ baseStep: 1,
63
+ breakpointList: [
64
+ {
65
+ step: 2,
66
+ bottomBreakpoint: 20,
67
+ },
68
+ {
69
+ step: 3,
70
+ bottomBreakpoint: 30,
71
+ },
72
+ ],
73
+ };
74
+
75
+ expect(
76
+ getSliderMax({
77
+ min: 10,
78
+ max: 40,
79
+ steps: linerStep,
80
+ }),
81
+ ).toBe(29);
82
+ });
83
+ });
@@ -0,0 +1,34 @@
1
+ import { SliderBreakpoint, SliderSteps } from '@/components/slider/slider/slider.types';
2
+
3
+ interface GetSliderMaxParam {
4
+ readonly max: number;
5
+ readonly min: number;
6
+ readonly steps: SliderSteps;
7
+ }
8
+
9
+ export const getSliderMax = (param: GetSliderMaxParam): number => {
10
+ const { max, min, steps } = param;
11
+
12
+ const breakpoints: SliderBreakpoint[] = [{ step: steps.baseStep, bottomBreakpoint: min }, ...steps.breakpointList];
13
+
14
+ const sliderMax = breakpoints.reduce((accumulator, currentValue, currentIndex, array) => {
15
+ const { bottomBreakpoint: currenBottomBreakpoint, step } = currentValue;
16
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
17
+ const nextBreakpoint: number = array[currentIndex + 1]?.bottomBreakpoint === undefined ? max : array[currentIndex + 1].bottomBreakpoint;
18
+
19
+ let localSteps = 0;
20
+ let i = currenBottomBreakpoint;
21
+ while (i + step < nextBreakpoint) {
22
+ i = i + step;
23
+ localSteps = localSteps + 1;
24
+ }
25
+
26
+ if (i < nextBreakpoint) {
27
+ return accumulator + localSteps + 1;
28
+ }
29
+
30
+ return accumulator + localSteps;
31
+ }, min);
32
+
33
+ return sliderMax;
34
+ };
@@ -0,0 +1,249 @@
1
+ import { getSliderValueByValue } from '@/components/slider/slider/sliderFunction/linearVisualSteps/sliderValueByValue';
2
+ import { SliderSteps } from '@/components/slider/slider/slider.types';
3
+
4
+ describe('Running Test for slider linear visual step sliderValue', () => {
5
+ test('linear step', () => {
6
+ const steps: SliderSteps = {
7
+ baseStep: 1,
8
+ breakpointList: [],
9
+ };
10
+
11
+ expect(
12
+ getSliderValueByValue({
13
+ min: 10,
14
+ max: 20,
15
+ steps: steps,
16
+ value: 10,
17
+ }),
18
+ ).toBe(10);
19
+
20
+ expect(
21
+ getSliderValueByValue({
22
+ min: 10,
23
+ max: 20,
24
+ steps: steps,
25
+ value: 15,
26
+ }),
27
+ ).toBe(15);
28
+
29
+ expect(
30
+ getSliderValueByValue({
31
+ min: 10,
32
+ max: 20,
33
+ steps: steps,
34
+ value: 20,
35
+ }),
36
+ ).toBe(20);
37
+ });
38
+
39
+ test('multiple step 1', () => {
40
+ const steps: SliderSteps = {
41
+ baseStep: 1,
42
+ breakpointList: [
43
+ {
44
+ step: 2,
45
+ bottomBreakpoint: 20,
46
+ },
47
+ ],
48
+ };
49
+
50
+ expect(
51
+ getSliderValueByValue({
52
+ min: 10,
53
+ max: 30,
54
+ steps: steps,
55
+ value: 10,
56
+ }),
57
+ ).toBe(10);
58
+
59
+ expect(
60
+ getSliderValueByValue({
61
+ min: 10,
62
+ max: 30,
63
+ steps: steps,
64
+ value: 20,
65
+ }),
66
+ ).toBe(20);
67
+
68
+ expect(
69
+ getSliderValueByValue({
70
+ min: 10,
71
+ max: 30,
72
+ steps: steps,
73
+ value: 22,
74
+ }),
75
+ ).toBe(21);
76
+
77
+ expect(
78
+ getSliderValueByValue({
79
+ min: 10,
80
+ max: 30,
81
+ steps: steps,
82
+ value: 30,
83
+ }),
84
+ ).toBe(25);
85
+
86
+ expect(
87
+ getSliderValueByValue({
88
+ min: 10,
89
+ max: 30,
90
+ steps: steps,
91
+ value: 28,
92
+ }),
93
+ ).toBe(24);
94
+
95
+ expect(
96
+ getSliderValueByValue({
97
+ min: 10,
98
+ max: 30,
99
+ steps: steps,
100
+ value: 27,
101
+ }),
102
+ ).toBe(24);
103
+ });
104
+
105
+ test('multiple step 2', () => {
106
+ const steps: SliderSteps = {
107
+ baseStep: 1,
108
+ breakpointList: [
109
+ {
110
+ step: 2,
111
+ bottomBreakpoint: 20,
112
+ },
113
+ {
114
+ step: 3,
115
+ bottomBreakpoint: 30,
116
+ },
117
+ ],
118
+ };
119
+
120
+ expect(
121
+ getSliderValueByValue({
122
+ min: 10,
123
+ max: 40,
124
+ steps: steps,
125
+ value: 30,
126
+ }),
127
+ ).toBe(25);
128
+
129
+ expect(
130
+ getSliderValueByValue({
131
+ min: 10,
132
+ max: 40,
133
+ steps: steps,
134
+ value: 33,
135
+ }),
136
+ ).toBe(26);
137
+
138
+ expect(
139
+ getSliderValueByValue({
140
+ min: 10,
141
+ max: 40,
142
+ steps: steps,
143
+ value: 34,
144
+ }),
145
+ ).toBe(27);
146
+
147
+ expect(
148
+ getSliderValueByValue({
149
+ min: 10,
150
+ max: 40,
151
+ steps: steps,
152
+ value: 36,
153
+ }),
154
+ ).toBe(27);
155
+
156
+ expect(
157
+ getSliderValueByValue({
158
+ min: 10,
159
+ max: 40,
160
+ steps: steps,
161
+ value: 39,
162
+ }),
163
+ ).toBe(28);
164
+
165
+ expect(
166
+ getSliderValueByValue({
167
+ min: 10,
168
+ max: 40,
169
+ steps: steps,
170
+ value: 40,
171
+ }),
172
+ ).toBe(29);
173
+ });
174
+
175
+ test('multiple step 3', () => {
176
+ const steps: SliderSteps = {
177
+ baseStep: 3,
178
+ breakpointList: [
179
+ {
180
+ step: 4,
181
+ bottomBreakpoint: 20,
182
+ },
183
+ ],
184
+ };
185
+
186
+ expect(
187
+ getSliderValueByValue({
188
+ min: 10,
189
+ max: 50,
190
+ steps: steps,
191
+ value: 19,
192
+ }),
193
+ ).toBe(13);
194
+
195
+ expect(
196
+ getSliderValueByValue({
197
+ min: 10,
198
+ max: 50,
199
+ steps: steps,
200
+ value: 20,
201
+ }),
202
+ ).toBe(14);
203
+
204
+ expect(
205
+ getSliderValueByValue({
206
+ min: 10,
207
+ max: 50,
208
+ steps: steps,
209
+ value: 21,
210
+ }),
211
+ ).toBe(15);
212
+
213
+ expect(
214
+ getSliderValueByValue({
215
+ min: 10,
216
+ max: 50,
217
+ steps: steps,
218
+ value: 22,
219
+ }),
220
+ ).toBe(15);
221
+
222
+ expect(
223
+ getSliderValueByValue({
224
+ min: 10,
225
+ max: 50,
226
+ steps: steps,
227
+ value: 23,
228
+ }),
229
+ ).toBe(15);
230
+
231
+ expect(
232
+ getSliderValueByValue({
233
+ min: 10,
234
+ max: 50,
235
+ steps: steps,
236
+ value: 24,
237
+ }),
238
+ ).toBe(15);
239
+
240
+ expect(
241
+ getSliderValueByValue({
242
+ min: 10,
243
+ max: 50,
244
+ steps: steps,
245
+ value: 25,
246
+ }),
247
+ ).toBe(16);
248
+ });
249
+ });
@@ -0,0 +1,41 @@
1
+ import { SliderBreakpoint, SliderSteps } from '@/components/slider/slider/slider.types';
2
+
3
+ interface GetSliderValueByValueParam {
4
+ readonly max: number;
5
+ readonly min: number;
6
+ readonly steps: SliderSteps;
7
+ readonly value: number;
8
+ }
9
+
10
+ export const getSliderValueByValue = (param: GetSliderValueByValueParam): number => {
11
+ const { max, min, steps, value } = param;
12
+
13
+ const breakpoints: SliderBreakpoint[] = [{ step: steps.baseStep, bottomBreakpoint: min }, ...steps.breakpointList];
14
+
15
+ let sliderValue = min;
16
+
17
+ outerCycle: for (const [breakpointIndex, breakpoint] of breakpoints.entries()) {
18
+ const { bottomBreakpoint: currenBottomBreakpoint, step } = breakpoint;
19
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
20
+ const nextBreakpoint = breakpoints[breakpointIndex + 1]?.bottomBreakpoint === undefined ? max : breakpoints[breakpointIndex + 1].bottomBreakpoint;
21
+
22
+ let i: number = currenBottomBreakpoint;
23
+ if (value <= currenBottomBreakpoint) {
24
+ break;
25
+ }
26
+ while (i + step < nextBreakpoint) {
27
+ i = i + step;
28
+ sliderValue = sliderValue + 1;
29
+
30
+ if (i === value || (i > value && i < value + step)) {
31
+ break outerCycle;
32
+ }
33
+ }
34
+
35
+ if (i < nextBreakpoint) {
36
+ sliderValue = sliderValue + 1;
37
+ }
38
+ }
39
+
40
+ return sliderValue;
41
+ };
@@ -0,0 +1,204 @@
1
+ import { SliderSteps } from '@/components/slider/slider/slider.types';
2
+ import { getValueBySliderValue } from '@/components/slider/slider/sliderFunction/linearVisualSteps/valueBySliderValue';
3
+
4
+ describe('Running Test for slider linear visual step value', () => {
5
+ test('linear step', () => {
6
+ const steps: SliderSteps = {
7
+ baseStep: 1,
8
+ breakpointList: [],
9
+ };
10
+
11
+ expect(
12
+ getValueBySliderValue({
13
+ min: 10,
14
+ max: 20,
15
+ steps: steps,
16
+ sliderValue: 10,
17
+ }),
18
+ ).toBe(10);
19
+
20
+ expect(
21
+ getValueBySliderValue({
22
+ min: 10,
23
+ max: 20,
24
+ steps: steps,
25
+ sliderValue: 15,
26
+ }),
27
+ ).toBe(15);
28
+
29
+ expect(
30
+ getValueBySliderValue({
31
+ min: 10,
32
+ max: 20,
33
+ steps: steps,
34
+ sliderValue: 20,
35
+ }),
36
+ ).toBe(20);
37
+ });
38
+
39
+ test('multiple step 1', () => {
40
+ const steps: SliderSteps = {
41
+ baseStep: 1,
42
+ breakpointList: [
43
+ {
44
+ step: 2,
45
+ bottomBreakpoint: 20,
46
+ },
47
+ ],
48
+ };
49
+
50
+ expect(
51
+ getValueBySliderValue({
52
+ min: 10,
53
+ max: 30,
54
+ steps: steps,
55
+ sliderValue: 10,
56
+ }),
57
+ ).toBe(10);
58
+
59
+ expect(
60
+ getValueBySliderValue({
61
+ min: 10,
62
+ max: 30,
63
+ steps: steps,
64
+ sliderValue: 20,
65
+ }),
66
+ ).toBe(20);
67
+
68
+ expect(
69
+ getValueBySliderValue({
70
+ min: 10,
71
+ max: 30,
72
+ steps: steps,
73
+ sliderValue: 21,
74
+ }),
75
+ ).toBe(22);
76
+
77
+ expect(
78
+ getValueBySliderValue({
79
+ min: 10,
80
+ max: 30,
81
+ steps: steps,
82
+ sliderValue: 25,
83
+ }),
84
+ ).toBe(30);
85
+
86
+ expect(
87
+ getValueBySliderValue({
88
+ min: 10,
89
+ max: 30,
90
+ steps: steps,
91
+ sliderValue: 24,
92
+ }),
93
+ ).toBe(28);
94
+ });
95
+
96
+ test('multiple step 2', () => {
97
+ const steps: SliderSteps = {
98
+ baseStep: 1,
99
+ breakpointList: [
100
+ {
101
+ step: 2,
102
+ bottomBreakpoint: 20,
103
+ },
104
+ {
105
+ step: 3,
106
+ bottomBreakpoint: 30,
107
+ },
108
+ ],
109
+ };
110
+
111
+ expect(
112
+ getValueBySliderValue({
113
+ min: 10,
114
+ max: 40,
115
+ steps: steps,
116
+ sliderValue: 25,
117
+ }),
118
+ ).toBe(30);
119
+
120
+ expect(
121
+ getValueBySliderValue({
122
+ min: 10,
123
+ max: 40,
124
+ steps: steps,
125
+ sliderValue: 26,
126
+ }),
127
+ ).toBe(33);
128
+
129
+ expect(
130
+ getValueBySliderValue({
131
+ min: 10,
132
+ max: 40,
133
+ steps: steps,
134
+ sliderValue: 27,
135
+ }),
136
+ ).toBe(36);
137
+
138
+ expect(
139
+ getValueBySliderValue({
140
+ min: 10,
141
+ max: 40,
142
+ steps: steps,
143
+ sliderValue: 28,
144
+ }),
145
+ ).toBe(39);
146
+
147
+ expect(
148
+ getValueBySliderValue({
149
+ min: 10,
150
+ max: 40,
151
+ steps: steps,
152
+ sliderValue: 30,
153
+ }),
154
+ ).toBe(40);
155
+ });
156
+
157
+ test('multiple step 3', () => {
158
+ const steps: SliderSteps = {
159
+ baseStep: 3,
160
+ breakpointList: [
161
+ {
162
+ step: 4,
163
+ bottomBreakpoint: 20,
164
+ },
165
+ ],
166
+ };
167
+
168
+ expect(
169
+ getValueBySliderValue({
170
+ min: 10,
171
+ max: 50,
172
+ steps: steps,
173
+ sliderValue: 13,
174
+ }),
175
+ ).toBe(19);
176
+
177
+ expect(
178
+ getValueBySliderValue({
179
+ min: 10,
180
+ max: 50,
181
+ steps: steps,
182
+ sliderValue: 14,
183
+ }),
184
+ ).toBe(20);
185
+
186
+ expect(
187
+ getValueBySliderValue({
188
+ min: 10,
189
+ max: 50,
190
+ steps: steps,
191
+ sliderValue: 15,
192
+ }),
193
+ ).toBe(24);
194
+
195
+ expect(
196
+ getValueBySliderValue({
197
+ min: 10,
198
+ max: 50,
199
+ steps: steps,
200
+ sliderValue: 16,
201
+ }),
202
+ ).toBe(28);
203
+ });
204
+ });
@@ -0,0 +1,35 @@
1
+ import { SliderBreakpoint, SliderMapOnChangeFunction } from '@/components/slider/slider/slider.types';
2
+
3
+ export const getValueBySliderValue: SliderMapOnChangeFunction = (param): number => {
4
+ const { max, min, sliderValue, steps } = param;
5
+
6
+ const breakpoints: SliderBreakpoint[] = [{ step: steps.baseStep, bottomBreakpoint: min }, ...steps.breakpointList];
7
+
8
+ let currentSliderValue = min;
9
+ let currentValue = min;
10
+
11
+ while (currentSliderValue < sliderValue) {
12
+ let breakpointIndexFound = 0;
13
+ let breakpointFound: SliderBreakpoint = breakpoints[breakpointIndexFound];
14
+
15
+ for (const [currentBreakpointIndex, currentBreakpoint] of breakpoints.entries()) {
16
+ if (currentBreakpoint.bottomBreakpoint > currentValue) {
17
+ break;
18
+ }
19
+
20
+ breakpointIndexFound = currentBreakpointIndex;
21
+ breakpointFound = currentBreakpoint;
22
+ }
23
+
24
+ const breakpointFoundStep = breakpointFound.step;
25
+
26
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
27
+ const nextBreakpoint = breakpoints[breakpointIndexFound + 1]?.bottomBreakpoint === undefined ? max : breakpoints[breakpointIndexFound + 1].bottomBreakpoint;
28
+
29
+ const nextValue = currentValue + breakpointFoundStep;
30
+ currentValue = nextValue < nextBreakpoint ? nextValue : nextBreakpoint;
31
+ currentSliderValue = currentSliderValue + 1;
32
+ }
33
+
34
+ return currentValue;
35
+ };
@@ -0,0 +1,26 @@
1
+ import { theme } from '@/style/styledComponents/theme';
2
+ import { encode as encodeBase64 } from 'base-64';
3
+
4
+ export const getSliderHandleBackgroundSvg = (disable: boolean) => {
5
+ if (disable) {
6
+ return `
7
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
8
+ <circle cx="12" cy="12" r="11" stroke="${theme.colors.fg.disabled.light}" stroke-width="2"/>
9
+ </svg>`;
10
+ }
11
+
12
+ return `
13
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
14
+ <circle cx="12" cy="12" r="11" stroke="url(#paint0_linear_1206_76209)" stroke-width="2" />
15
+ <defs>
16
+ <linearGradient id="paint0_linear_1206_76209" x1="24" y1="0" x2="0" y2="24" gradientUnits="userSpaceOnUse">
17
+ <stop offset="0.0677083" stop-color="${theme.palette.pink600}"/>
18
+ <stop offset="1" stop-color="${theme.palette.blue600}"/>
19
+ </linearGradient>
20
+ </defs>
21
+ </svg>`;
22
+ };
23
+
24
+ export const getSliderHandleBackgroundSvgBase64 = (disable: boolean) => {
25
+ return encodeBase64(getSliderHandleBackgroundSvg(disable));
26
+ };