generated from Seekra/repository-template
Add color theme button 'auto' state
This commit is contained in:
@@ -21,18 +21,30 @@ const colorTheme = inject('colorTheme');
|
|||||||
|
|
||||||
const colorThemeNextMapper = {
|
const colorThemeNextMapper = {
|
||||||
'light': 'dark',
|
'light': 'dark',
|
||||||
'dark': 'light'
|
'dark': 'auto',
|
||||||
|
'auto': 'light'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const colorThemeTextMapper = {
|
||||||
|
'light': 'Switch to light mode',
|
||||||
|
'dark': 'Switch to dark mode',
|
||||||
|
'auto': 'Switch to the system theme'
|
||||||
|
}
|
||||||
|
|
||||||
|
const colorThemeIconMapper = {
|
||||||
|
'dark': '⏾',
|
||||||
|
'light': '☀',
|
||||||
|
'auto': '◐'
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<button class="color-theme-button"
|
<button class="color-theme-button"
|
||||||
@click="colorTheme = colorThemeNextMapper[colorTheme]"
|
@click="colorTheme = colorThemeNextMapper[colorTheme]"
|
||||||
:aria-label="`Switch to ${colorThemeNextMapper[colorTheme]} mode`"
|
:aria-label="colorThemeTextMapper[colorThemeNextMapper[colorTheme]]"
|
||||||
:title="`Switch to ${colorThemeNextMapper[colorTheme]} mode`"
|
:title="colorThemeTextMapper[colorThemeNextMapper[colorTheme]]"
|
||||||
>
|
>
|
||||||
<span v-if="colorTheme === 'dark'">☀</span>
|
{{ colorThemeIconMapper[colorThemeNextMapper[colorTheme]] }}
|
||||||
<span v-else-if="colorTheme === 'light'">⏾</span>
|
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user