Fix usercard from breaking with certain colors, clean up code structure a bit.

This commit is contained in:
shpuld 2017-11-20 22:45:09 +02:00
parent 8020363680
commit f6b2f6eaee
5 changed files with 103 additions and 90 deletions

View file

@ -1,3 +1,5 @@
import { rgbstr2hex } from '../../services/color_convert/color_convert.js'
export default {
data () {
return {
@ -19,13 +21,6 @@ export default {
})
},
mounted () {
const rgbstr2hex = (rgb) => {
if (rgb[0] === '#') {
return rgb
}
rgb = rgb.match(/\d+/g)
return `#${((Number(rgb[0]) << 16) + (Number(rgb[1]) << 8) + Number(rgb[2])).toString(16)}`
}
this.bgColorLocal = rgbstr2hex(this.$store.state.config.colors['base00'])
this.fgColorLocal = rgbstr2hex(this.$store.state.config.colors['base02'])
this.textColorLocal = rgbstr2hex(this.$store.state.config.colors['base05'])