@lemonadejs/switch 1.3.2 → 5.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.
- package/dist/index.js +12 -4
- package/dist/style.css +61 -17
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13,9 +13,17 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
13
13
|
|
|
14
14
|
const onchange = self.onchange;
|
|
15
15
|
|
|
16
|
-
self.onchange = function(prop,
|
|
17
|
-
if (
|
|
18
|
-
|
|
16
|
+
self.onchange = function(prop, a, b, c, d) {
|
|
17
|
+
if (typeof(c) !== 'undefined') {
|
|
18
|
+
// Version 4
|
|
19
|
+
if (c !== d && typeof(onchange) === 'function') {
|
|
20
|
+
onchange.call(self, self, self.value);
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
// Version 5
|
|
24
|
+
if (a !== b && typeof(onchange) === 'function') {
|
|
25
|
+
onchange.call(self, self, self.value);
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
|
|
@@ -25,7 +33,7 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
|
|
28
|
-
return `<label class="lm-switch" position="{{self.position}}">
|
|
36
|
+
return `<label class="lm-switch" position="{{self.position}}" data-color="{{self.color}}">
|
|
29
37
|
<input type="checkbox" name="{{self.name}}" disabled="{{self.disabled}}" :bind="self.value" /> <span>{{self.text}}</span>
|
|
30
38
|
</label>`
|
|
31
39
|
}
|
package/dist/style.css
CHANGED
|
@@ -1,8 +1,45 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--lm-switch-front-color: 0,0,0;
|
|
3
|
+
--lm-switch-primary-color: 255,255,255;
|
|
4
|
+
--lm-switch-main-color: var(--lm-main-color, #1565C0);
|
|
5
|
+
--lm-switch-main-color-alpha: var(--lm-main-color-alpha, #1565C088);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.lm-switch[data-color="green"] {
|
|
9
|
+
--lm-switch-main-color: var(--lm-main-color, #2E7D32);
|
|
10
|
+
--lm-switch-main-color-alpha: var(--lm-main-color-alpha, #2E7D3288);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.lm-switch[data-color="orange"] {
|
|
14
|
+
--lm-switch-main-color: var(--lm-main-color, #EF6C00);
|
|
15
|
+
--lm-switch-main-color-alpha: var(--lm-main-color-alpha, #EF6C0088);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.lm-switch[data-color="red"] {
|
|
19
|
+
--lm-switch-main-color: var(--lm-main-color, #C62828);
|
|
20
|
+
--lm-switch-main-color-alpha: var(--lm-main-color-alpha, #C6282888);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.lm-switch[data-color="purple"] {
|
|
24
|
+
--lm-switch-main-color: var(--lm-main-color, #6A1B9A);
|
|
25
|
+
--lm-switch-main-color-alpha: var(--lm-main-color-alpha, #6A1B9A88);
|
|
26
|
+
}
|
|
27
|
+
|
|
1
28
|
.lm-switch {
|
|
2
29
|
position: relative;
|
|
3
30
|
display: inline-flex;
|
|
4
31
|
z-index: 0;
|
|
5
32
|
align-items: center;
|
|
33
|
+
min-width: 36px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
label.lm-switch {
|
|
37
|
+
display: inline-flex;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.lm-switch:before {
|
|
41
|
+
content: '';
|
|
42
|
+
min-height: 1em;
|
|
6
43
|
}
|
|
7
44
|
|
|
8
45
|
.lm-switch > input {
|
|
@@ -14,10 +51,10 @@
|
|
|
14
51
|
margin: 0;
|
|
15
52
|
display: block;
|
|
16
53
|
border-radius: 50%;
|
|
17
|
-
width:
|
|
18
|
-
height:
|
|
19
|
-
max-width:
|
|
20
|
-
max-height:
|
|
54
|
+
width: 30px;
|
|
55
|
+
height: 30px;
|
|
56
|
+
max-width: 30px;
|
|
57
|
+
max-height: 30px;
|
|
21
58
|
outline: none;
|
|
22
59
|
opacity: 0;
|
|
23
60
|
transform: scale(1);
|
|
@@ -32,6 +69,8 @@
|
|
|
32
69
|
cursor: pointer;
|
|
33
70
|
margin: 0 0 0 45px;
|
|
34
71
|
align-items: center;
|
|
72
|
+
box-sizing: border-box;
|
|
73
|
+
max-width: -webkit-fill-available;
|
|
35
74
|
}
|
|
36
75
|
|
|
37
76
|
.lm-switch > span:empty {
|
|
@@ -45,7 +84,7 @@
|
|
|
45
84
|
border-radius: 7px;
|
|
46
85
|
width: 36px;
|
|
47
86
|
height: 14px;
|
|
48
|
-
background-color: rgba(var(--lm-switch-front-color
|
|
87
|
+
background-color: rgba(var(--lm-switch-front-color), 0.38);
|
|
49
88
|
transition: background-color 0.2s, opacity 0.2s;
|
|
50
89
|
}
|
|
51
90
|
|
|
@@ -56,27 +95,27 @@
|
|
|
56
95
|
border-radius: 50%;
|
|
57
96
|
width: 20px;
|
|
58
97
|
height: 20px;
|
|
59
|
-
background-color: rgb(var(
|
|
98
|
+
background-color: rgb(var(--lm-switch-primary-color));
|
|
60
99
|
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
|
61
100
|
transition: background-color 0.2s, transform 0.2s;
|
|
62
101
|
}
|
|
63
102
|
|
|
64
103
|
.lm-switch > input:checked {
|
|
65
|
-
left:
|
|
66
|
-
background-color: var(--lm-main-color
|
|
104
|
+
left: 11px;
|
|
105
|
+
background-color: var(--lm-switch-main-color);
|
|
67
106
|
}
|
|
68
107
|
|
|
69
108
|
.lm-switch > input:not(:checked) {
|
|
70
|
-
left: -
|
|
109
|
+
left: -5px;
|
|
71
110
|
background-color: var(--lm-secondary-color, #6A6A6A);
|
|
72
111
|
}
|
|
73
112
|
|
|
74
113
|
.lm-switch > input:checked + span::before {
|
|
75
|
-
background-color: var(--lm-main-color-alpha
|
|
114
|
+
background-color: var(--lm-switch-main-color-alpha);
|
|
76
115
|
}
|
|
77
116
|
|
|
78
117
|
.lm-switch > input:checked + span::after {
|
|
79
|
-
background-color: var(--lm-main-color
|
|
118
|
+
background-color: var(--lm-switch-main-color);
|
|
80
119
|
transform: translateX(16px);
|
|
81
120
|
}
|
|
82
121
|
|
|
@@ -100,11 +139,11 @@
|
|
|
100
139
|
}
|
|
101
140
|
|
|
102
141
|
.lm-switch > input:active + span::before {
|
|
103
|
-
background-color: var(--lm-main-color-alpha
|
|
142
|
+
background-color: var(--lm-switch-main-color-alpha);
|
|
104
143
|
}
|
|
105
144
|
|
|
106
145
|
.lm-switch > input:checked:active + span::before {
|
|
107
|
-
background-color: rgba(var(--lm-front-color
|
|
146
|
+
background-color: rgba(var(--lm-switch-front-color), 0.38);
|
|
108
147
|
}
|
|
109
148
|
|
|
110
149
|
.lm-switch > input:disabled {
|
|
@@ -112,17 +151,17 @@
|
|
|
112
151
|
}
|
|
113
152
|
|
|
114
153
|
.lm-switch > input:disabled + span {
|
|
115
|
-
color: rgb(var(--lm-front-color
|
|
154
|
+
color: rgb(var(--lm-switch-front-color));
|
|
116
155
|
opacity: 0.50;
|
|
117
156
|
cursor: default;
|
|
118
157
|
}
|
|
119
158
|
|
|
120
159
|
.lm-switch > input:disabled + span::before {
|
|
121
|
-
background-color: rgba(var(--lm-front-color
|
|
160
|
+
background-color: rgba(var(--lm-switch-front-color), 0.38);
|
|
122
161
|
}
|
|
123
162
|
|
|
124
163
|
.lm-switch > input:checked:disabled + span::before {
|
|
125
|
-
background-color: var(--lm-main-color-alpha
|
|
164
|
+
background-color: var(--lm-switch-main-color-alpha);
|
|
126
165
|
}
|
|
127
166
|
|
|
128
167
|
.lm-switch[position="right"] > span {
|
|
@@ -131,7 +170,12 @@
|
|
|
131
170
|
|
|
132
171
|
.lm-switch[position="right"] > input {
|
|
133
172
|
left: initial;
|
|
134
|
-
right:
|
|
173
|
+
right: 11px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.lm-switch[position="right"] > input:checked {
|
|
177
|
+
left: initial;
|
|
178
|
+
right: -5px;
|
|
135
179
|
}
|
|
136
180
|
|
|
137
181
|
.lm-switch[position="right"] > span::before {
|