fix lint, for shadows, it's now possible to refer css variables as colors

This commit is contained in:
Henry Jameson 2018-11-21 04:26:45 +03:00
parent 3d6547001e
commit 50562eb6b7
2 changed files with 19 additions and 2 deletions

View file

@ -1,5 +1,4 @@
import StillImage from '../still-image/still-image.vue' import StillImage from '../still-image/still-image.vue'
import { hex2rgb } from '../../services/color_convert/color_convert.js'
export default { export default {
props: [ 'user', 'switcher', 'selected', 'hideBio' ], props: [ 'user', 'switcher', 'selected', 'hideBio' ],

View file

@ -101,11 +101,29 @@ const getCssShadow = (input) => {
shad.blur, shad.blur,
shad.spread shad.spread
].map(_ => _ + 'px').concat([ ].map(_ => _ + 'px').concat([
rgb2rgba({...(hex2rgb(shad.color)), a: shad.alpha}), getCssColor(shad.color, shad.alpha),
shad.inset ? 'inset' : '' shad.inset ? 'inset' : ''
]).join(' ')).join(', ') ]).join(' ')).join(', ')
} }
const getCssColor = (input, a) => {
console.log(input)
let rgb = {}
if (typeof input === 'object') {
rgb = input
} else if (typeof input === 'string') {
if (input.startsWith('#')) {
rgb = hex2rgb(input)
} else if (input.startsWith('--')) {
return `var(${input})`
} else {
return input
}
}
console.log(rgb2rgba({ ...rgb, a }))
return rgb2rgba({ ...rgb, a })
}
const generateColors = (input) => { const generateColors = (input) => {
const colors = {} const colors = {}
const opacity = Object.assign({ const opacity = Object.assign({