@bethinkpl/design-system 16.6.2 → 17.0.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.
@@ -4,34 +4,62 @@
4
4
  :class="{
5
5
  '-rounded': radius === TOGGLE_BUTTON_RADIUSES.ROUNDED,
6
6
  }"
7
- :disable="!isInteractive"
7
+ :disable="!isInteractiveComputed"
8
8
  :color="rippleColor"
9
9
  >
10
- <span
10
+ <div
11
11
  class="toggleButton"
12
12
  :class="{
13
- '-outlined': type === TOGGLE_BUTTON_TYPES.OUTLINED,
14
- '-filled': type === TOGGLE_BUTTON_TYPES.FILLED,
15
-
16
- '-xSmall': size === TOGGLE_BUTTON_SIZES.X_SMALL,
17
13
  '-small': size === TOGGLE_BUTTON_SIZES.SMALL,
14
+ '-medium': size === TOGGLE_BUTTON_SIZES.MEDIUM,
15
+ '-large': size === TOGGLE_BUTTON_SIZES.LARGE,
18
16
 
19
- '-long': isLong,
17
+ '-hasSmallHorizontalPadding': hasSmallHorizontalPadding,
20
18
 
21
19
  '-rounded': radius === TOGGLE_BUTTON_RADIUSES.ROUNDED,
22
20
 
23
21
  [colorClassName]: true,
24
22
 
25
- '-elevationXSmall': elevation === TOGGLE_BUTTON_ELEVATIONS.X_SMALL,
26
- '-elevationSmall': elevation === TOGGLE_BUTTON_ELEVATIONS.SMALL,
27
-
28
- '-interactive': isInteractive,
23
+ '-disabled': state === TOGGLE_BUTTON_STATES.DISABLED,
24
+ '-loading': state === TOGGLE_BUTTON_STATES.LOADING,
25
+ '-interactive': isInteractiveComputed,
29
26
  '-selected': isSelected,
30
27
  }"
31
- @click="isInteractive && $emit('click')"
28
+ @click="isInteractiveComputed && $emit('click')"
32
29
  >
33
- <span class="toggleButton__content">{{ text }}</span>
34
- </span>
30
+ <div class="toggleButton__contentWrapper">
31
+ <ds-icon
32
+ v-if="iconLeft"
33
+ class="toggleButton__icon"
34
+ :icon="iconLeft"
35
+ :size="iconSize"
36
+ />
37
+ <span
38
+ v-if="label"
39
+ class="toggleButton__content"
40
+ :class="{
41
+ '-small': labelSize === TOGGLE_BUTTON_LABEL_SIZES.SMALL,
42
+ '-uppercase': isLabelUppercase,
43
+ }"
44
+ >
45
+ {{ label }}
46
+ </span>
47
+ <ds-icon
48
+ v-if="iconRight"
49
+ class="toggleButton__icon"
50
+ :icon="iconRight"
51
+ :size="iconSize"
52
+ />
53
+ </div>
54
+
55
+ <ds-icon
56
+ v-if="state === TOGGLE_BUTTON_STATES.LOADING"
57
+ class="toggleButton__icon toggleButton__loadingSpinner"
58
+ :icon="ICONS.FAD_SPINNER_THIRD"
59
+ :size="iconSize"
60
+ spinning
61
+ />
62
+ </div>
35
63
  </ds-ripple>
36
64
  </template>
37
65
 
@@ -43,53 +71,170 @@
43
71
  @import '../../../../styles/settings/radiuses';
44
72
  @import '../../../../styles/settings/shadows';
45
73
 
46
- $toggle-button-size-x-small: 28px;
47
- $toggle-button-size-small: 32px;
48
- $toggle-button-size-medium: 40px;
74
+ $toggle-button-size-small: 28px;
75
+ $toggle-button-size-medium: 32px;
76
+ $toggle-button-size-large: 40px;
77
+
78
+ $toggle-button-border-size: 1px;
79
+ $toggle-button-border-size-large: 2px;
49
80
 
50
81
  $toggle-button-colors: (
51
- 'primary': (
52
- 'text': $color-primary-text,
53
- 'outline': $color-primary-border-weak,
54
- 'filled': (
55
- 'background': $color-primary-background-medium,
56
- 'background-hovered': $color-primary-background-medium-hovered,
57
- 'background-focused': $color-primary-background-medium-focused,
82
+ 'neutral': (
83
+ 'color': $color-neutral-text,
84
+ 'border': $color-neutral-border,
85
+ 'border-hovered': $color-neutral-border-hovered,
86
+ 'border-focused': $color-neutral-border-focused,
87
+ 'background': $color-neutral-background-ghost,
88
+ 'background-hovered': $color-neutral-background-ghost-hovered,
89
+ 'background-focused': $color-neutral-background-ghost-focused,
90
+ 'icon': $color-neutral-icon-weak,
91
+ 'outline-hovered': $color-neutral-background-ghost-hovered,
92
+ 'outline-focused': $color-neutral-background-ghost-focused,
93
+ 'disabled': (
94
+ 'color': $color-neutral-text-disabled,
95
+ 'border': $color-neutral-border-disabled,
96
+ 'background': $color-neutral-background-ghost-disabled,
97
+ 'icon': $color-neutral-icon-weak-disabled,
58
98
  ),
59
- 'outlined': (
99
+ 'selected': (
100
+ 'color': $color-neutral-text-heavy,
60
101
  'border': $color-primary-border,
61
- 'background': $color-primary-background-ghost,
62
- 'background-hovered': $color-primary-background-ghost-hovered,
63
- 'background-focused': $color-primary-background-ghost-focused,
102
+ 'border-hovered': $color-primary-border-hovered,
103
+ 'border-focused': $color-primary-border-focused,
104
+ 'background': $color-primary-background,
105
+ 'background-hovered': $color-primary-background-hovered,
106
+ 'background-focused': $color-primary-background-focused,
107
+ 'icon': $color-primary-icon,
108
+ 'outline-hovered': $color-primary-background-ghost-hovered,
109
+ 'outline-focused': $color-primary-background-ghost-focused,
110
+ 'disabled': (
111
+ 'color': $color-neutral-text-heavy-disabled,
112
+ 'border': $color-primary-border-disabled,
113
+ 'background': $color-primary-background-disabled,
114
+ 'icon': $color-primary-icon-disabled,
115
+ ),
116
+ ),
117
+ ),
118
+ 'neutralHeavy': (
119
+ 'color': $color-neutral-text,
120
+ 'border': $color-neutral-border-heavy,
121
+ 'border-hovered': $color-neutral-border-heavy-hovered,
122
+ 'border-focused': $color-neutral-border-heavy-focused,
123
+ 'background': $color-neutral-background-ghost,
124
+ 'background-hovered': $color-neutral-background-ghost-hovered,
125
+ 'background-focused': $color-neutral-background-ghost-focused,
126
+ 'icon': $color-neutral-icon,
127
+ 'outline-hovered': $color-neutral-background-ghost-hovered,
128
+ 'outline-focused': $color-neutral-background-ghost-focused,
129
+ 'disabled': (
130
+ 'color': $color-neutral-text-disabled,
131
+ 'border': $color-neutral-border-heavy-disabled,
132
+ 'background': $color-neutral-background-ghost-disabled,
133
+ 'icon': $color-neutral-icon-weak-disabled,
64
134
  ),
65
135
  'selected': (
66
- 'background': $color-primary-background-strong,
67
- 'background-hovered': $color-primary-background-strong-hovered,
68
- 'background-focused': $color-primary-background-strong-focused,
136
+ 'color': $color-neutral-text-heavy,
137
+ 'background': $color-primary-background,
138
+ 'background-hovered': $color-primary-background-hovered,
139
+ 'background-focused': $color-primary-background-focused,
140
+ 'border': $color-primary-border,
141
+ 'border-hovered': $color-primary-border-hovered,
142
+ 'border-focused': $color-primary-border-focused,
143
+ 'icon': $color-primary-icon,
144
+ 'outline-hovered': $color-primary-background-ghost-hovered,
145
+ 'outline-focused': $color-primary-background-ghost-focused,
146
+ 'disabled': (
147
+ 'color': $color-neutral-text-heavy-disabled,
148
+ 'border': $color-primary-border-disabled,
149
+ 'background': $color-primary-background-disabled,
150
+ 'icon': $color-primary-icon-disabled,
151
+ ),
69
152
  ),
70
153
  ),
71
- 'neutral': (
72
- 'text': $color-neutral-text-weak,
73
- 'outline': $color-neutral-border-weak,
74
- 'filled': (
75
- 'background': $color-neutral-background-medium,
76
- 'background-hovered': $color-neutral-background-medium-hovered,
77
- 'background-focused': $color-neutral-background-medium-focused,
78
- ),
79
- 'outlined': (
80
- 'border': $color-neutral-border-strong,
81
- 'background': $color-neutral-background-ghost,
82
- 'background-hovered': $color-neutral-background-ghost-hovered,
83
- 'background-focused': $color-neutral-background-ghost-focused,
154
+ 'neutralStrong': (
155
+ 'color': $color-neutral-text,
156
+ 'border': $color-neutral-border-strong,
157
+ 'border-hovered': $color-neutral-border-strong-hovered,
158
+ 'border-focused': $color-neutral-border-strong-focused,
159
+ 'background': $color-neutral-background-ghost,
160
+ 'background-hovered': $color-neutral-background-ghost-hovered,
161
+ 'background-focused': $color-neutral-background-ghost-focused,
162
+ 'icon': $color-neutral-icon,
163
+ 'outline-hovered': $color-neutral-background-ghost-hovered,
164
+ 'outline-focused': $color-neutral-background-ghost-focused,
165
+ 'disabled': (
166
+ 'color': $color-neutral-text-disabled,
167
+ 'border': $color-neutral-border-strong-disabled,
168
+ 'background': $color-neutral-background-ghost-disabled,
169
+ 'icon': $color-neutral-icon-disabled,
84
170
  ),
85
171
  'selected': (
172
+ 'color': $color-inverted-text,
86
173
  'background': $color-neutral-background-strong,
87
174
  'background-hovered': $color-neutral-background-strong-hovered,
88
175
  'background-focused': $color-neutral-background-strong-focused,
176
+ 'border': $color-neutral-background-strong,
177
+ 'border-hovered': $color-neutral-background-strong-hovered,
178
+ 'border-focused': $color-neutral-background-strong-focused,
179
+ 'icon': $color-inverted-icon,
180
+ 'outline-hovered': $color-neutral-background-ghost-hovered,
181
+ 'outline-focused': $color-neutral-background-ghost-focused,
182
+ 'disabled': (
183
+ 'color': $color-inverted-text-disabled,
184
+ 'border': $color-neutral-background-strong-disabled,
185
+ 'background': $color-neutral-background-strong-disabled,
186
+ 'icon': $color-inverted-icon-disabled,
187
+ ),
188
+ ),
189
+ ),
190
+ 'primary': (
191
+ 'color': $color-primary-text,
192
+ 'border': $color-primary-border,
193
+ 'border-hovered': $color-primary-border-hovered,
194
+ 'border-focused': $color-primary-border-focused,
195
+ 'background': $color-primary-background-ghost,
196
+ 'background-hovered': $color-primary-background-ghost-hovered,
197
+ 'background-focused': $color-primary-background-ghost-focused,
198
+ 'icon': $color-primary-icon-weak,
199
+ 'outline-hovered': $color-primary-background-ghost-hovered,
200
+ 'outline-focused': $color-primary-background-ghost-focused,
201
+ 'disabled': (
202
+ 'color': $color-primary-text-disabled,
203
+ 'border': $color-primary-border-disabled,
204
+ 'background': $color-neutral-background-ghost-disabled,
205
+ 'icon': $color-primary-icon-weak-disabled,
206
+ ),
207
+ 'selected': (
208
+ 'color': $color-inverted-text,
209
+ 'background': $color-primary-background-strong,
210
+ 'background-hovered': $color-primary-background-strong-hovered,
211
+ 'background-focused': $color-primary-background-strong-focused,
212
+ 'border': $color-primary-background-strong,
213
+ 'border-hovered': $color-primary-background-strong-hovered,
214
+ 'border-focused': $color-primary-background-strong-focused,
215
+ 'icon': $color-inverted-icon,
216
+ 'outline-hovered': $color-primary-background-ghost-hovered,
217
+ 'outline-focused': $color-primary-background-ghost-focused,
218
+ 'disabled': (
219
+ 'color': $color-inverted-text-disabled,
220
+ 'border': $color-primary-background-strong-disabled,
221
+ 'background': $color-primary-background-strong-disabled,
222
+ 'icon': $color-inverted-icon-disabled,
223
+ ),
89
224
  ),
90
225
  ),
91
226
  );
92
227
 
228
+ @function substract-border($padding, $size) {
229
+ $size-map: (
230
+ 'small': $toggle-button-border-size,
231
+ 'medium': $toggle-button-border-size,
232
+ 'large': $toggle-button-border-size-large,
233
+ );
234
+
235
+ @return $padding - map-get($size-map, $size);
236
+ }
237
+
93
238
  .toggleButtonWrapper {
94
239
  display: inline-block;
95
240
 
@@ -103,84 +248,105 @@ $toggle-button-colors: (
103
248
  }
104
249
 
105
250
  .toggleButton {
106
- @include label-l-default-bold;
251
+ $root: &;
107
252
 
108
253
  @each $color-name, $color-map in $toggle-button-colors {
109
254
  &.-color-#{$color-name} {
110
- color: map-get($color-map, 'text');
255
+ background-color: map-get($color-map, 'background');
256
+ border-color: map-get($color-map, 'border');
257
+ color: map-get($color-map, 'color');
111
258
 
112
259
  &:hover {
113
- outline-color: map-get($color-map, 'outline');
260
+ background-color: map-get($color-map, 'background-hovered');
261
+ border-color: map-get($color-map, 'border-hovered');
262
+ outline-color: map-get($color-map, 'outline-hovered');
114
263
  }
115
264
 
116
- &.-filled {
117
- background-color: map-get($color-map, 'filled', 'background');
265
+ &:focus {
266
+ background-color: map-get($color-map, 'background-focused');
267
+ border-color: map-get($color-map, 'border-focused');
268
+ outline-color: map-get($color-map, 'outline-focused');
269
+ }
270
+
271
+ &.-selected {
272
+ background-color: map-get($color-map, 'selected', 'background');
273
+ border-color: map-get($color-map, 'selected', 'border');
274
+ color: map-get($color-map, 'selected', 'color');
118
275
 
119
276
  &:hover {
120
- background-color: map-get($color-map, 'filled', 'background-hovered');
277
+ background-color: map-get($color-map, 'selected', 'background-hovered');
278
+ border-color: map-get($color-map, 'selected', 'border-hovered');
279
+ outline-color: map-get($color-map, 'selected', 'outline-hovered');
121
280
  }
122
281
 
123
282
  &:focus {
124
- background-color: map-get($color-map, 'filled', 'background-focused');
283
+ background-color: map-get($color-map, 'selected', 'background-focused');
284
+ border-color: map-get($color-map, 'selected', 'border-focused');
285
+ outline-color: map-get($color-map, 'selected', 'outline-focused');
125
286
  }
126
- }
127
-
128
- &.-outlined {
129
- background-color: map-get($color-map, 'outlined', 'background');
130
- border-color: map-get($color-map, 'outlined', 'border');
131
287
 
132
- &:hover {
133
- background-color: map-get($color-map, 'outlined', 'background-hovered');
288
+ #{$root}__icon {
289
+ color: map-get($color-map, 'selected', 'icon');
134
290
  }
291
+ }
135
292
 
136
- &:focus {
137
- background-color: map-get($color-map, 'outlined', 'background-focused');
293
+ &.-disabled {
294
+ background-color: map-get($color-map, 'disabled', 'background');
295
+ border-color: map-get($color-map, 'disabled', 'border');
296
+ color: map-get($color-map, 'disabled', 'color');
297
+
298
+ #{$root}__icon {
299
+ color: map-get($color-map, 'disabled', 'icon');
138
300
  }
139
301
  }
140
302
 
141
- &.-selected {
142
- background-color: map-get($color-map, 'selected', 'background');
303
+ &.-disabled.-selected {
304
+ background-color: map-get($color-map, 'selected', 'disabled', 'background');
305
+ border-color: map-get($color-map, 'selected', 'disabled', 'border');
306
+ color: map-get($color-map, 'selected', 'disabled', 'color');
143
307
 
144
- &:hover {
145
- background-color: map-get($color-map, 'selected', 'background-hovered');
308
+ #{$root}__icon {
309
+ color: map-get($color-map, 'selected', 'disabled', 'icon');
146
310
  }
311
+ }
147
312
 
148
- &:focus {
149
- background-color: map-get($color-map, 'selected', 'background-focused');
150
- }
313
+ #{$root}__icon {
314
+ color: map-get($color-map, 'icon');
151
315
  }
152
316
  }
153
317
  }
154
318
 
155
319
  align-items: center;
156
- // we can't use percent value because we don't want ellipse shape when text is longer
157
- // value it big enough to make circle when text is short
320
+ // we can't use percent value because we don't want ellipse shape when label is longer
321
+ // value it big enough to make circle when label is short
158
322
  border-radius: 100px;
323
+ border-style: solid;
324
+ border-width: $toggle-button-border-size;
159
325
  display: flex;
160
326
  justify-content: center;
161
- min-height: $toggle-button-size-medium;
162
- min-width: $toggle-button-size-medium;
163
327
  outline: 6px solid transparent;
164
- // vertical passing is smaller than designed, but we compensate that with `min-height`.
165
- // This shortcut allows us to use the same padding on .filled and .outlined versions, so number of variants is cut by half
166
- padding: $space-xxs;
167
328
  pointer-events: none;
168
329
  transition: color ease-in-out $default-transition-time,
169
330
  border-color ease-in-out $default-transition-time,
170
331
  background-color ease-in-out $default-transition-time,
171
332
  outline-color ease-in-out $default-transition-time;
172
333
 
334
+ &__contentWrapper {
335
+ align-items: center;
336
+ display: flex;
337
+ gap: $space-xxxxs;
338
+ justify-content: center;
339
+ }
340
+
173
341
  &__content {
342
+ @include label-l-default-bold;
343
+
174
344
  overflow: hidden;
175
345
  text-overflow: ellipsis;
176
346
  white-space: nowrap;
177
- }
178
-
179
- &.-long {
180
- padding: $space-xxs $space-s;
181
347
 
182
- &.-rounded {
183
- padding: $space-xxs $space-xs;
348
+ &.-uppercase {
349
+ @include label-l-default-bold-uppercase;
184
350
  }
185
351
  }
186
352
 
@@ -188,151 +354,213 @@ $toggle-button-colors: (
188
354
  border-radius: $radius-s;
189
355
  }
190
356
 
191
- &.-outlined {
192
- border: 2px solid;
193
- }
194
-
195
- &.-selected {
196
- color: $color-inverted-text;
197
- }
198
-
199
357
  &.-interactive {
200
358
  cursor: pointer;
201
359
  pointer-events: initial;
202
360
  }
203
361
 
204
- &.-xSmall {
205
- min-height: $toggle-button-size-x-small;
206
- min-width: $toggle-button-size-x-small;
207
- padding: $space-xxxxs;
208
-
209
- &.-long {
210
- padding: $space-xxxxs $space-xs;
211
-
212
- &.-rounded {
213
- padding: $space-xxxxs $space-xxs;
214
- }
362
+ &.-loading {
363
+ #{$root}__contentWrapper {
364
+ opacity: 0;
215
365
  }
216
366
  }
217
367
 
218
368
  &.-small {
219
369
  min-height: $toggle-button-size-small;
220
370
  min-width: $toggle-button-size-small;
221
- padding: $space-xxxs;
371
+ padding: substract-border($space-xxxs, 'small') substract-border($space-xs, 'small');
222
372
 
223
- &.-long {
224
- // Exception in padding rules in Figma. -capsule has the same padding as -rounded
225
- padding: $space-xxxs $space-xs;
373
+ &.-hasSmallHorizontalPadding {
374
+ padding: substract-border($space-xxxs, 'small') substract-border($space-xxxxxs, 'small');
375
+ }
226
376
 
227
- &.-rounded {
228
- padding: $space-xxxs $space-xs;
377
+ #{$root}__content.-small {
378
+ @include label-s-default-bold;
379
+
380
+ &.-uppercase {
381
+ @include label-s-default-bold-uppercase;
229
382
  }
230
383
  }
231
384
  }
232
385
 
233
- &.-elevationXSmall,
234
- &.-elevationSmall {
235
- background-color: $color-default-background;
386
+ &.-medium {
387
+ min-height: $toggle-button-size-medium;
388
+ min-width: $toggle-button-size-medium;
389
+ padding: substract-border($space-xxs, 'medium') substract-border($space-xs, 'medium');
390
+
391
+ &.-hasSmallHorizontalPadding {
392
+ padding: substract-border($space-xxs, 'medium')
393
+ substract-border($space-xxxxxs, 'medium');
394
+ }
395
+
396
+ #{$root}__content.-small {
397
+ @include label-m-default-bold;
398
+
399
+ &.-uppercase {
400
+ @include label-m-default-bold-uppercase;
401
+ }
402
+ }
236
403
  }
237
404
 
238
- &.-elevationSmall {
239
- box-shadow: $shadow-l;
405
+ &.-large {
406
+ border-width: $toggle-button-border-size-large;
407
+ min-height: $toggle-button-size-large;
408
+ min-width: $toggle-button-size-large;
409
+ padding: substract-border($space-xs, 'large') substract-border($space-s, 'large');
410
+
411
+ &.-hasSmallHorizontalPadding {
412
+ padding: substract-border($space-xxs, 'large') substract-border($space-xxxxxs, 'large');
413
+ }
414
+ }
415
+
416
+ &__loadingSpinner {
417
+ position: absolute;
240
418
  }
241
419
  }
242
420
  </style>
243
421
 
244
422
  <script lang="ts">
245
423
  import { Value } from '../../../utils/type.utils';
246
- import DsRipple, { RIPPLE_COLORS } from '../../Ripple';
424
+ import DsRipple, { RIPPLE_COLORS, RippleColor } from '../../Ripple';
425
+ import { PropType, toRaw } from 'vue';
247
426
 
248
427
  import {
249
428
  TOGGLE_BUTTON_COLORS,
250
- TOGGLE_BUTTON_ELEVATIONS,
429
+ TOGGLE_BUTTON_LABEL_SIZES,
251
430
  TOGGLE_BUTTON_RADIUSES,
252
431
  TOGGLE_BUTTON_SIZES,
253
- TOGGLE_BUTTON_TYPES,
432
+ TOGGLE_BUTTON_STATES,
433
+ ToggleButtonColor,
434
+ ToggleButtonLabelSize,
435
+ ToggleButtonRadius,
436
+ ToggleButtonSize,
437
+ ToggleButtonState,
254
438
  } from './ToggleButton.consts';
439
+ import { ICON_SIZES, IconItem, ICONS, IconSize } from '../../Icons/Icon';
440
+ import DsIcon from '../../Icons/Icon/Icon.vue';
255
441
 
256
442
  export default {
257
443
  name: 'ToggleButton',
258
444
  components: {
445
+ DsIcon,
259
446
  DsRipple,
260
447
  },
261
448
  props: {
262
- text: {
263
- type: String,
264
- default: '',
265
- },
266
- size: {
267
- type: String,
268
- default: TOGGLE_BUTTON_SIZES.MEDIUM,
269
- validator(value: Value<typeof TOGGLE_BUTTON_SIZES>) {
270
- return Object.values(TOGGLE_BUTTON_SIZES).includes(value);
271
- },
272
- },
273
- type: {
274
- type: String,
275
- default: TOGGLE_BUTTON_TYPES.FILLED,
276
- validator(value: Value<typeof TOGGLE_BUTTON_TYPES>) {
277
- return Object.values(TOGGLE_BUTTON_TYPES).includes(value);
278
- },
279
- },
280
449
  color: {
281
- type: String,
282
- default: TOGGLE_BUTTON_COLORS.PRIMARY,
450
+ type: String as PropType<ToggleButtonColor>,
451
+ default: TOGGLE_BUTTON_COLORS.NEUTRAL,
283
452
  validator(value: Value<typeof TOGGLE_BUTTON_COLORS>) {
284
453
  return Object.values(TOGGLE_BUTTON_COLORS).includes(value);
285
454
  },
286
455
  },
287
- radius: {
288
- type: String,
289
- default: TOGGLE_BUTTON_RADIUSES.CAPSULE,
290
- validator(value: Value<typeof TOGGLE_BUTTON_RADIUSES>) {
291
- return Object.values(TOGGLE_BUTTON_RADIUSES).includes(value);
456
+ hasSmallHorizontalPadding: {
457
+ type: Boolean,
458
+ default: false,
459
+ },
460
+ iconLeft: {
461
+ type: Object as PropType<IconItem>,
462
+ default: null,
463
+ validator(icon) {
464
+ return Object.values(ICONS).includes(toRaw(icon));
465
+ },
466
+ },
467
+ iconRight: {
468
+ type: Object as PropType<IconItem>,
469
+ default: null,
470
+ validator(icon) {
471
+ return Object.values(ICONS).includes(toRaw(icon));
292
472
  },
293
473
  },
294
474
  isInteractive: {
295
475
  type: Boolean,
296
476
  default: true,
297
477
  },
478
+ isLabelUppercase: {
479
+ type: Boolean,
480
+ default: false,
481
+ },
298
482
  isSelected: {
299
483
  type: Boolean,
300
484
  default: false,
301
485
  },
302
- elevation: {
486
+ label: {
303
487
  type: String,
304
- default: TOGGLE_BUTTON_ELEVATIONS.NONE,
305
- validator(value: Value<typeof TOGGLE_BUTTON_ELEVATIONS>) {
306
- return Object.values(TOGGLE_BUTTON_ELEVATIONS).includes(value);
488
+ default: '',
489
+ },
490
+ labelSize: {
491
+ type: String as PropType<ToggleButtonLabelSize>,
492
+ default: TOGGLE_BUTTON_SIZES.MEDIUM,
493
+ },
494
+ radius: {
495
+ type: String as PropType<ToggleButtonRadius>,
496
+ default: TOGGLE_BUTTON_RADIUSES.CAPSULE,
497
+ validator(value: Value<typeof TOGGLE_BUTTON_RADIUSES>) {
498
+ return Object.values(TOGGLE_BUTTON_RADIUSES).includes(value);
499
+ },
500
+ },
501
+ size: {
502
+ type: String as PropType<ToggleButtonSize>,
503
+ default: TOGGLE_BUTTON_SIZES.MEDIUM,
504
+ validator(value: Value<typeof TOGGLE_BUTTON_SIZES>) {
505
+ return Object.values(TOGGLE_BUTTON_SIZES).includes(value);
506
+ },
507
+ },
508
+ state: {
509
+ type: String as PropType<ToggleButtonState>,
510
+ default: TOGGLE_BUTTON_STATES.DEFAULT,
511
+ validator(value: Value<typeof TOGGLE_BUTTON_STATES>) {
512
+ return Object.values(TOGGLE_BUTTON_STATES).includes(value);
307
513
  },
308
514
  },
309
515
  },
310
516
  emits: ['click'],
311
517
  data() {
312
518
  return {
519
+ ICONS: Object.freeze(ICONS),
313
520
  TOGGLE_BUTTON_COLORS: Object.freeze(TOGGLE_BUTTON_COLORS),
314
- TOGGLE_BUTTON_ELEVATIONS: Object.freeze(TOGGLE_BUTTON_ELEVATIONS),
315
- TOGGLE_BUTTON_SIZES: Object.freeze(TOGGLE_BUTTON_SIZES),
316
- TOGGLE_BUTTON_TYPES: Object.freeze(TOGGLE_BUTTON_TYPES),
521
+ TOGGLE_BUTTON_LABEL_SIZES: Object.freeze(TOGGLE_BUTTON_LABEL_SIZES),
317
522
  TOGGLE_BUTTON_RADIUSES: Object.freeze(TOGGLE_BUTTON_RADIUSES),
523
+ TOGGLE_BUTTON_SIZES: Object.freeze(TOGGLE_BUTTON_SIZES),
524
+ TOGGLE_BUTTON_STATES: Object.freeze(TOGGLE_BUTTON_STATES),
318
525
  };
319
526
  },
320
527
  computed: {
321
528
  colorClassName(): string {
322
529
  return `-color-${this.color}`;
323
530
  },
324
- rippleColor() {
325
- if (this.isSelected) {
326
- return RIPPLE_COLORS.INVERTED;
531
+ iconSize(): IconSize {
532
+ return this.size === TOGGLE_BUTTON_SIZES.LARGE
533
+ ? ICON_SIZES.X_SMALL
534
+ : ICON_SIZES.XX_SMALL;
535
+ },
536
+ isInteractiveComputed(): boolean {
537
+ if (this.state !== TOGGLE_BUTTON_STATES.DEFAULT) {
538
+ return false;
327
539
  }
328
540
 
329
- return {
330
- [TOGGLE_BUTTON_COLORS.NEUTRAL]: RIPPLE_COLORS.NEUTRAL,
331
- [TOGGLE_BUTTON_COLORS.PRIMARY]: RIPPLE_COLORS.PRIMARY,
332
- }[this.color];
541
+ return this.isInteractive;
333
542
  },
334
- isLong() {
335
- return this.text.length > 1;
543
+ rippleColor(): RippleColor {
544
+ const map = {
545
+ [TOGGLE_BUTTON_COLORS.NEUTRAL]: {
546
+ false: RIPPLE_COLORS.NEUTRAL,
547
+ true: RIPPLE_COLORS.PRIMARY,
548
+ },
549
+ [TOGGLE_BUTTON_COLORS.NEUTRAL_HEAVY]: {
550
+ false: RIPPLE_COLORS.NEUTRAL,
551
+ true: RIPPLE_COLORS.PRIMARY,
552
+ },
553
+ [TOGGLE_BUTTON_COLORS.NEUTRAL_STRONG]: {
554
+ false: RIPPLE_COLORS.NEUTRAL,
555
+ true: RIPPLE_COLORS.INVERTED,
556
+ },
557
+ [TOGGLE_BUTTON_COLORS.PRIMARY]: {
558
+ false: RIPPLE_COLORS.PRIMARY,
559
+ true: RIPPLE_COLORS.INVERTED,
560
+ },
561
+ };
562
+
563
+ return map[this.color][this.isSelected];
336
564
  },
337
565
  },
338
566
  };