wave-ui 2.31.3 → 2.32.1

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.31.3",
3
+ "version": "2.32.1",
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",
@@ -16,6 +16,7 @@ export { default as WDrawer } from './w-drawer.vue'
16
16
  export { default as WFlex } from './w-flex.vue'
17
17
  export { default as WForm } from './w-form.vue'
18
18
  export { default as WFormElement } from './w-form-element.vue'
19
+ export { default as WGrid } from './w-grid.vue'
19
20
  export { default as WIcon } from './w-icon.vue'
20
21
  export { default as WImage } from './w-image.vue'
21
22
  export { default as WInput } from './w-input.vue'
@@ -1,8 +1,5 @@
1
1
  <template lang="pug">
2
- component.w-flex-wrap(v-if="gap" :is="tag")
3
- .w-flex(:class="classes")
4
- slot
5
- component.w-flex(v-else :class="classes" :is="tag")
2
+ component.w-flex(:class="classes" :is="tag")
6
3
  slot
7
4
  </template>
8
5
 
@@ -28,7 +25,7 @@ export default {
28
25
  justifySpaceAround: { type: Boolean },
29
26
  justifySpaceEvenly: { type: Boolean },
30
27
  basisZero: { type: Boolean },
31
- gap: { type: Number, default: 0 }
28
+ gap: { type: [Number, String], default: 0 }
32
29
  },
33
30
 
34
31
  computed: {
@@ -51,7 +48,7 @@ export default {
51
48
  'justify-space-around': this.justifySpaceAround,
52
49
  'justify-space-evenly': this.justifySpaceEvenly,
53
50
  'basis-zero': this.basisZero,
54
- [`w-flex--gap${this.gap}`]: this.gap
51
+ [`gap${this.gap}`]: ~~this.gap
55
52
  }
56
53
  }
57
54
  }
@@ -68,12 +65,5 @@ export default {
68
65
  &.wrap {flex-wrap: wrap;}
69
66
  &.basis-zero > * {flex-basis: 0;flex-grow: 1;}
70
67
  &.basis-zero > .no-grow, &.basis-zero > .shrink {flex-grow: 0;}
71
-
72
- @for $i from 1 through 12 {
73
- // Divide by 2 as there are 2 elements having this space.
74
- $space: round($base-increment * divide($i, 2));
75
- &--gap#{$i} {margin: -$space;}
76
- &--gap#{$i} > * {margin: $space;}
77
- }
78
68
  }
79
69
  </style>
@@ -0,0 +1,82 @@
1
+ <template lang="pug">
2
+ component.w-grid(:class="classes" :is="tag")
3
+ slot
4
+ </template>
5
+
6
+ <script>
7
+ export default {
8
+ name: 'w-grid',
9
+ props: {
10
+ tag: { type: String, default: 'div' },
11
+ columns: { type: [Number, Object, String] },
12
+ gap: { type: [Number, Object, String], default: 0 }
13
+ },
14
+
15
+ computed: {
16
+ breakpointsColumns () {
17
+ let columns = { xs: 0, sm: 0, md: 0, lg: 0, xl: 0 }
18
+ switch (typeof this.columns) {
19
+ case 'object':
20
+ columns = Object.assign(columns, this.columns)
21
+ break
22
+ case 'number':
23
+ case 'string':
24
+ columns = Object.keys(columns).reduce((obj, breakpoint) => (obj[breakpoint] = ~~this.columns), {})
25
+ break
26
+ default:
27
+ break
28
+ }
29
+ return columns
30
+ },
31
+
32
+ breakpointsGap () {
33
+ let gap = { xs: 0, sm: 0, md: 0, lg: 0, xl: 0 }
34
+ switch (typeof this.gap) {
35
+ case 'object':
36
+ gap = Object.assign(gap, this.gap)
37
+ break
38
+ case 'number':
39
+ case 'string':
40
+ gap = Object.keys(gap).reduce((obj, breakpoint) => (obj[breakpoint] = ~~this.gap), {})
41
+ break
42
+ default:
43
+ break
44
+ }
45
+ return gap
46
+ },
47
+
48
+ classes () {
49
+ let breakpointsColumns = null
50
+ if (typeof this.columns === 'object') {
51
+ breakpointsColumns = Object.entries(this.breakpointsColumns).reduce((obj, [breakpoint, columns]) => {
52
+ obj[`${breakpoint}-columns${columns}`] = true
53
+ return obj
54
+ }, {})
55
+ }
56
+
57
+ let breakpointsGap = null
58
+ if (typeof this.gap === 'object') {
59
+ breakpointsGap = Object.entries(this.breakpointsGap).reduce((obj, [breakpoint, gap]) => {
60
+ obj[`${breakpoint}-gap${gap}`] = true
61
+ return obj
62
+ }, {})
63
+ }
64
+
65
+ return {
66
+ ...(breakpointsColumns || { [`columns${this.columns}`]: this.columns }),
67
+ ...(breakpointsGap || { [`gap${this.gap}`]: this.gap })
68
+ }
69
+ }
70
+ }
71
+ }
72
+ </script>
73
+
74
+ <style lang="scss">
75
+ .w-grid {
76
+ display: grid;
77
+
78
+ @for $i from 1 through 12 {
79
+ &.columns#{$i} {grid-template-columns: repeat($i, 1fr);}
80
+ }
81
+ }
82
+ </style>
@@ -48,7 +48,7 @@ export default {
48
48
  ligature () {
49
49
  if (!config.iconsLigature) return false
50
50
 
51
- const [fontName, icon] = this.$slots.default()[0].children
51
+ const [fontName, icon] = this.icon.split(' ')
52
52
  return fontName === config.iconsLigature && { fontName, icon }
53
53
  },
54
54
  forcedSize () {
@@ -66,7 +66,7 @@ export default {
66
66
  },
67
67
  classes () {
68
68
  return {
69
- [this.$slots.default()[0].children]: true,
69
+ [this.icon]: true,
70
70
  [this.color]: this.color,
71
71
  [`${this.bgColor}--bg`]: this.bgColor,
72
72
  [`size--${this.presetSize}`]: this.presetSize && !this.forcedSize,
@@ -87,6 +87,16 @@ export default {
87
87
  styles () {
88
88
  return this.forcedSize && `font-size: ${this.forcedSize}`
89
89
  }
90
+ },
91
+
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
100
  }
91
101
  }
92
102
  </script>
@@ -19,92 +19,6 @@ ul.w-list(:class="classes")
19
19
  :is="checklist ? 'w-checkbox' : (nav && !li.disabled && li.route ? (hasRouter ? 'router-link' : 'a') : 'div')"
20
20
  v-bind="liLabelProps(li, i, li._selected)")
21
21
 
22
- //- Vue 2.x only. Keep this comment to simplify the master branch merge into next.
23
- //-----------------------------------------------------
24
- //- When there are slots.
25
- //- template(v-if="$slots[`item.${i + 1}`] || $slots.item || $slots.default")
26
- //- Checklist items. (separated case cz it needs a @click.native, can't be in v-on)
27
- w-checkbox.w-list__item-label(
28
- v-if="checklist"
29
- v-bind="liLabelProps(li, i, li._selected)"
30
- v-on="liLabelEvents(li)"
31
- @click.native="onCheckboxWrapperClick")
32
- slot(
33
- v-if="$slots[`item.${i + 1}`] && $slots[`item.${i + 1}`]()"
34
- :name="`item.${i + 1}`"
35
- :item="cleanLi(li)"
36
- :index="i + 1"
37
- :selected="li._selected")
38
- slot(
39
- v-else-if="$slots.item"
40
- name="item"
41
- :item="cleanLi(li)"
42
- :index="i + 1"
43
- :selected="li._selected")
44
- slot(v-else :item="cleanLi(li)" :index="i + 1" :selected="li._selected") {{ li._label }}
45
- //- Router link list items. (separated case cz it needs a @click.native, can't be in v-on)
46
- router-link.w-list__item-label(
47
- v-else-if="nav && !li.disabled && li[itemRouteKey] && hasRouter"
48
- v-bind="liLabelProps(li, i, li._selected)"
49
- v-on="liLabelEvents(li)"
50
- @click.native="$emit('item-select', cleanLi(li))")
51
- slot(
52
- v-if="$slots[`item.${i + 1}`] && $slots[`item.${i + 1}`]()"
53
- :name="`item.${i + 1}`"
54
- :item="cleanLi(li)"
55
- :index="i + 1"
56
- :selected="li._selected")
57
- slot(
58
- v-else-if="$slots.item"
59
- name="item"
60
- :item="cleanLi(li)"
61
- :index="i + 1"
62
- :selected="li._selected")
63
- slot(v-else :item="cleanLi(li)" :index="i + 1" :selected="li._selected") {{ li._label }}
64
- //- Nav & simple list items.
65
- component.w-list__item-label(
66
- v-else
67
- :is="nav && !li.disabled && li[itemRouteKey] ? 'a' : 'div'"
68
- v-bind="liLabelProps(li, i, li._selected)"
69
- v-on="liLabelEvents(li)")
70
- slot(
71
- v-if="$slots[`item.${i + 1}`] && $slots[`item.${i + 1}`]()"
72
- :name="`item.${i + 1}`"
73
- :item="cleanLi(li)"
74
- :index="i + 1"
75
- :selected="li._selected")
76
- slot(
77
- v-else-if="$slots.item"
78
- name="item"
79
- :item="cleanLi(li)"
80
- :index="i + 1"
81
- :selected="li._selected")
82
- slot(v-else :item="cleanLi(li)" :index="i + 1" :selected="li._selected") {{ li._label }}
83
-
84
- //- When there are no slots.
85
- //- template(v-else)
86
- //- Checklist items. (separated case cz it needs a @click.native, can't be in v-on)
87
- w-checkbox.w-list__item-label(
88
- v-if="checklist"
89
- v-bind="liLabelProps(li, i, li._selected)"
90
- v-on="liLabelEvents(li)"
91
- @click.native="onCheckboxWrapperClick")
92
- //- Router link list items. (separated case cz it needs a @click.native, can't be in v-on)
93
- router-link.w-list__item-label(
94
- v-else-if="nav && !li.disabled && li[itemRouteKey] && hasRouter"
95
- v-bind="liLabelProps(li, i, li._selected)"
96
- v-on="liLabelEvents(li)"
97
- @click.native="$emit('item-select', cleanLi(li))"
98
- v-html="li._label")
99
- //- Nav & simple list items.
100
- component.w-list__item-label(
101
- v-else
102
- :is="nav && !li.disabled && li[itemRouteKey] ? 'a' : 'div'"
103
- v-bind="liLabelProps(li, i, li._selected)"
104
- v-on="liLabelEvents(li)"
105
- v-html="li._label")
106
- //-----------------------------------------------------
107
-
108
22
  //- Children lists.
109
23
  w-list(
110
24
  v-if="(li.children || []).length"
@@ -212,3 +212,8 @@
212
212
  // ----------------------------------------------
213
213
  }
214
214
  }
215
+
216
+ @for $i from 1 through 12 {
217
+ .w-flex.gap#{$i}, .w-grid.gap#{$i} {gap: round($base-increment * $i);}
218
+ }
219
+ .w-flex.gap0, .w-grid.gap0 {gap: 0;}
@@ -150,7 +150,7 @@ const generateBreakpointSpaces = () => {
150
150
 
151
151
  const genBreakpointLayoutClasses = () => {
152
152
  let styles = ''
153
- const { cssScope } = cssVars
153
+ const { cssScope, baseIncrement } = cssVars
154
154
  const layoutClasses = [
155
155
  'show{display:block}',
156
156
  'hide{display:none}',
@@ -185,6 +185,7 @@ const genBreakpointLayoutClasses = () => {
185
185
  'justify-space-around{justify-content:space-around}',
186
186
  'justify-space-evenly{justify-content:space-evenly}'
187
187
  ]
188
+ const array12 = Array(12).fill()
188
189
 
189
190
  // Define media queries for each breakpoint: xs, sm, md, lg, xl.
190
191
 
@@ -194,6 +195,10 @@ const genBreakpointLayoutClasses = () => {
194
195
  styles +=
195
196
  `@media(min-width:${min}px){` +
196
197
  layoutClasses.map(rule => `${cssScope} .${label}u-${rule}`).join('') +
198
+ // w-grid columns and gap.
199
+ array12.map((item, i) => `.w-grid.${label}u-columns${i + 1}{grid-template-columns:repeat(${i + 1},1fr);}`).join('') +
200
+ array12.map((item, i) => `.w-flex.${label}u-gap${i + 1},.w-grid.${label}u-gap${i + 1}{gap:${(i + 1) * baseIncrement}px;}`).join('') +
201
+ `.w-flex.${label}u-gap0,.w-flex.${label}u-gap0{gap:0}` +
197
202
  '}'
198
203
  }
199
204
  })
@@ -202,6 +207,10 @@ const genBreakpointLayoutClasses = () => {
202
207
  styles +=
203
208
  `@media (min-width:${min}px) and (max-width:${max}px){` +
204
209
  layoutClasses.map(rule => `${cssScope} .${label}-${rule}`).join('') +
210
+ // w-grid columns and gap.
211
+ array12.map((item, i) => `.w-grid.${label}-columns${i + 1}{grid-template-columns:repeat(${i + 1},1fr);}`).join('') +
212
+ array12.map((item, i) => `.w-flex.${label}-gap${i + 1},.w-grid.${label}-gap${i + 1}{gap:${(i + 1) * baseIncrement}px;}`).join('') +
213
+ `.w-flex.${label}-gap0,.w-flex.${label}-gap0{gap:0}` +
205
214
  '}'
206
215
  })
207
216
 
@@ -210,6 +219,10 @@ const genBreakpointLayoutClasses = () => {
210
219
  styles +=
211
220
  `@media (max-width:${max}px){` +
212
221
  layoutClasses.map(rule => `${cssScope} .${label}d-${rule}`).join('') +
222
+ // w-grid columns and gap.
223
+ array12.map((item, i) => `.w-grid.${label}d-columns${i + 1}{grid-template-columns:repeat(${i + 1},1fr);}`).join('') +
224
+ array12.map((item, i) => `.w-flex.${label}d-gap${i + 1},.w-grid.${label}d-gap${i + 1}{gap:${(i + 1) * baseIncrement}px;}`).join('') +
225
+ `.w-flex.${label}d-gap0,.w-flex.${label}d-gap0{gap:0}` +
213
226
  '}'
214
227
  }
215
228
  })