mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
automatically theme mode based on user preference
Related to #1901 Implemented automatic dark theme change based on user preference using the `prefers-color-scheme` media query.
This commit is contained in:
parent
d635cca210
commit
e484d426fe
2 changed files with 11 additions and 0 deletions
8
src/web/waiters/OptionsWaiter.mjs
Executable file → Normal file
8
src/web/waiters/OptionsWaiter.mjs
Executable file → Normal file
|
@ -163,6 +163,14 @@ class OptionsWaiter {
|
|||
themeSelect.selectedIndex = themeSelect.querySelector(`option[value="${theme}"`).index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the user's preferred color scheme using the `prefers-color-scheme` media query.
|
||||
*/
|
||||
applyPreferredColorScheme() {
|
||||
const prefersDarkScheme = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
const theme = prefersDarkScheme ? "dark" : "classic";
|
||||
this.changeTheme(theme);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the console logging level.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue