Add a theme toggle, and fix the voice picker showing no voices
Some checks failed
CI / build-and-deploy (push) Has been cancelled
Some checks failed
CI / build-and-deploy (push) Has been cancelled
Theme toggle sits next to the settings icon. The choice starts as 'system' and follows the OS until you press it, after which it's explicit and persisted. An inline script in <head> stamps the resolved theme on <html> before the first paint - resolving it from JS after load means a visible flash of dark on the way to light. Because that attribute is always present, the stylesheet drops its prefers-color-scheme query entirely rather than having a media query and an explicit override fighting over the same tokens. The voice picker was effectively empty: Chrome reports zero voices synchronously and only fills the list when voiceschanged fires, and while the narrator did reload them, nothing told preact to re-render - so the dropdown kept whatever existed at construction, which was nothing. It now notifies, and the list arrives (181 voices here). That many voices needs shape, so they're sorted with your own language first and offline voices ahead of network ones, then grouped into optgroups by language. Network voices are marked as such since they're useless offline, which for an app built to work in a field matters. Speed and pitch are adjustable too, both fed through to every utterance. The settings button gains a class of its own: the header now has two icon buttons, so identifying it by .icon-button alone hits the theme toggle. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QK7PKpRVoy69Fpa32R8abb
This commit is contained in:
@@ -13,9 +13,31 @@
|
||||
href="https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
<script>
|
||||
// Resolve the theme before the first paint, or the page flashes dark on
|
||||
// its way to light. Kept inline and dependency-free for that reason.
|
||||
(() => {
|
||||
let choice = 'system';
|
||||
try {
|
||||
choice =
|
||||
JSON.parse(localStorage.getItem('web-dslr.prefs') || '{}').theme ||
|
||||
'system';
|
||||
} catch {}
|
||||
document.documentElement.dataset.theme =
|
||||
choice === 'light' || choice === 'dark'
|
||||
? choice
|
||||
: matchMedia('(prefers-color-scheme: light)').matches
|
||||
? 'light'
|
||||
: 'dark';
|
||||
})();
|
||||
</script>
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: dark light;
|
||||
/* Dark is the base. The script above always stamps an explicit
|
||||
data-theme, so there's no prefers-color-scheme query here to fight
|
||||
with an override the user has chosen. */
|
||||
:root,
|
||||
:root[data-theme='dark'] {
|
||||
color-scheme: dark;
|
||||
--bg: #14161a;
|
||||
--panel: #1c1f26;
|
||||
--panel-2: #242832;
|
||||
@@ -30,17 +52,16 @@
|
||||
--radius: 10px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
--bg: #f2f4f7;
|
||||
--panel: #ffffff;
|
||||
--panel-2: #f7f8fa;
|
||||
--line: #d9dee6;
|
||||
--text: #1a1d23;
|
||||
--muted: #5c6675;
|
||||
--accent: #1f6fd0;
|
||||
--accent-text: #ffffff;
|
||||
}
|
||||
:root[data-theme='light'] {
|
||||
color-scheme: light;
|
||||
--bg: #f2f4f7;
|
||||
--panel: #ffffff;
|
||||
--panel-2: #f7f8fa;
|
||||
--line: #d9dee6;
|
||||
--text: #1a1d23;
|
||||
--muted: #5c6675;
|
||||
--accent: #1f6fd0;
|
||||
--accent-text: #ffffff;
|
||||
}
|
||||
|
||||
* {
|
||||
@@ -91,6 +112,12 @@
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
#app-header .header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
#app-header .logo {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user