50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
import baseComponent from '../helpers/baseComponent'
|
|
|
|
baseComponent({
|
|
externalClasses: ['wux-class'],
|
|
properties: {
|
|
type: {
|
|
type: String,
|
|
value: '',
|
|
},
|
|
size: {
|
|
type: [String, Number],
|
|
value: 32,
|
|
observer: 'updated',
|
|
},
|
|
color: {
|
|
type: String,
|
|
value: '',
|
|
},
|
|
hidden: {
|
|
type: Boolean,
|
|
value: false,
|
|
},
|
|
},
|
|
data: {
|
|
fontSize: '',
|
|
},
|
|
methods: {
|
|
updated(size = this.data.size) {
|
|
let fontSize = size
|
|
|
|
if (typeof size === 'number') {
|
|
fontSize = `${size}px`
|
|
} else if (typeof size === 'string') {
|
|
if (!isNaN(Number(size))) {
|
|
fontSize = `${size}px`
|
|
}
|
|
}
|
|
|
|
if (this.data.fontSize !== fontSize) {
|
|
this.setData({
|
|
fontSize,
|
|
})
|
|
}
|
|
},
|
|
},
|
|
attached() {
|
|
this.updated()
|
|
},
|
|
})
|