wave-ui 2.31.4 → 2.32.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/wave-ui.cjs.js +1 -1
- package/dist/wave-ui.css +1 -1
- package/dist/wave-ui.es.js +129 -75
- package/dist/wave-ui.umd.js +1 -1
- package/package.json +1 -1
- package/src/wave-ui/components/index.js +1 -0
- package/src/wave-ui/components/w-flex.vue +3 -13
- package/src/wave-ui/components/w-grid.vue +82 -0
- package/src/wave-ui/scss/_layout.scss +5 -0
- package/src/wave-ui/utils/dynamic-css.js +14 -1
package/package.json
CHANGED
|
@@ -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
|
|
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
|
-
[`
|
|
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>
|
|
@@ -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
|
})
|