Skip to content

Commit c70a69e

Browse files
committed
feat(QSeparator): "spaced" prop now supports predefined size (xs/sm/md/lg/xl) or a size in CSS units, including unit name quasarframework#7209
1 parent cd9e74a commit c70a69e

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

ui/src/components/separator/QSeparator.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ const insetMap = {
99
'item-thumbnail': 'item-thumbnail-inset'
1010
}
1111

12+
export const margins = {
13+
xs: 2,
14+
sm: 4,
15+
md: 8,
16+
lg: 16,
17+
xl: 24
18+
}
19+
1220
export default Vue.extend({
1321
name: 'QSeparator',
1422

1523
mixins: [ DarkMixin, ListenersMixin ],
1624

1725
props: {
18-
spaced: Boolean,
26+
spaced: [ Boolean, String ],
1927
inset: [ Boolean, String ],
2028
vertical: Boolean,
2129
color: String,
@@ -41,17 +49,30 @@ export default Vue.extend({
4149

4250
classes () {
4351
return `q-separator${this.classPrefix}${this.insetClass}` +
44-
(this.spaced === true ? `${this.classPrefix}-spaced` : '') +
4552
(this.color !== void 0 ? ` bg-${this.color}` : '') +
4653
(this.isDark === true ? ' q-separator--dark' : '')
4754
},
4855

4956
style () {
57+
const style = {}
58+
5059
if (this.size !== void 0) {
51-
return {
52-
[ this.vertical === true ? 'width' : 'height' ]: this.size
53-
}
60+
style[ this.vertical === true ? 'width' : 'height' ] = this.size
61+
}
62+
63+
if (this.spaced !== false) {
64+
const size = this.spaced === true
65+
? `${margins.md}px`
66+
: this.spaced in margins ? `${margins[this.spaced]}px` : this.spaced
67+
68+
const props = this.vertical === true
69+
? [ 'Left', 'Right' ]
70+
: [ 'Top', 'Bottom' ]
71+
72+
style[`margin${props[0]}`] = style[`margin${props[1]}`] = size
5473
}
74+
75+
return style
5576
},
5677

5778
attrs () {

ui/src/components/separator/QSeparator.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
},
1414

1515
"spaced": {
16-
"type": "Boolean",
17-
"desc": "If set to true, the top and bottom margins will be set to 8px",
16+
"type": [ "Boolean", "String" ],
17+
"desc": "If set to true, the corresponding direction margins will be set to 8px; It can also be set to a size in CSS units, including unit name, or one of the xs|sm|md|lg|xl predefined sizes",
18+
"default": "md",
19+
"examples": [
20+
"12px", "sm", "md"
21+
],
1822
"category": "content"
1923
},
2024

ui/src/components/separator/QSeparator.sass

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
height: 1px
1313
width: 100%
1414

15-
&-spaced
16-
margin-top: 8px
17-
margin-bottom: 8px
1815
&-inset
1916
margin-left: 16px
2017
margin-right: 16px
@@ -33,9 +30,6 @@
3330
height: inherit
3431
align-self: stretch
3532

36-
&-spaced
37-
margin-left: 8px
38-
margin-right: 8px
3933
&-inset
4034
margin-top: 8px
4135
margin-bottom: 8px

ui/src/components/separator/QSeparator.styl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
height: 1px
1313
width: 100%
1414

15-
&-spaced
16-
margin-top: 8px
17-
margin-bottom: 8px
1815
&-inset
1916
margin-left: 16px
2017
margin-right: 16px
@@ -33,9 +30,6 @@
3330
height: inherit
3431
align-self: stretch
3532

36-
&-spaced
37-
margin-left: 8px
38-
margin-right: 8px
3933
&-inset
4034
margin-top: 8px
4135
margin-bottom: 8px

0 commit comments

Comments
 (0)