Skip to content

Commit

Permalink
fix: give 'size' prop precedens over height and width attributes
Browse files Browse the repository at this point in the history
- add 'custom' as a valid value of 'size' prop
  • Loading branch information
woothu committed Feb 4, 2020
1 parent aba556b commit 01a354e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/CIconRaw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
size: {
type: String,
validator: size => [
'custom-size', 'sm', 'lg', 'xl',
'custom', 'custom-size', 'sm', 'lg', 'xl',
'2xl', '3xl', '4xl', '5xl', '6xl', '7xl', '8xl', '9xl'
].includes(size)
},
Expand Down Expand Up @@ -56,11 +56,12 @@ export default {
return this.$attrs.viewBox || `0 0 ${this.scale}`
},
computedSize () {
return this.$attrs.width || this.$attrs.height ? 'custom-size' : this.size
const addCustom = !this.size && (this.$attrs.width || this.$attrs.height)
return this.size === 'custom' || addCustom ? 'custom-size' : this.size
},
computedClasses () {
return this.customClasses ||
['c-icon', { [`c-icon-${this.computedSize}`]: this.computedSize }]
const size = this.computedSize
return this.customClasses || ['c-icon', { [`c-icon-${size}`]: size }]
}
},
methods: {
Expand Down

0 comments on commit 01a354e

Please sign in to comment.