@lemonadejs/switch 1.4.0 → 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 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, elements, s, oldValue, newValue) {
17
- if (oldValue !== newValue && typeof(onchange) === 'function') {
18
- onchange.call(self, self, self.value);
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,10 +1,40 @@
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;
6
- min-height: 40px;
7
- min-width: 40px;
33
+ min-width: 36px;
34
+ }
35
+
36
+ label.lm-switch {
37
+ display: inline-flex;
8
38
  }
9
39
 
10
40
  .lm-switch:before {
@@ -54,7 +84,7 @@
54
84
  border-radius: 7px;
55
85
  width: 36px;
56
86
  height: 14px;
57
- background-color: rgba(var(--lm-switch-front-color, 0,0,0), 0.38);
87
+ background-color: rgba(var(--lm-switch-front-color), 0.38);
58
88
  transition: background-color 0.2s, opacity 0.2s;
59
89
  }
60
90
 
@@ -65,14 +95,14 @@
65
95
  border-radius: 50%;
66
96
  width: 20px;
67
97
  height: 20px;
68
- background-color: rgb(var(---lm-switch-primary-color, 255,255,255));
98
+ background-color: rgb(var(--lm-switch-primary-color));
69
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);
70
100
  transition: background-color 0.2s, transform 0.2s;
71
101
  }
72
102
 
73
103
  .lm-switch > input:checked {
74
104
  left: 11px;
75
- background-color: var(--lm-main-color, #2196f3);
105
+ background-color: var(--lm-switch-main-color);
76
106
  }
77
107
 
78
108
  .lm-switch > input:not(:checked) {
@@ -81,11 +111,11 @@
81
111
  }
82
112
 
83
113
  .lm-switch > input:checked + span::before {
84
- background-color: var(--lm-main-color-alpha, #2196f388);
114
+ background-color: var(--lm-switch-main-color-alpha);
85
115
  }
86
116
 
87
117
  .lm-switch > input:checked + span::after {
88
- background-color: var(--lm-main-color, #2196f3);
118
+ background-color: var(--lm-switch-main-color);
89
119
  transform: translateX(16px);
90
120
  }
91
121
 
@@ -109,11 +139,11 @@
109
139
  }
110
140
 
111
141
  .lm-switch > input:active + span::before {
112
- background-color: var(--lm-main-color-alpha, #2196f388);
142
+ background-color: var(--lm-switch-main-color-alpha);
113
143
  }
114
144
 
115
145
  .lm-switch > input:checked:active + span::before {
116
- background-color: rgba(var(--lm-front-color, 0,0,0), 0.38);
146
+ background-color: rgba(var(--lm-switch-front-color), 0.38);
117
147
  }
118
148
 
119
149
  .lm-switch > input:disabled {
@@ -121,17 +151,17 @@
121
151
  }
122
152
 
123
153
  .lm-switch > input:disabled + span {
124
- color: rgb(var(--lm-front-color,0,0,0));
154
+ color: rgb(var(--lm-switch-front-color));
125
155
  opacity: 0.50;
126
156
  cursor: default;
127
157
  }
128
158
 
129
159
  .lm-switch > input:disabled + span::before {
130
- background-color: rgba(var(--lm-front-color,0,0,0), 0.38);
160
+ background-color: rgba(var(--lm-switch-front-color), 0.38);
131
161
  }
132
162
 
133
163
  .lm-switch > input:checked:disabled + span::before {
134
- background-color: var(--lm-main-color-alpha, #2196f388);
164
+ background-color: var(--lm-switch-main-color-alpha);
135
165
  }
136
166
 
137
167
  .lm-switch[position="right"] > span {
@@ -140,7 +170,12 @@
140
170
 
141
171
  .lm-switch[position="right"] > input {
142
172
  left: initial;
143
- right: -11px;
173
+ right: 11px;
174
+ }
175
+
176
+ .lm-switch[position="right"] > input:checked {
177
+ left: initial;
178
+ right: -5px;
144
179
  }
145
180
 
146
181
  .lm-switch[position="right"] > span::before {
package/package.json CHANGED
@@ -13,9 +13,9 @@
13
13
  "switch js"
14
14
  ],
15
15
  "dependencies": {
16
- "lemonadejs": "^4.3.3"
16
+ "lemonadejs": "^5.0.3"
17
17
  },
18
18
  "main": "dist/index.js",
19
19
  "types": "dist/index.d.ts",
20
- "version": "1.4.0"
20
+ "version": "5.0.0"
21
21
  }