mirror of
https://github.com/wukko/cobalt.git
synced 2025-04-29 22:14:26 +02:00
web/cobalt.js: clean up
This commit is contained in:
parent
8bcb98f005
commit
4aa5aef775
@ -151,13 +151,6 @@ const preferredColorScheme = () => {
|
||||
return theme
|
||||
}
|
||||
|
||||
if (window.matchMedia) {
|
||||
window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', () => {
|
||||
changeStatusBarColor()
|
||||
detectColorScheme()
|
||||
})
|
||||
}
|
||||
|
||||
const changeStatusBarColor = () => {
|
||||
const theme = preferredColorScheme();
|
||||
const colors = {
|
||||
@ -176,10 +169,15 @@ const changeStatusBarColor = () => {
|
||||
document.querySelector('meta[name="theme-color"]').setAttribute('content', colors[state]);
|
||||
}
|
||||
const detectColorScheme = () => {
|
||||
let theme = preferredColorScheme();
|
||||
document.documentElement.setAttribute("data-theme", preferredColorScheme());
|
||||
changeStatusBarColor();
|
||||
}
|
||||
|
||||
document.documentElement.setAttribute("data-theme", theme);
|
||||
changeStatusBarColor(theme);
|
||||
if (window.matchMedia) {
|
||||
window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', () => {
|
||||
changeStatusBarColor()
|
||||
detectColorScheme()
|
||||
})
|
||||
}
|
||||
|
||||
const updateFilenamePreview = () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user