theme tab: don't crash out on non-colours (#41)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: AkkomaGang/pleroma-fe#41
This commit is contained in:
parent
a256931596
commit
2977edc04d
2 changed files with 6 additions and 2 deletions
|
@ -28,7 +28,7 @@
|
||||||
flex: 0 0 2em;
|
flex: 0 0 2em;
|
||||||
min-width: 2em;
|
min-width: 2em;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
height: 100%;
|
height: 2em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.computedIndicator,
|
.computedIndicator,
|
||||||
|
|
|
@ -51,8 +51,11 @@ const v1OnlyNames = [
|
||||||
'cOrange'
|
'cOrange'
|
||||||
].map(_ => _ + 'ColorLocal')
|
].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) => {
|
const colorConvert = (color) => {
|
||||||
if (color.startsWith('--') || color === 'transparent') {
|
if (color.startsWith('--') || color === 'transparent' || !isColor(color)) {
|
||||||
return color
|
return color
|
||||||
} else {
|
} else {
|
||||||
return hex2rgb(color)
|
return hex2rgb(color)
|
||||||
|
@ -246,6 +249,7 @@ export default {
|
||||||
const colors = this.previewTheme.colors
|
const colors = this.previewTheme.colors
|
||||||
const opacity = this.previewTheme.opacity
|
const opacity = this.previewTheme.opacity
|
||||||
if (!colors.bg) return {}
|
if (!colors.bg) return {}
|
||||||
|
if (!isColor(colors.bg)) return {}
|
||||||
const hints = (ratio) => ({
|
const hints = (ratio) => ({
|
||||||
text: ratio.toPrecision(3) + ':1',
|
text: ratio.toPrecision(3) + ':1',
|
||||||
// AA level, AAA level
|
// AA level, AAA level
|
||||||
|
|
Loading…
Reference in a new issue