don't try converting non-colours
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful

This commit is contained in:
FloatingGhost 2022-07-17 14:08:23 +01:00
parent b38b54eddf
commit fc18981b77

View file

@ -51,8 +51,11 @@ const v1OnlyNames = [
'cOrange'
].map(_ => _ + 'ColorLocal')
// if color doesn't match regex, it's not a color
const isColor = (color) => /^#[0-9a-f]{6}$/i.test(color)
const colorConvert = (color) => {
if (color.startsWith('--') || color === 'transparent') {
if (color.startsWith('--') || color === 'transparent' || !isColor(color)) {
return color
} else {
return hex2rgb(color)
@ -246,6 +249,7 @@ export default {
const colors = this.previewTheme.colors
const opacity = this.previewTheme.opacity
if (!colors.bg) return {}
if (!isColor(colors.bg)) return {}
const hints = (ratio) => ({
text: ratio.toPrecision(3) + ':1',
// AA level, AAA level