current state before improvement pass

This commit is contained in:
2026-05-27 18:56:36 +03:00
parent 5eb27ab779
commit f0775b8ff0
23 changed files with 3563 additions and 1853 deletions
+147 -89
View File
@@ -5,121 +5,179 @@
let { onDone }: { onDone: () => void } = $props()
let start: string | null = $state(null)
let stop: string | null = $state(null)
let stop: string | null = $state(null)
let pause: string | null = $state(null)
let saving: boolean = $state(false)
let warnings: string[] = $state([])
async function save() {
saving = true
warnings = []
try {
const cfg = await api.getConfig()
cfg.hotkeys.start = start
cfg.hotkeys.stop = stop
cfg.hotkeys.stop = stop
cfg.hotkeys.pause = pause
await api.saveConfig(cfg)
onDone()
} finally {
saving = false
}
const result = await api.saveConfig(cfg)
const failed: string[] = []
if (result.hotkey_result.start_ok === false) failed.push("start")
if (result.hotkey_result.stop_ok === false) failed.push("stop")
if (result.hotkey_result.pause_ok === false) failed.push("pause")
if (failed.length > 0) {
warnings = [`${failed.join(", ")} - hotkey may be in use by another app. try different keys.`]
} else {
onDone()
}
} finally { saving = false }
}
let valid = $derived(!!start && !!stop && !!pause)
</script>
<main>
<header>
<h1>ByteSize</h1>
<p class="sub">assign your hotkeys</p>
</header>
<p>
ByteSize doesn't ship default hotkeys. Pick combinations that won't clash
with apps you use. You can change these later in settings.
</p>
<div class="form">
<label>
<span>start</span>
<HotkeyInput bind:value={start} placeholder="e.g. F9" />
</label>
<label>
<span>stop</span>
<HotkeyInput bind:value={stop} placeholder="e.g. F9" />
</label>
<label>
<span>pause</span>
<HotkeyInput bind:value={pause} placeholder="e.g. F10" />
</label>
<div class="stage">
<div class="card">
<div class="card-head">
<div class="logo">BYTESIZE</div>
<div class="tag">assign your hotkeys</div>
</div>
<div class="body">
<p class="copy">
No defaults are shipped. Pick combos that work for you - you can change these later in settings.
</p>
<div class="fields">
<label class="field">
<span class="field-label">Start recording</span>
<HotkeyInput bind:value={start} placeholder="e.g. F9" />
</label>
<label class="field">
<span class="field-label">Stop recording</span>
<HotkeyInput bind:value={stop} placeholder="e.g. F10" />
</label>
<label class="field">
<span class="field-label">Pause / resume</span>
<HotkeyInput bind:value={pause} placeholder="e.g. F11" />
</label>
</div>
{#if warnings.length > 0}
<div class="warn" role="alert">
{#each warnings as w}<p>{w}</p>{/each}
</div>
{/if}
<button class="btn-primary" onclick={save} disabled={!valid || saving}>
{saving ? "Saving" : "Save and continue"}
</button>
<p class="hint">Click a field, press your combo. Escape to cancel.</p>
</div>
</div>
<div class="row">
<button class="primary" disabled={!valid || saving} onclick={save}>
{saving ? "saving..." : "save and continue"}
</button>
</div>
<p class="hint">
Click each field, then press your combo. Escape cancels.
</p>
</main>
</div>
<style>
main {
padding: 2rem;
max-width: 560px;
margin: 0 auto;
}
header h1 {
margin: 0 0 0.25rem;
font-size: 1.5rem;
letter-spacing: -0.01em;
}
.sub {
color: #888;
font-size: 0.875rem;
margin: 0 0 1.5rem;
}
.form {
.stage {
min-height: 100vh;
display: grid;
gap: 0.75rem;
margin: 1.25rem 0;
place-items: center;
padding: 24px;
background: var(--bg);
}
label {
display: grid;
grid-template-columns: 80px 1fr;
align-items: center;
gap: 0.75rem;
.card {
width: 100%;
max-width: 400px;
background: var(--bg-2);
border: 1px solid var(--border);
border-radius: var(--r-md);
overflow: hidden;
}
label span {
color: #aaa;
font-size: 0.875rem;
.card-head {
padding: 28px 24px 20px;
border-bottom: 1px solid var(--border);
text-align: center;
}
.row {
.logo {
font-family: var(--mono);
font-size: 13px;
font-weight: 500;
letter-spacing: 0.12em;
color: var(--accent);
}
.tag {
margin-top: 6px;
font-size: 12px;
color: var(--text-3);
letter-spacing: 0.02em;
}
.body {
padding: 24px;
display: flex;
gap: 0.5rem;
margin: 1rem 0;
flex-direction: column;
gap: 16px;
}
.hint {
color: #888;
font-size: 0.85rem;
.copy {
margin: 0;
font-size: 13px;
line-height: 1.6;
color: var(--text-2);
text-align: center;
}
button {
font: inherit;
padding: 0.5rem 1rem;
border: 1px solid #444;
background: transparent;
color: inherit;
.fields {
display: flex;
flex-direction: column;
gap: 14px;
}
.field {
display: flex;
flex-direction: column;
gap: 6px;
}
.field-label {
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--text-3);
}
.btn-primary {
width: 100%;
padding: 11px 16px;
background: var(--accent);
border: none;
color: var(--accent-text);
border-radius: var(--r-sm);
font-family: var(--sans);
font-size: 13px;
font-weight: 600;
cursor: pointer;
border-radius: 4px;
transition: background 80ms;
}
button:hover:not(:disabled) {
border-color: #888;
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.hint {
margin: 0;
font-size: 11px;
color: var(--text-3);
text-align: center;
}
button.primary {
background: #4a8;
border-color: #4a8;
color: #111;
}
button.primary:disabled {
background: #333;
border-color: #333;
color: #666;
cursor: not-allowed;
.warn {
padding: 10px 14px;
background: var(--err-dim);
border: 1px solid var(--err-border);
border-radius: var(--r-sm);
text-align: center;
}
.warn p { margin: 0; font-size: 12px; color: var(--err); }
</style>