mirror of
https://github.com/coreui/coreui-icons.git
synced 2025-08-22 00:05:22 +02:00
feat: add automatic size setting
This commit is contained in:
@@ -15,7 +15,19 @@ export default {
|
|||||||
name: String,
|
name: String,
|
||||||
content: String,
|
content: String,
|
||||||
fill: String,
|
fill: String,
|
||||||
background: String
|
background: String,
|
||||||
|
// height: String,
|
||||||
|
// width: String
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
lineHeight: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.lineHeight = window.getComputedStyle(this.$el, null).getPropertyValue('line-height')
|
||||||
|
})
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
iconName () {
|
iconName () {
|
||||||
@@ -24,12 +36,17 @@ export default {
|
|||||||
computedCode () {
|
computedCode () {
|
||||||
return this.content || this.$options.icons[this.iconName]
|
return this.content || this.$options.icons[this.iconName]
|
||||||
},
|
},
|
||||||
|
autoDimensions () {
|
||||||
|
const noDimensions = !this.$attrs.height && !this.$attrs.width
|
||||||
|
return noDimensions ? { height: this.lineHeight } : {}
|
||||||
|
},
|
||||||
style () {
|
style () {
|
||||||
return {
|
return Object.assign({}, this.autoDimensions, {
|
||||||
fill: this.fill || 'currentColor',
|
fill: this.fill || 'currentColor',
|
||||||
background: this.background
|
background: this.background
|
||||||
}
|
})
|
||||||
}
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toCamelCase (str) {
|
toCamelCase (str) {
|
||||||
|
Reference in New Issue
Block a user