Skip to content

Commit 3edefde

Browse files
committed
feat(QIcon): True SVG icon support quasarframework#6027
1 parent 8db463f commit 3edefde

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

ui/src/components/icon/QIcon.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ export default Vue.extend({
4949
}
5050
}
5151

52+
if (icon.startsWith('M') === true) {
53+
const [ path, viewBox ] = icon.split('|')
54+
return {
55+
svg: true,
56+
cls: commonCls + ' q-svg-icon',
57+
path,
58+
viewBox
59+
}
60+
}
61+
5262
if (icon.startsWith('img:') === true) {
5363
return {
5464
img: true,
@@ -119,11 +129,26 @@ export default Vue.extend({
119129
})
120130
}
121131

122-
return h('i', {
132+
const data = {
123133
staticClass: this.type.cls,
124134
style: this.sizeStyle,
125135
on: this.$listeners,
126136
attrs: { 'aria-hidden': true }
127-
}, mergeSlot([ this.type.content ], this, 'default'))
137+
}
138+
139+
if (this.type.svg === true) {
140+
data.attrs.focusable = 'false' /* needed for IE11 */
141+
data.attrs.viewBox = this.type.viewBox
142+
143+
return h('svg', data, mergeSlot([
144+
h('path', {
145+
attrs: { d: this.type.path }
146+
})
147+
], this, 'default'))
148+
}
149+
150+
return h('i', data, mergeSlot([
151+
this.type.content
152+
], this, 'default'))
128153
}
129154
})

ui/src/css/critical.sass

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@
3232
align-items: center
3333
justify-content: center
3434
vertical-align: middle
35+
36+
.q-svg-icon
37+
vertical-align: text-bottom
38+
path
39+
fill: currentColor

ui/src/css/critical.styl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@
3232
align-items: center
3333
justify-content: center
3434
vertical-align: middle
35+
36+
.q-svg-icon
37+
vertical-align: text-bottom
38+
path
39+
fill: currentColor

0 commit comments

Comments
 (0)