mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
Various Dark Theme fixes per QA feedback (#1212)
* 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>
This commit is contained in:
22
src/theme.js
Normal file
22
src/theme.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user