Skip to content

Commit

Permalink
feat(QIcon): True SVG icon support #6027
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Jan 8, 2020
1 parent 8db463f commit 3edefde
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
29 changes: 27 additions & 2 deletions ui/src/components/icon/QIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export default Vue.extend({
}
}

if (icon.startsWith('M') === true) {
const [ path, viewBox ] = icon.split('|')
return {
svg: true,
cls: commonCls + ' q-svg-icon',
path,
viewBox
}
}

if (icon.startsWith('img:') === true) {
return {
img: true,
Expand Down Expand Up @@ -119,11 +129,26 @@ export default Vue.extend({
})
}

return h('i', {
const data = {
staticClass: this.type.cls,
style: this.sizeStyle,
on: this.$listeners,
attrs: { 'aria-hidden': true }
}, mergeSlot([ this.type.content ], this, 'default'))
}

if (this.type.svg === true) {
data.attrs.focusable = 'false' /* needed for IE11 */
data.attrs.viewBox = this.type.viewBox

return h('svg', data, mergeSlot([
h('path', {
attrs: { d: this.type.path }
})
], this, 'default'))
}

return h('i', data, mergeSlot([
this.type.content
], this, 'default'))
}
})
5 changes: 5 additions & 0 deletions ui/src/css/critical.sass
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@
align-items: center
justify-content: center
vertical-align: middle

.q-svg-icon
vertical-align: text-bottom
path
fill: currentColor
5 changes: 5 additions & 0 deletions ui/src/css/critical.styl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@
align-items: center
justify-content: center
vertical-align: middle

.q-svg-icon
vertical-align: text-bottom
path
fill: currentColor

0 comments on commit 3edefde

Please sign in to comment.