Skip to content

Commit b56a838

Browse files
committed
feat(QIcon): Enhance format for svg form (can add multiple paths, each with its own style and svg transform) quasarframework#6976
New format: path@@style_attr@@transform_attr&&path@@style_attr@@transform_attr&&...|viewBox - A path is defined by: path@@style_attr@@transform_attr * style_attr is optional * transform_attr is optional * if no style_attr but you have a transform, still use the separator between path and style_attr (path@@@@transform_attr) - Supports multiple paths, separated by "&&" - viewBox is optional - Backward compatibility with the old format (path|viewBox)
1 parent 4a70c55 commit b56a838

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ui/src/components/icon/QIcon.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,22 @@ export default Vue.extend({
6161
}
6262

6363
if (icon.startsWith('M') === true) {
64-
const cfg = icon.split('|')
64+
const [ def, viewBox ] = icon.split('|')
65+
6566
return {
6667
svg: true,
6768
cls: this.classes,
68-
path: cfg[0],
69-
viewBox: cfg[1] !== void 0 ? cfg[1] : '0 0 24 24'
69+
nodes: def.split('&&').map(path => {
70+
const [ d, style, transform ] = path.split('@@')
71+
return this.$createElement('path', {
72+
attrs: {
73+
d,
74+
transform
75+
},
76+
style
77+
})
78+
}),
79+
viewBox: viewBox !== void 0 ? viewBox : '0 0 24 24'
7080
}
7181
}
7282

@@ -154,11 +164,7 @@ export default Vue.extend({
154164
data.attrs.focusable = 'false' /* needed for IE11 */
155165
data.attrs.viewBox = this.type.viewBox
156166

157-
return h('svg', data, mergeSlot([
158-
h('path', {
159-
attrs: { d: this.type.path }
160-
})
161-
], this, 'default'))
167+
return h('svg', data, mergeSlot(this.type.nodes, this, 'default'))
162168
}
163169

164170
return h(this.tag, data, mergeSlot([

0 commit comments

Comments
 (0)