mirror of
https://github.com/coreui/coreui-icons.git
synced 2025-08-20 23:41:21 +02:00
feat: add case converter, styles, change prop names in CIcon component.
This commit is contained in:
@@ -1,21 +1,41 @@
|
|||||||
<template>
|
<template>
|
||||||
<svg width="64" height="64" v-html="computedCode"></svg>
|
<svg
|
||||||
|
viewBox="0 0 64 64"
|
||||||
|
:style="style"
|
||||||
|
v-html="computedCode"
|
||||||
|
></svg>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'CIcon',
|
name: 'CIcon',
|
||||||
|
//This object contains icons added before component registration
|
||||||
icons: {},
|
icons: {},
|
||||||
props: {
|
props: {
|
||||||
iconCode: String,
|
name: String,
|
||||||
icon: String
|
content: String,
|
||||||
},
|
fill: String,
|
||||||
mounted () {
|
background: String
|
||||||
console.log(this.$options.icons)
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
iconName () {
|
||||||
|
return this.name.includes('-') ? this.toCamelCase(this.name) : this.name
|
||||||
|
},
|
||||||
computedCode () {
|
computedCode () {
|
||||||
return this.iconCode || this.$options.icons[this.icon]
|
return this.content || this.$options.icons[this.iconName]
|
||||||
|
},
|
||||||
|
style () {
|
||||||
|
return {
|
||||||
|
fill: this.fill || 'currentColor',
|
||||||
|
background: this.background
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toCamelCase (str) {
|
||||||
|
return str.replace(/([-_][a-z])/ig, ($1) => {
|
||||||
|
return $1.toUpperCase().replace('-', '')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user