@veritree/ui 0.97.1 → 0.98.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.
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="relative flex
|
|
2
|
+
<div class="relative flex px-0.5 items-center" :class="containerClass">
|
|
3
3
|
<input
|
|
4
4
|
ref="input"
|
|
5
5
|
:id="id"
|
|
6
6
|
:checked="checkedComputed"
|
|
7
7
|
:disabled="disabled"
|
|
8
8
|
:value="valueComputed"
|
|
9
|
-
class="absolute inset-0 appearance-none peer rounded-full transition-colors bg-gray-400
|
|
9
|
+
class="absolute inset-0 appearance-none peer rounded-full transition-colors bg-gray-400 disabled:bg-gray-200"
|
|
10
|
+
:class="variantClass"
|
|
10
11
|
role="switch"
|
|
11
12
|
type="checkbox"
|
|
12
13
|
@change="onChange"
|
|
13
14
|
/>
|
|
14
15
|
<span
|
|
15
|
-
class="
|
|
16
|
+
class="rounded-full bg-white transition-transform translate-x-0 pointer-events-none peer-disabled:bg-gray-400"
|
|
17
|
+
:class="thumbClass"
|
|
16
18
|
/>
|
|
17
19
|
</div>
|
|
18
20
|
</template>
|
|
@@ -36,6 +38,16 @@ export default {
|
|
|
36
38
|
type: [Array, Boolean, Number, String],
|
|
37
39
|
default: false,
|
|
38
40
|
},
|
|
41
|
+
size: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: 'normal',
|
|
44
|
+
validator: (value) => ['normal', 'small'].includes(value),
|
|
45
|
+
},
|
|
46
|
+
variant: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: 'primary',
|
|
49
|
+
validator: (value) => ['primary', 'dark'].includes(value),
|
|
50
|
+
},
|
|
39
51
|
},
|
|
40
52
|
|
|
41
53
|
computed: {
|
|
@@ -43,6 +55,22 @@ export default {
|
|
|
43
55
|
return this.value;
|
|
44
56
|
},
|
|
45
57
|
|
|
58
|
+
containerClass() {
|
|
59
|
+
return this.size === 'small' ? 'w-6 h-4' : 'w-11 h-6';
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
thumbClass() {
|
|
63
|
+
return this.size === 'small'
|
|
64
|
+
? 'size-3 peer-checked:translate-x-2'
|
|
65
|
+
: 'size-5 peer-checked:translate-x-full';
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
variantClass() {
|
|
69
|
+
return this.variant === 'dark'
|
|
70
|
+
? 'checked:bg-gray-800'
|
|
71
|
+
: 'checked:bg-secondary-300';
|
|
72
|
+
},
|
|
73
|
+
|
|
46
74
|
valueComputed: {
|
|
47
75
|
get() {
|
|
48
76
|
return this.value;
|