Merge branch 'more-fixes' into shigusegubu-themes3
This commit is contained in:
commit
0814fdbb9b
2 changed files with 39 additions and 11 deletions
|
|
@ -26,14 +26,14 @@ export default (data) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const suggestEmoji = (emojis) => (input, nameKeywordLocalizer) => {
|
export const suggestEmoji = (emojis) => (input, nameKeywordLocalizer) => {
|
||||||
const noPrefix = input.toLowerCase().substr(1)
|
const noPrefix = input.toLowerCase().substring(1)
|
||||||
return emojis
|
return emojis
|
||||||
.map((emoji) => ({ ...emoji, ...nameKeywordLocalizer(emoji) }))
|
.map((emoji) => ({ ...emoji, ...nameKeywordLocalizer(emoji) }))
|
||||||
.filter(
|
.filter(
|
||||||
(emoji) =>
|
(emoji) =>
|
||||||
emoji.names
|
emoji.names
|
||||||
.concat(emoji.keywords)
|
.concat(emoji.keywords)
|
||||||
.filter((kw) => kw.toLowerCase().match(noPrefix)).length,
|
.filter((kw) => kw.toLowerCase().includes(noPrefix)).length,
|
||||||
)
|
)
|
||||||
.map((k) => {
|
.map((k) => {
|
||||||
let score = 0
|
let score = 0
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
:class="{ '-compact': compact, '-apply': apply, '-mobile': mobile }"
|
:class="{ '-compact': compact, '-apply': apply, '-mobile': mobile }"
|
||||||
>
|
>
|
||||||
<div class="palette">
|
<div class="palette">
|
||||||
|
<div v-for="key in paletteKeys">
|
||||||
<ColorInput
|
<ColorInput
|
||||||
v-for="key in paletteKeys"
|
|
||||||
:key="key"
|
:key="key"
|
||||||
:name="key"
|
:name="key"
|
||||||
:model-value="props.modelValue[key]"
|
:model-value="props.modelValue[key]"
|
||||||
|
|
@ -13,6 +13,12 @@
|
||||||
:label="$t('settings.style.themes3.palette.' + key)"
|
:label="$t('settings.style.themes3.palette.' + key)"
|
||||||
@update:model-value="value => updatePalette(key, value)"
|
@update:model-value="value => updatePalette(key, value)"
|
||||||
/>
|
/>
|
||||||
|
<ContrastRatio
|
||||||
|
v-if="contrast[key]"
|
||||||
|
:show-ratio="true"
|
||||||
|
:contrast="contrast[key]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button
|
<button
|
||||||
|
|
@ -48,6 +54,9 @@
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
import ColorInput from 'src/components/color_input/color_input.vue'
|
import ColorInput from 'src/components/color_input/color_input.vue'
|
||||||
|
import ContrastRatio from 'src/components/contrast_ratio/contrast_ratio.vue'
|
||||||
|
|
||||||
|
import { getContrastRatio, hex2rgb } from 'src/services/color_convert/color_convert.js'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
|
||||||
|
|
@ -106,6 +115,16 @@ const importPalette = () => {
|
||||||
paletteImporter.importData()
|
paletteImporter.importData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hints = (ratio) => ({
|
||||||
|
text: ratio.toPrecision(3) + ':1',
|
||||||
|
// AA level, AAA level
|
||||||
|
aa: ratio >= 4.5,
|
||||||
|
aaa: ratio >= 7,
|
||||||
|
// same but for 18pt+ texts
|
||||||
|
laa: ratio >= 3,
|
||||||
|
laaa: ratio >= 4.5,
|
||||||
|
})
|
||||||
|
|
||||||
const applyPalette = () => {
|
const applyPalette = () => {
|
||||||
emit('applyPalette', getExportedObject())
|
emit('applyPalette', getExportedObject())
|
||||||
}
|
}
|
||||||
|
|
@ -114,6 +133,15 @@ const mobile = computed(() => {
|
||||||
return useInterfaceStore().layoutType === 'mobile'
|
return useInterfaceStore().layoutType === 'mobile'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const contrast = computed(() => {
|
||||||
|
const bg = hex2rgb(props.modelValue.bg)
|
||||||
|
|
||||||
|
return {
|
||||||
|
text: hints(getContrastRatio(bg, hex2rgb(props.modelValue.text))),
|
||||||
|
link: hints(getContrastRatio(bg, hex2rgb(props.modelValue.link))),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const fallback = (key) => {
|
const fallback = (key) => {
|
||||||
if (key === 'accent') {
|
if (key === 'accent') {
|
||||||
return props.modelValue.link
|
return props.modelValue.link
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue