wave-ui 2.34.0 → 2.35.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,6 +1,6 @@
1
1
  {
2
2
  "name": "wave-ui",
3
- "version": "2.34.0",
3
+ "version": "2.35.0",
4
4
  "description": "An emerging UI framework for Vue.js (2 & 3) with only the bright side. :sunny:",
5
5
  "author": "Antoni Andre <antoniandre.web@gmail.com>",
6
6
  "main": "./dist/wave-ui.umd.js",
@@ -1,12 +1,12 @@
1
1
  <template lang="pug">
2
2
  component.w-icon(
3
3
  :is="tag || 'i'"
4
- :class="classes"
5
4
  v-on="$attrs"
5
+ :class="classes"
6
6
  role="icon"
7
7
  aria-hidden="true"
8
- :style="styles")
9
- template(v-if="ligature") {{ ligature.icon }}
8
+ :style="readIcon() /* Always reacting to slot change when called from template. */ && styles")
9
+ template(v-if="hasLigature") {{ icon }}
10
10
  </template>
11
11
 
12
12
  <script>
@@ -41,15 +41,13 @@ export default {
41
41
  emits: [],
42
42
 
43
43
  data: () => ({
44
- icon: ''
44
+ icon: '',
45
+ fontName: ''
45
46
  }),
46
47
 
47
48
  computed: {
48
- ligature () {
49
- if (!config.iconsLigature) return false
50
-
51
- const [fontName, icon] = this.icon.split(' ')
52
- return fontName === config.iconsLigature && { fontName, icon }
49
+ hasLigature () {
50
+ return config.iconsLigature === this.fontName
53
51
  },
54
52
  forcedSize () {
55
53
  return this.size && (!isNaN(this.size) ? `${this.size}px` : this.size)
@@ -66,7 +64,8 @@ export default {
66
64
  },
67
65
  classes () {
68
66
  return {
69
- [this.icon]: true,
67
+ [this.fontName]: true,
68
+ [!this.hasLigature && this.icon]: !this.hasLigature && this.icon,
70
69
  [this.color]: this.color,
71
70
  [`${this.bgColor}--bg`]: this.bgColor,
72
71
  [`size--${this.presetSize}`]: this.presetSize && !this.forcedSize,
@@ -80,8 +79,7 @@ export default {
80
79
  'w-icon--rotate-90': this.rotate90a,
81
80
  'w-icon--rotate-135': this.rotate135a,
82
81
  'w-icon--flip-x': this.flipX,
83
- 'w-icon--flip-y': this.flipY,
84
- [this.ligature && this.ligature.fontName]: this.ligature
82
+ 'w-icon--flip-y': this.flipY
85
83
  }
86
84
  },
87
85
  styles () {
@@ -89,14 +87,13 @@ export default {
89
87
  }
90
88
  },
91
89
 
92
- created () {
93
- this.icon = this.$slots.default && this.$slots.default()[0].children
94
- },
95
-
96
- // Using the slot content directly in the classes computed is not always reacting to changes.
97
- // https://github.com/antoniandre/wave-ui/issues/81
98
- updated () {
99
- this.icon = this.$slots.default && this.$slots.default()[0].children
90
+ methods: {
91
+ readIcon () {
92
+ const { default: slot } = this.$slots
93
+ const [fontName = '', icon = ''] = typeof slot === 'function' && slot()[0].children.trim().split(' ') || []
94
+ this.fontName = fontName
95
+ this.icon = icon
96
+ }
100
97
  }
101
98
  }
102
99
  </script>
@@ -110,6 +107,7 @@ export default {
110
107
  justify-content: center;
111
108
  vertical-align: middle;
112
109
  user-select: none;
110
+ speak: never;
113
111
  line-height: 1;
114
112
  font-size: 1.2em;
115
113
  width: 1em;
@@ -29,6 +29,10 @@ component(
29
29
  @click="$refs.input.focus();$refs.input.click()"
30
30
  v-on="$attrs"
31
31
  :class="inputClasses")
32
+ .w-switch__track(v-if="$slots.track")
33
+ slot(name="track")
34
+ .w-switch__thumb(v-if="$slots.thumb")
35
+ slot(name="thumb")
32
36
  template(v-if="hasLabel && !labelOnLeft")
33
37
  label.w-switch__label.w-form-el-shakable(v-if="$slots.default" :for="`w-switch--${_.uid}`")
34
38
  slot
@@ -77,6 +81,8 @@ export default {
77
81
  'w-switch--disabled': this.isDisabled,
78
82
  'w-switch--readonly': this.isReadonly,
79
83
  'w-switch--ripple': this.ripple.start,
84
+ 'w-switch--custom-thumb': this.$slots.thumb,
85
+ 'w-switch--custom-track': this.$slots.track,
80
86
  'w-switch--rippled': this.ripple.end
81
87
  }
82
88
  },
@@ -186,8 +192,18 @@ $disabled-color: #ddd;
186
192
  }
187
193
  }
188
194
 
189
- // Thumb.
190
- &__input:after {
195
+ // Track slot, if any.
196
+ &__track {
197
+ position: absolute;
198
+ left: 100%;
199
+ padding: 0 4px;
200
+ transform: translateX(-100%);
201
+ @include default-transition;
202
+ }
203
+ .w-switch--on &__track {left: 0;transform: translateX(0);}
204
+
205
+ // Thumb: show either the thumb slot if any, or :after otherwise.
206
+ &__thumb, &__input:after {
191
207
  content: '';
192
208
  position: absolute;
193
209
  left: 0;
@@ -196,22 +212,28 @@ $disabled-color: #ddd;
196
212
  height: $small-form-el-size;
197
213
  background-color: #fff;
198
214
  border-radius: 100%;
215
+ text-align: center;
199
216
  @include default-transition;
200
217
 
201
218
  .w-switch[class^="bdrs"] &, .w-switch[class*=" bdrs"] & {border-radius: inherit;}
202
219
 
203
- :checked ~ & {transform: translateX(100%);}
220
+ .w-switch--on & {left: 100%;transform: translateX(-100%);}
204
221
 
205
222
  .w-switch--thin & {
206
223
  top: - round(0.15 * $small-form-el-size);
207
224
  transform: scale(1.1);
208
225
  box-shadow: $box-shadow;
209
226
  }
210
- .w-switch--thin :checked ~ & {
211
- transform: translateX(100%) scale(1.1);
227
+ .w-switch--thin.w-switch--on & {
228
+ transform: translateX(-100%) scale(1.1);
212
229
  background-color: currentColor;
213
230
  }
214
231
  }
232
+ &--custom-thumb &__input:after {display: none;}
233
+ &__thumb > * {
234
+ width: inherit;
235
+ height: inherit;
236
+ }
215
237
 
216
238
  // The focus outline & ripple on switch activation.
217
239
  &__input:before {
@@ -223,11 +245,12 @@ $disabled-color: #ddd;
223
245
  height: $small-form-el-size;
224
246
  background-color: currentColor;
225
247
  border-radius: 100%;
226
- transform: translateX(100%) scale(0);
227
248
  opacity: 0;
228
249
  pointer-events: none;
229
250
  transition: 0.25s ease-in-out;
230
251
 
252
+ :checked ~ & {transform: translateX(-100%) scale(0);left: 100%;}
253
+
231
254
  .w-switch[class^="bdrs"] &, .w-switch[class*=" bdrs"] & {border-radius: inherit;}
232
255
  .w-switch--thin & {top: - round(0.15 * $small-form-el-size);}
233
256
  }
@@ -242,14 +265,14 @@ $disabled-color: #ddd;
242
265
  opacity: 0.2;
243
266
  }
244
267
  :focus:checked ~ &__input:before {
245
- transform: translateX(100%) scale(1.8);
268
+ transform: translateX(-100%) scale(1.8);
246
269
  }
247
270
 
248
271
  // After ripple reset to default state, then remove the class via js and the
249
272
  // `:focus ~ &__input:before` will re-transition to normal focused outline.
250
273
  &--rippled &__input:before {
251
274
  transition: none;
252
- transform: translateX(100%) scale(0);
275
+ transform: translateX(-100%) scale(0);
253
276
  opacity: 0;
254
277
  }
255
278
 
@@ -264,7 +287,7 @@ $disabled-color: #ddd;
264
287
  }
265
288
 
266
289
  @keyframes w-switch-ripple {
267
- 0% {opacity: 0.8;transform: translateX(100%) scale(1);background-color: currentColor;} // Start with visible ripple.
268
- 100% {opacity: 0;transform: translateX(100%) scale(2.8);} // Propagate ripple to max radius and fade out.
290
+ 0% {opacity: 0.8;transform: translateX(-100%) scale(1);background-color: currentColor;} // Start with visible ripple.
291
+ 100% {opacity: 0;transform: translateX(-100%) scale(2.8);} // Propagate ripple to max radius and fade out.
269
292
  }
270
293
  </style>