ots/frontend/index.html
Knut Ahlers 5c0ea48261
Add Theme-Switcher for Dark-/Light-Mode
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2021-09-16 19:52:14 +02:00

36 lines
1 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="css/all.min.css"/>
<title>OTS - One Time Secrets</title>
<script>
window.getTheme = () => localStorage.getItem('set-color-scheme') || (window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark')
window.refreshTheme = () => {
document.querySelector('html').setAttribute('mode', window.getTheme())
}
window.setTheme = (theme) => {
localStorage.setItem('set-color-scheme', theme)
window.refreshTheme()
}
// Very early load of theme definition to avoid flickering
document.addEventListener('DOMContentLoaded', () => window.refreshTheme())
</script>
</head>
<body>
<div id="app"></div>
<script src="vars.js"></script>
<script src="app.js"></script>
</body>
</html>