Skip to content

Commit 9df7cbf

Browse files
pdanpdanrstoenescu
authored andcommitted
feat: QBtn justify (and alert actions justify start) (quasarframework#1395)
* feat: QBtn justify (and alert actions justify start) * Extract inner classes to mixin computed property
1 parent d8b5052 commit 9df7cbf

File tree

6 files changed

+29
-20
lines changed

6 files changed

+29
-20
lines changed

dev/components/components/alert.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<q-alert
5555
icon="map"
5656
color="primary"
57-
:actions="[ { label: 'Reply', icon: 'map', handler: () => {} }, { label: 'Reply', icon: 'map', handler: () => {} }, { label: 'Dismiss', handler: () => {} } ]"
57+
:actions="[ { label: 'Reply', icon: 'map', handler: () => {} }, { label: 'Reply long', icon: 'map', handler: () => {} }, { label: 'Dismiss', handler: () => {} } ]"
5858
>Learn how you can get there</q-alert>
5959
<br>
6060
<q-alert

dev/components/components/button.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,12 @@
271271

272272
<p class="caption">Full Width Buttons</p>
273273
<div class="group">
274-
<q-btn color="primary" class="full-width">Full-width Full-width Full-width Full-width Full-width Full-width Full-width Full-width Full-width</q-btn>
275-
<q-btn color="secondary" class="full-width">Full-width</q-btn>
276-
<q-btn color="primary" icon="alarm" class="full-width">Full-width</q-btn>
277-
<q-btn color="secondary" icon-right="alarm" class="full-width">Full-width</q-btn>
278-
<q-btn color="secondary" icon="lock" icon-right="alarm" class="full-width">Full-width</q-btn>
274+
<q-btn color="primary" class="full-width" label="Full-width Full-width Full-width Full-width Full-width Full-width Full-width Full-width Full-width" />
275+
<q-btn color="secondary" class="full-width" label="Full-width" justify="start" />
276+
<q-btn color="primary" icon="alarm" class="full-width" label="Full-width" justify="end" />
277+
<q-btn color="secondary" icon-right="alarm" class="full-width" label="Full-width" justify="center" />
278+
<q-btn color="secondary" icon="lock" icon-right="alarm" class="full-width" label="Full-width" justify="between" />
279+
<q-btn color="secondary" icon="lock" icon-right="alarm" class="full-width" label="Full-width" justify="around" />
279280
</div>
280281

281282
<p class="caption">Multiline Buttons</p>
@@ -304,9 +305,9 @@
304305
<q-btn color="primary" icon-right="alarm" size="sm" class="full-width">Small Full-width<br/>Multiline<br/>Button</q-btn>
305306
<q-btn color="primary" icon-right="alarm" class="full-width">Normal Full-width<br/>Multiline<br/>Button</q-btn>
306307
<q-btn color="primary" icon-right="alarm" size="lg" class="full-width">Big Full-width<br/>Multiline<br/>Button</q-btn>
307-
<q-btn color="primary" icon="lock" icon-right="alarm" size="sm" class="full-width">Small Full-width<br/>Multiline<br/>Button</q-btn>
308-
<q-btn color="primary" icon="lock" icon-right="alarm" class="full-width">Normal Full-width<br/>Multiline<br/>Button</q-btn>
309-
<q-btn color="primary" icon="lock" icon-right="alarm" size="lg" class="full-width">Big Full-width<br/>Multiline<br/>Button</q-btn>
308+
<q-btn color="primary" icon="lock" icon-right="alarm" justify="between" size="sm" class="full-width">Small Full-width<br/>Multiline<br/>Button</q-btn>
309+
<q-btn color="primary" icon="lock" icon-right="alarm" justify="between" class="full-width">Normal Full-width<br/>Multiline<br/>Button</q-btn>
310+
<q-btn color="primary" icon="lock" icon-right="alarm" justify="between" size="lg" class="full-width">Big Full-width<br/>Multiline<br/>Button</q-btn>
310311
</div>
311312

312313
<p class="caption">Wrap test</p>

src/components/alert/QAlert.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ export default {
6969
this.actions.map(action =>
7070
h('div', [
7171
h(QBtn, {
72+
staticClass: 'full-width',
7273
props: {
7374
flat: true,
7475
dense: true,
7576
icon: action.icon,
77+
justify: 'start',
7678
label: action.closeBtn === true
7779
? (typeof action.label === 'string' ? action.label : this.$q.i18n.label.close)
7880
: action.label

src/components/btn/QBtn.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,8 @@ export default {
130130
: null,
131131

132132
h('div', {
133-
staticClass: 'q-btn-inner row col flex-center',
134-
'class': {
135-
'no-wrap': this.noWrap,
136-
'text-no-wrap': this.noWrap
137-
}
133+
staticClass: 'q-btn-inner row col items-center',
134+
'class': this.innerClasses
138135
},
139136
this.loading
140137
? [ this.$slots.loading || h(QSpinner) ]

src/components/btn/QBtnToggle.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ export default {
5656
h('div', { staticClass: 'q-focus-helper' }),
5757

5858
h('div', {
59-
staticClass: 'q-btn-inner row col flex-center',
60-
'class': {
61-
'no-wrap': this.noWrap,
62-
'text-no-wrap': this.noWrap
63-
}
59+
staticClass: 'q-btn-inner row col items-center',
60+
'class': this.innerClasses
6461
}, [
6562
this.icon
6663
? h('q-icon', {

src/components/btn/btn-mixin.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ export default {
3131
textColor: String,
3232
glossy: Boolean,
3333
dense: Boolean,
34-
noRipple: Boolean
34+
noRipple: Boolean,
35+
justify: {
36+
type: String,
37+
default: 'center',
38+
validator: v => ['start', 'end', 'center', 'between', 'around'].includes(v)
39+
}
3540
},
3641
computed: {
3742
style () {
@@ -104,6 +109,13 @@ export default {
104109
})
105110

106111
return cls
112+
},
113+
innerClasses () {
114+
const classes = [`justify-${this.justify}`]
115+
if (this.noWrap) {
116+
classes.push('no-wrap', 'text-no-wrap')
117+
}
118+
return classes
107119
}
108120
},
109121
methods: {

0 commit comments

Comments
 (0)