theme tab: don't crash out on non-colours (#41)
ci/woodpecker/push/woodpecker Pipeline was successful Details

Reviewed-on: AkkomaGang/pleroma-fe#41
This commit is contained in:
floatingghost 2022-07-17 13:13:51 +00:00
parent a256931596
commit 2977edc04d
2 changed files with 6 additions and 2 deletions

View File

@ -28,7 +28,7 @@
flex: 0 0 2em;
min-width: 2em;
align-self: center;
height: 100%;
height: 2em;
}
}
.computedIndicator,

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