Make it clear which theme is light / dark

This commit is contained in:
Matthias 2020-12-28 10:49:26 +01:00
parent c80f569a85
commit 37bbac4d60

View File

@ -18,8 +18,9 @@
v-b-tooltip.hover.right v-b-tooltip.hover.right
:active="activeTheme === theme.name" :active="activeTheme === theme.name"
:title="theme.description" :title="theme.description"
:name="theme.name"
@click="handleClick" @click="handleClick"
>{{ theme.name }}</b-dropdown-item-button >{{ theme.name }}{{ theme.dark ? ' [dark]' : '' }}</b-dropdown-item-button
> >
</b-nav-item-dropdown> </b-nav-item-dropdown>
</div> </div>
@ -37,90 +38,112 @@ export default {
{ {
name: 'Bootstrap', name: 'Bootstrap',
description: 'Plain bootstrap default theme', description: 'Plain bootstrap default theme',
dark: false,
}, },
{ {
name: 'Cerulean', name: 'Cerulean',
description: 'A calm blue sky', description: 'A calm blue sky',
dark: false,
}, },
{ {
name: 'Cosmo', name: 'Cosmo',
description: 'An ode to Metro', description: 'An ode to Metro',
dark: false,
}, },
{ {
name: 'Cyborg', name: 'Cyborg',
description: 'Jet black and electric blue', description: 'Jet black and electric blue',
dark: true,
}, },
{ {
name: 'Darkly', name: 'Darkly',
description: 'Flatly in night mode', description: 'Flatly in night mode',
dark: true,
}, },
{ {
name: 'Flatly', name: 'Flatly',
description: 'Flat and modern', description: 'Flat and modern',
dark: false,
}, },
{ {
name: 'Journal', name: 'Journal',
description: 'Crisp like a new sheet of paper', description: 'Crisp like a new sheet of paper',
dark: false,
}, },
{ {
name: 'Litera', name: 'Litera',
description: 'The medium is the message', description: 'The medium is the message',
dark: false,
}, },
{ {
name: 'Lumen', name: 'Lumen',
description: 'Light and shadow', description: 'Light and shadow',
dark: false,
}, },
{ {
name: 'Lux', name: 'Lux',
description: 'A touch of class', description: 'A touch of class',
dark: false,
}, },
{ {
name: 'Materia', name: 'Materia',
description: 'Material is the metaphor', description: 'Material is the metaphor',
dark: false,
}, },
{ {
name: 'Minty', name: 'Minty',
description: 'A fresh feel', description: 'A fresh feel',
dark: false,
}, },
{ {
name: 'Pulse', name: 'Pulse',
description: 'A trace of purple', description: 'A trace of purple',
dark: false,
}, },
{ {
name: 'Sandstone', name: 'Sandstone',
description: 'A touch of warmth', description: 'A touch of warmth',
dark: false,
}, },
{ {
name: 'Simplex', name: 'Simplex',
description: 'Mini and minimalist', description: 'Mini and minimalist',
dark: false,
}, },
{ {
name: 'Sketchy', name: 'Sketchy',
description: 'A hand-drawn look for mockups and mirth', description: 'A hand-drawn look for mockups and mirth',
dark: false,
}, },
{ {
name: 'Slate', name: 'Slate',
description: 'Shades of gunmetal gray', description: 'Shades of gunmetal gray',
dark: true,
}, },
{ {
name: 'Solar', name: 'Solar',
description: 'A spin on Solarized', description: 'A spin on Solarized',
dark: true,
}, },
{ {
name: 'Spacelab', name: 'Spacelab',
description: 'Silvery and sleek', description: 'Silvery and sleek',
dark: false,
}, },
{ {
name: 'Superhero', name: 'Superhero',
description: 'The brave and the blue', description: 'The brave and the blue',
dark: true,
}, },
{ {
name: 'United', name: 'United',
description: 'Ubuntu orange and unique font', description: 'Ubuntu orange and unique font',
dark: false,
}, },
{ {
name: 'Yeti', name: 'Yeti',
description: 'A friendly foundation', description: 'A friendly foundation',
dark: false,
}, },
], ],
}; };
@ -131,7 +154,7 @@ export default {
}, },
methods: { methods: {
handleClick(e) { handleClick(e) {
this.setTheme(e.target.innerText.trim()); this.setTheme(e.target.name.trim());
}, },
setTheme(themeName) { setTheme(themeName) {
// If theme is already active, do nothing. // If theme is already active, do nothing.
@ -147,7 +170,8 @@ export default {
}); });
} else { } else {
// Dynamic import for a different theme, to avoid loading ALL themes. // Dynamic import for a different theme, to avoid loading ALL themes.
import(`bootswatch/dist/${themeName.toLowerCase()}/bootstrap.min.css`).then(() => { import(`bootswatch/dist/${themeName.toLowerCase()}/bootstrap.min.css`).then((mod) => {
console.log('theme', mod);
const styles = document.getElementsByTagName('style'); const styles = document.getElementsByTagName('style');
const bw = Array.from(styles).filter((w) => w.textContent.includes('bootswatch')); const bw = Array.from(styles).filter((w) => w.textContent.includes('bootswatch'));
bw.forEach((style, index) => { bw.forEach((style, index) => {