1
0
mirror of https://github.com/coreui/coreui-icons.git synced 2025-08-20 07:21:24 +02:00

feat: add case converter, styles, change prop names in CIcon component.

This commit is contained in:
woothu
2019-06-04 15:42:34 +02:00
parent 271222cf45
commit 2e0994d97c

View File

@@ -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('-', '')
})
} }
} }
} }