mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-12 11:52:12 +01:00
web/cobalt.js: clean up
This commit is contained in:
parent
8bcb98f005
commit
4aa5aef775
1 changed files with 8 additions and 10 deletions
|
@ -151,13 +151,6 @@ const preferredColorScheme = () => {
|
||||||
return theme
|
return theme
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.matchMedia) {
|
|
||||||
window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', () => {
|
|
||||||
changeStatusBarColor()
|
|
||||||
detectColorScheme()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const changeStatusBarColor = () => {
|
const changeStatusBarColor = () => {
|
||||||
const theme = preferredColorScheme();
|
const theme = preferredColorScheme();
|
||||||
const colors = {
|
const colors = {
|
||||||
|
@ -176,10 +169,15 @@ const changeStatusBarColor = () => {
|
||||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', colors[state]);
|
document.querySelector('meta[name="theme-color"]').setAttribute('content', colors[state]);
|
||||||
}
|
}
|
||||||
const detectColorScheme = () => {
|
const detectColorScheme = () => {
|
||||||
let theme = preferredColorScheme();
|
document.documentElement.setAttribute("data-theme", preferredColorScheme());
|
||||||
|
changeStatusBarColor();
|
||||||
|
}
|
||||||
|
|
||||||
document.documentElement.setAttribute("data-theme", theme);
|
if (window.matchMedia) {
|
||||||
changeStatusBarColor(theme);
|
window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', () => {
|
||||||
|
changeStatusBarColor()
|
||||||
|
detectColorScheme()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateFilenamePreview = () => {
|
const updateFilenamePreview = () => {
|
||||||
|
|
Loading…
Reference in a new issue