Skip to content

Commit c537baa

Browse files
committed
fix(QItem/QCollapsible): fixes regarding some props
1 parent c71f866 commit c537baa

File tree

6 files changed

+67
-86
lines changed

6 files changed

+67
-86
lines changed

src/components/collapsible/QCollapsible.js

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import { QItem, QItemSide, QItemTile, QItemWrapper } from '../list'
22
import { QSlideTransition } from '../slide-transition'
33
import Ripple from '../../directives/ripple'
44
import ModelToggleMixin from '../../mixins/model-toggle'
5+
import ItemMixin from '../../mixins/item'
6+
import extend from '../../utils/extend'
57

68
const eventName = 'q:collapsible:close'
79

810
export default {
911
name: 'q-collapsible',
10-
mixins: [ModelToggleMixin],
12+
mixins: [ModelToggleMixin, ItemMixin],
1113
modelToggle: {
1214
history: false
1315
},
@@ -20,57 +22,14 @@ export default {
2022
indent: Boolean,
2123
group: String,
2224
iconToggle: Boolean,
23-
separator: Boolean,
24-
insetSeparator: Boolean,
2525
noRipple: Boolean,
2626
collapseIcon: String,
2727
opened: Boolean,
2828

29-
dense: Boolean,
30-
sparse: Boolean,
31-
multiline: Boolean,
32-
33-
icon: String,
34-
rightIcon: String,
35-
image: String,
36-
rightImage: String,
37-
avatar: String,
38-
rightAvatar: String,
39-
letter: String,
40-
rightLetter: String,
41-
label: String,
42-
sublabel: String,
43-
labelLines: [String, Number],
44-
sublabelLines: [String, Number],
45-
4629
headerStyle: [Array, String, Object],
4730
headerClass: [Array, String, Object]
4831
},
4932
computed: {
50-
cfg () {
51-
return {
52-
link: !this.iconToggle,
53-
54-
dark: this.dark,
55-
dense: this.dense,
56-
sparse: this.sparse,
57-
multiline: this.multiline,
58-
59-
icon: this.icon,
60-
rightIcon: this.rightIcon,
61-
image: this.image,
62-
rightImage: this.rightImage,
63-
avatar: this.avatar,
64-
rightAvatar: this.rightAvatar,
65-
letter: this.letter,
66-
rightLetter: this.rightLetter,
67-
68-
label: this.label,
69-
sublabel: this.sublabel,
70-
labelLines: this.labelLines,
71-
sublabelLines: this.sublabelLines
72-
}
73-
},
7433
hasRipple () {
7534
return __THEME__ === 'mat' && !this.noRipple && !this.disable
7635
},
@@ -82,6 +41,11 @@ export default {
8241
'q-item-inset-separator': this.insetSeparator,
8342
disabled: this.disable
8443
}
44+
},
45+
wrapperCfg () {
46+
return extend({}, this.$props, {
47+
link: !this.iconToggle
48+
})
8549
}
8650
},
8751
watch: {
@@ -130,7 +94,7 @@ export default {
13094
__getItemProps (wrapper) {
13195
return {
13296
props: wrapper
133-
? { cfg: this.cfg }
97+
? { cfg: this.wrapperCfg }
13498
: { link: !this.iconToggle },
13599
style: this.headerStyle,
136100
'class': this.headerClass,

src/components/list/QItem.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ItemMixin, itemClasses } from './list-utils'
1+
import ItemMixin from '../../mixins/item'
22
import { RouterLinkMixin } from '../../utils/router-link'
33

44
export default {
@@ -13,7 +13,7 @@ export default {
1313
},
1414
computed: {
1515
classes () {
16-
const cls = itemClasses(this.$props)
16+
const cls = this.itemClasses
1717
return this.to !== void 0
1818
? cls
1919
: [{active: this.active}, cls]

src/components/list/QItemMain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { textStyle } from './list-utils'
1+
import { textStyle } from '../../mixins/item'
22

33
function text (h, name, val, n) {
44
n = parseInt(n, 10)

src/components/list/QItemTile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { QIcon } from '../icon'
2-
import { textStyle } from './list-utils'
2+
import { textStyle } from '../../mixins/item'
33

44
export default {
55
name: 'q-item-tile',

src/components/list/list-utils.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/mixins/item.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
export function textStyle (n) {
2+
return n === void 0 || n < 2
3+
? {}
4+
: {overflow: 'hidden', display: '-webkit-box', '-webkit-box-orient': 'vertical', '-webkit-line-clamp': n}
5+
}
6+
7+
export default {
8+
props: {
9+
dark: Boolean,
10+
11+
link: Boolean,
12+
dense: Boolean,
13+
sparse: Boolean,
14+
separator: Boolean,
15+
insetSeparator: Boolean,
16+
multiline: Boolean,
17+
highlight: Boolean,
18+
19+
icon: String,
20+
rightIcon: String,
21+
image: String,
22+
rightImage: String,
23+
avatar: String,
24+
rightAvatar: String,
25+
letter: String,
26+
rightLetter: String,
27+
label: String,
28+
sublabel: String,
29+
labelLines: [String, Number],
30+
sublabelLines: [String, Number],
31+
32+
tag: {
33+
type: String,
34+
default: 'div'
35+
}
36+
},
37+
computed: {
38+
itemClasses () {
39+
return {
40+
'q-item': true,
41+
'q-item-division': true,
42+
'relative-position': true,
43+
'q-item-dark': this.dark,
44+
'q-item-dense': this.dense,
45+
'q-item-sparse': this.sparse,
46+
'q-item-separator': this.separator,
47+
'q-item-inset-separator': this.insetSeparator,
48+
'q-item-multiline': this.multiline,
49+
'q-item-highlight': this.highlight,
50+
'q-item-link': this.to || this.link
51+
}
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)