mirror of
https://github.com/bitwarden/browser
synced 2024-12-26 18:04:07 +01:00
7a43510cf5
* Fix CORS issue on in-line theming javascript * Fix date picker icon color * Add comment * Fix table theming in dark mode * Selfhosted navbar fix * Rename selector to avoid clashing with bootstrap * Do not set initial theme if default * Fix .text-danger style in dropdown lists * Fix toast style, restructure toast and card scss * Fix table and dropdown list hover color * Use callout component for Disable Send warning * Remove unneeded theming for hovering over links * Undo changes to register enterprise2 layout * Apply theming to Safari input field icons e.g. Caps lock, password autofill * Selectively apply themed logo CSS * Fix unrelated linting * Fix webpack config to bundle theme.js Co-authored-by: Danny Murphy <6512845+dltmurphy@users.noreply.github.com>
23 lines
854 B
JavaScript
23 lines
854 B
JavaScript
// Set theme on page load
|
|
// This is done outside the Angular app to avoid a flash of unthemed content before it loads
|
|
// The defaultTheme is also set in the html itself to make sure that some theming is always applied
|
|
(function () {
|
|
const defaultTheme = 'light'
|
|
const htmlEl = document.documentElement;
|
|
let theme = defaultTheme;
|
|
|
|
const savedTheme = window.localStorage.getItem('theme');
|
|
if (savedTheme != null) {
|
|
if (savedTheme.indexOf('system') > -1) {
|
|
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
} else if (savedTheme.indexOf('dark') > -1) {
|
|
theme = 'dark';
|
|
}
|
|
}
|
|
|
|
if (!htmlEl.classList.contains('theme_' + theme)) {
|
|
htmlEl.classList.remove('theme_' + defaultTheme);
|
|
htmlEl.classList.add('theme_' + theme);
|
|
}
|
|
})();
|