Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions js/theme-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Anti-flash theme initialiser for Riksdagsmonitor news articles.
*
* Runs synchronously before first paint to set the correct `data-theme`
* attribute on `<html>` and prevent a flash of the wrong theme.
*
* Uses the same storage key (`riksdagsmonitor-theme`) as theme-toggle.js
* so that all theme state remains consistent across the app.
*
* @module js/theme-init
*/
(function () {
var key = 'riksdagsmonitor-theme';
var t = null;
try { t = localStorage.getItem(key); } catch (_e) { /* ignore storage errors */ }
if (t !== 'dark' && t !== 'light') {
if (t !== null) { try { localStorage.removeItem(key); } catch (_e) { /* ignore storage errors */ } }
t = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light';
}
document.documentElement.setAttribute('data-theme', t);
}());
4 changes: 2 additions & 2 deletions js/theme-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
if (stored === DARK || stored === LIGHT) {
return stored;
}
} catch (e) {
} catch (_e) {
// Ignore storage errors and fall back to the attribute set by the anti-flash snippet
}
return null;
Expand All @@ -70,7 +70,7 @@
applyTheme(currentTheme, button);
try {
window.localStorage.setItem(STORAGE_KEY, currentTheme);
} catch (e) {
} catch (_e) {
// Ignore storage errors
}
});
Expand Down
257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-ar.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-da.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-de.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-en.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-es.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-fi.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-fr.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-he.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-ja.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-ko.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-nl.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-no.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-sv.html

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions news/2026-03-05-evening-analysis-zh.html

Large diffs are not rendered by default.

Loading