mirror of
https://github.com/azlux/botamusique
synced 2024-11-23 22:06:09 +00:00
ff5b1cb1ee
* Update assets * Upgrade linting and other improvments * Correct linting * Correction and type check improvements * Correct type check lib * Fix lint pathing for VSCode * Remove duplicate babel config * Remove editorconfig root attribute from web subdir * Use double quotes around message * Simplify ESLint config * Update web assets * Allow AMD loader in WebPack * Bump web dependencies * Only include FA icons in-use
43 lines
977 B
JavaScript
43 lines
977 B
JavaScript
export default class {
|
|
/**
|
|
* @property {boolean} dark Interal state for dark theme activation.
|
|
* @private
|
|
*/
|
|
static #dark = false;
|
|
|
|
/**
|
|
* Inialize the theme class.
|
|
*/
|
|
static init() {
|
|
// Check LocalStorage for dark theme selection
|
|
if (localStorage.getItem('darkTheme') === 'true') {
|
|
// Update page theme
|
|
this.set(true);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Set page theme and update local storage variable.
|
|
*
|
|
* @param {boolean} dark Whether to activate dark theme.
|
|
*/
|
|
static set(dark = false) {
|
|
// Swap CSS to selected theme
|
|
document.getElementById('pagestyle')
|
|
.setAttribute('href', 'static/css/' + (dark ? 'dark' : 'main') + '.css');
|
|
|
|
// Update local storage
|
|
localStorage.setItem('darkTheme', dark);
|
|
|
|
// Update internal state
|
|
this.#dark = dark;
|
|
}
|
|
|
|
/**
|
|
* Swap page theme.
|
|
*/
|
|
static swap() {
|
|
this.set(!this.#dark);
|
|
}
|
|
}
|