mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
migration: rework dark theme enabling
This commit is contained in:
parent
4f047d92d3
commit
5892842cec
8 changed files with 27 additions and 21 deletions
|
@ -8,7 +8,7 @@
|
||||||
:disabled="waiting"
|
:disabled="waiting"
|
||||||
exact-active-class="active"
|
exact-active-class="active"
|
||||||
>
|
>
|
||||||
<span v-if="theme">
|
<span v-if="dark">
|
||||||
<img alt="YunoHost logo" src="./assets/logo_light.png" width="40" />
|
<img alt="YunoHost logo" src="./assets/logo_light.png" width="40" />
|
||||||
</span>
|
</span>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
|
@ -116,7 +116,7 @@ export default {
|
||||||
'transitions',
|
'transitions',
|
||||||
'transitionName',
|
'transitionName',
|
||||||
'waiting',
|
'waiting',
|
||||||
'theme',
|
'dark',
|
||||||
'ssoLink',
|
'ssoLink',
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
|
@ -184,8 +184,11 @@ export default {
|
||||||
if (today.getDate() === 31 && today.getMonth() + 1 === 10) {
|
if (today.getDate() === 31 && today.getMonth() + 1 === 10) {
|
||||||
this.$store.commit('SET_SPINNER', 'spookycat')
|
this.$store.commit('SET_SPINNER', 'spookycat')
|
||||||
}
|
}
|
||||||
|
// updates the data-bs-theme attribute
|
||||||
document.documentElement.setAttribute('dark-theme', this.theme) // updates the data-theme attribute
|
document.documentElement.setAttribute(
|
||||||
|
'data-bs-theme',
|
||||||
|
this.dark ? 'dark' : 'light',
|
||||||
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -63,7 +63,7 @@ export default {
|
||||||
&-#{$color} {
|
&-#{$color} {
|
||||||
color: theme-color-level($color, 6);
|
color: theme-color-level($color, 6);
|
||||||
|
|
||||||
[dark-theme='true'] & {
|
[data-bs-theme='light'] & {
|
||||||
color: theme-color-level($color, -6);
|
color: theme-color-level($color, -6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default {
|
||||||
background-image: url('../../assets/spinners/pacman_dark.gif');
|
background-image: url('../../assets/spinners/pacman_dark.gif');
|
||||||
animation-name: back-and-forth-pacman;
|
animation-name: back-and-forth-pacman;
|
||||||
|
|
||||||
[dark-theme='true'] & {
|
[data-bs-theme='dark'] & {
|
||||||
background-image: url('../../assets/spinners/pacman_light.gif');
|
background-image: url('../../assets/spinners/pacman_light.gif');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ app.config.globalProperties.$askConfirmation = function (message, props) {
|
||||||
bodyClass: [
|
bodyClass: [
|
||||||
'font-weight-bold',
|
'font-weight-bold',
|
||||||
'rounded-top',
|
'rounded-top',
|
||||||
store.state.theme ? 'text-white' : 'text-black',
|
store.state.dark ? 'text-white' : 'text-black',
|
||||||
],
|
],
|
||||||
...props,
|
...props,
|
||||||
})
|
})
|
||||||
|
@ -58,7 +58,7 @@ app.config.globalProperties.$askMdConfirmation = function (
|
||||||
okTitle: this.$t('yes'),
|
okTitle: this.$t('yes'),
|
||||||
cancelTitle: this.$t('cancel'),
|
cancelTitle: this.$t('cancel'),
|
||||||
headerBgVariant: 'warning',
|
headerBgVariant: 'warning',
|
||||||
headerClass: store.state.theme ? 'text-white' : 'text-black',
|
headerClass: store.state.dark ? 'text-white' : 'text-black',
|
||||||
centered: true,
|
centered: true,
|
||||||
...props,
|
...props,
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default {
|
||||||
fallbackLocale: localStorage.getItem('fallbackLocale'),
|
fallbackLocale: localStorage.getItem('fallbackLocale'),
|
||||||
cache: localStorage.getItem('cache') !== 'false',
|
cache: localStorage.getItem('cache') !== 'false',
|
||||||
transitions: localStorage.getItem('transitions') !== 'false',
|
transitions: localStorage.getItem('transitions') !== 'false',
|
||||||
theme: localStorage.getItem('theme') === 'true',
|
dark: localStorage.getItem('dark') === 'true',
|
||||||
experimental: localStorage.getItem('experimental') === 'true',
|
experimental: localStorage.getItem('experimental') === 'true',
|
||||||
spinner: 'pacman',
|
spinner: 'pacman',
|
||||||
supportedLocales,
|
supportedLocales,
|
||||||
|
@ -48,10 +48,13 @@ export default {
|
||||||
state.spinner = spinner
|
state.spinner = spinner
|
||||||
},
|
},
|
||||||
|
|
||||||
SET_THEME(state, boolean) {
|
SET_DARK(state, boolean) {
|
||||||
localStorage.setItem('theme', boolean)
|
localStorage.setItem('dark', boolean)
|
||||||
state.theme = boolean
|
state.dark = boolean
|
||||||
document.documentElement.setAttribute('dark-theme', boolean)
|
document.documentElement.setAttribute(
|
||||||
|
'data-bs-theme',
|
||||||
|
boolean ? 'dark' : 'light',
|
||||||
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -68,8 +71,8 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
UPDATE_THEME({ commit }, theme) {
|
UPDATE_DARK({ commit }, boolean) {
|
||||||
commit('SET_THEME', theme)
|
commit('SET_DARK', boolean)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -78,7 +81,7 @@ export default {
|
||||||
fallbackLocale: (state) => state.fallbackLocale,
|
fallbackLocale: (state) => state.fallbackLocale,
|
||||||
cache: (state) => state.cache,
|
cache: (state) => state.cache,
|
||||||
transitions: (state) => state.transitions,
|
transitions: (state) => state.transitions,
|
||||||
theme: (state) => state.theme,
|
dark: (state) => state.dark,
|
||||||
experimental: (state) => state.experimental,
|
experimental: (state) => state.experimental,
|
||||||
spinner: (state) => state.spinner,
|
spinner: (state) => state.spinner,
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['theme']),
|
...mapGetters(['dark']),
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -63,7 +63,7 @@ export default {
|
||||||
props: { labels: { true: 'enabled', false: 'disabled' } },
|
props: { labels: { true: 'enabled', false: 'disabled' } },
|
||||||
},
|
},
|
||||||
|
|
||||||
theme: {
|
dark: {
|
||||||
id: 'theme',
|
id: 'theme',
|
||||||
label: this.$t('tools_webadmin.theme'),
|
label: this.$t('tools_webadmin.theme'),
|
||||||
component: 'CheckboxItem',
|
component: 'CheckboxItem',
|
||||||
|
@ -77,7 +77,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
// Those are set/get computed properties
|
// Those are set/get computed properties
|
||||||
...mapStoreGetSet(['locale', 'fallbackLocale', 'theme'], 'dispatch'),
|
...mapStoreGetSet(['locale', 'fallbackLocale', 'dark'], 'dispatch'),
|
||||||
...mapStoreGetSet(['cache', 'transitions', 'experimental']),
|
...mapStoreGetSet(['cache', 'transitions', 'experimental']),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
id="apps-pre-upgrade"
|
id="apps-pre-upgrade"
|
||||||
:title="$t('app.upgrade.confirm.title')"
|
:title="$t('app.upgrade.confirm.title')"
|
||||||
header-bg-variant="warning"
|
header-bg-variant="warning"
|
||||||
:header-class="theme ? 'text-white' : 'text-black'"
|
:header-class="dark ? 'text-white' : 'text-black'"
|
||||||
:ok-title="$t('system_upgrade_btn')"
|
:ok-title="$t('system_upgrade_btn')"
|
||||||
ok-variant="success"
|
ok-variant="success"
|
||||||
:cancel-title="$t('cancel')"
|
:cancel-title="$t('cancel')"
|
||||||
|
@ -166,7 +166,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['theme']),
|
...mapGetters(['dark']),
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in a new issue