fix palette editor

This commit is contained in:
Henry Jameson 2026-07-06 19:43:20 +03:00
commit 72d5307fd9

View file

@ -16,7 +16,7 @@
@update:model-value="value => updatePalette(key, value)" @update:model-value="value => updatePalette(key, value)"
/> />
<ContrastRatio <ContrastRatio
v-if="contrast[key]" v-if="contrast?.[key]"
:show-ratio="true" :show-ratio="true"
:contrast="contrast[key]" :contrast="contrast[key]"
/> />
@ -136,11 +136,15 @@ const mobile = computed(() => {
}) })
const contrast = computed(() => { const contrast = computed(() => {
if (props.modelValue == null) return null
const bg = hex2rgb(props.modelValue.bg) const bg = hex2rgb(props.modelValue.bg)
const text = hex2rgb(props.modelValue.text)
const link = hex2rgb(props.modelValue.link)
if (text == null || link == null) return null
return { return {
text: hints(getContrastRatio(bg, hex2rgb(props.modelValue.text))), text: hints(getContrastRatio(bg, text)),
link: hints(getContrastRatio(bg, hex2rgb(props.modelValue.link))), link: hints(getContrastRatio(bg, link)),
} }
}) })