settings page, reveal in explorer

This commit is contained in:
2026-05-11 23:59:29 +03:00
parent 2c041be5a9
commit 03af276a1d
5 changed files with 283 additions and 11 deletions
+36 -9
View File
@@ -11,6 +11,8 @@
type Phase = "idle" | "recording" | "editing" | "exporting" | "done"
let { onSettings }: { onSettings: () => void } = $props()
let phase: Phase = $state("idle")
let config: Config | null = $state(null)
let clip: RecordedClip | null = $state(null)
@@ -109,14 +111,17 @@
<main>
<header>
<h1>ByteSize</h1>
<p class="sub">
{#if phase === "recording"}recording...
{:else if phase === "editing"}clip ready
{:else if phase === "exporting"}encoding...
{:else if phase === "done"}exported
{:else}ready{/if}
</p>
<div class="title">
<h1>ByteSize</h1>
<p class="sub">
{#if phase === "recording"}recording...
{:else if phase === "editing"}clip ready
{:else if phase === "exporting"}encoding...
{:else if phase === "done"}exported
{:else}ready{/if}
</p>
</div>
<button class="settings-btn" onclick={onSettings} title="settings">⚙</button>
</header>
{#if phase === "idle"}
@@ -209,6 +214,9 @@
<p>final size: {formatBytes(exportResult.size_bytes)}</p>
<div class="row">
<button class="primary" onclick={startOver}>record another</button>
<button onclick={() => exportResult && api.revealInExplorer(exportResult.output_path)}>
show in explorer
</button>
</div>
</section>
{/if}
@@ -224,6 +232,12 @@
max-width: 720px;
margin: 0 auto;
}
header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 1.5rem;
}
header h1 {
margin: 0 0 0.25rem;
font-size: 1.5rem;
@@ -232,7 +246,20 @@
.sub {
color: #888;
font-size: 0.875rem;
margin: 0 0 1.5rem;
margin: 0;
}
.settings-btn {
font-size: 1.25rem;
padding: 0.25rem 0.5rem;
background: transparent;
border: 1px solid #2a2a2a;
color: #888;
border-radius: 4px;
cursor: pointer;
}
.settings-btn:hover {
color: #fff;
border-color: #888;
}
section {
margin: 1.25rem 0;
+230
View File
@@ -0,0 +1,230 @@
<script lang="ts">
import { onMount } from "svelte"
import { api, type Config } from "./api"
let { onClose }: { onClose: () => void } = $props()
let cfg: Config | null = $state(null)
let saving: boolean = $state(false)
onMount(async () => {
cfg = await api.getConfig()
})
async function save() {
if (!cfg) return
saving = true
try {
await api.saveConfig(cfg)
onClose()
} finally {
saving = false
}
}
</script>
<main>
<header>
<h1>settings</h1>
<button class="back" onclick={onClose}>← back</button>
</header>
{#if cfg}
<section>
<h2>capture</h2>
<label>
<span>default fps</span>
<select bind:value={cfg.capture.default_fps}>
<option value={15}>15</option>
<option value={24}>24</option>
<option value={30}>30</option>
<option value={60}>60</option>
</select>
</label>
<label class="check">
<input type="checkbox" bind:checked={cfg.capture.capture_cursor} />
<span>capture cursor by default</span>
</label>
<label class="check">
<input type="checkbox" bind:checked={cfg.capture.capture_audio} />
<span>capture system audio by default</span>
</label>
</section>
<section>
<h2>export defaults</h2>
<label>
<span>default format</span>
<select bind:value={cfg.export.default_format}>
<option value="gif">GIF</option>
<option value="webm">WebM</option>
<option value="mp4">MP4</option>
</select>
</label>
<label>
<span>GIF dithering</span>
<select bind:value={cfg.export.gif_dither}>
<option value="floyd_steinberg">Floyd-Steinberg</option>
<option value="bayer">Bayer</option>
<option value="none">none</option>
</select>
</label>
<label>
<span>WebM codec</span>
<select bind:value={cfg.export.webm_codec}>
<option value="vp9">VP9 (default)</option>
<option value="av1">AV1 (smaller, slower)</option>
</select>
</label>
<label>
<span>MP4 codec</span>
<select bind:value={cfg.export.mp4_codec}>
<option value="h264">H.264 (default)</option>
<option value="h265">H.265 (smaller, less universal)</option>
</select>
</label>
</section>
<section>
<h2>hotkeys</h2>
<label>
<span>start</span>
<input
type="text"
placeholder="F9"
value={cfg.hotkeys.start ?? ""}
oninput={(e) => cfg && (cfg.hotkeys.start = (e.currentTarget as HTMLInputElement).value || null)}
/>
</label>
<label>
<span>stop</span>
<input
type="text"
placeholder="F9"
value={cfg.hotkeys.stop ?? ""}
oninput={(e) => cfg && (cfg.hotkeys.stop = (e.currentTarget as HTMLInputElement).value || null)}
/>
</label>
<label>
<span>pause</span>
<input
type="text"
placeholder="F10"
value={cfg.hotkeys.pause ?? ""}
oninput={(e) => cfg && (cfg.hotkeys.pause = (e.currentTarget as HTMLInputElement).value || null)}
/>
</label>
</section>
<section>
<h2>updates</h2>
<label class="check">
<input type="checkbox" bind:checked={cfg.updates.check_on_launch} />
<span>check for updates on launch</span>
</label>
</section>
<div class="row">
<button class="primary" disabled={saving} onclick={save}>
{saving ? "saving..." : "save"}
</button>
<button onclick={onClose}>cancel</button>
</div>
{/if}
</main>
<style>
main {
padding: 2rem;
max-width: 720px;
margin: 0 auto;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
header h1 {
margin: 0;
font-size: 1.5rem;
letter-spacing: -0.01em;
}
section {
margin: 1.5rem 0;
padding-top: 1rem;
border-top: 1px solid #2a2a2a;
}
h2 {
margin: 0 0 0.75rem;
font-size: 0.85rem;
color: #888;
font-weight: normal;
text-transform: uppercase;
letter-spacing: 0.05em;
}
label {
display: grid;
grid-template-columns: 180px 1fr;
gap: 1rem;
align-items: center;
margin: 0.75rem 0;
font-size: 0.9rem;
}
label span {
color: #aaa;
}
label.check {
grid-template-columns: 20px 1fr;
}
select, input[type="text"] {
font: inherit;
padding: 0.4rem 0.6rem;
border: 1px solid #444;
background: #222;
color: inherit;
border-radius: 4px;
}
input[type="text"]:focus, select:focus {
outline: none;
border-color: #4a8;
}
.row {
display: flex;
gap: 0.5rem;
margin-top: 2rem;
}
button {
font: inherit;
padding: 0.5rem 1rem;
border: 1px solid #444;
background: transparent;
color: inherit;
cursor: pointer;
border-radius: 4px;
}
button:hover:not(:disabled) {
border-color: #888;
}
button.primary {
background: #4a8;
border-color: #4a8;
color: #111;
}
button.primary:disabled {
background: #333;
border-color: #333;
color: #666;
cursor: not-allowed;
}
button.back {
background: transparent;
border: none;
padding: 0.25rem 0.5rem;
color: #aaa;
font-size: 0.9rem;
}
button.back:hover {
color: #fff;
}
</style>
+1
View File
@@ -78,6 +78,7 @@ export const api = {
startCapture: () => invoke<void>("start_capture"),
stopCapture: () => invoke<RecordedClip>("stop_capture"),
export: (request: ExportRequest) => invoke<ExportResult>("export", { request }),
revealInExplorer: (path: string) => invoke<void>("reveal_in_explorer", { path }),
}
export function formatBytes(n: number): string {