feat: YOLO toggle inline layout; yoloLabel/yoloDescription configurable via config.json

This commit is contained in:
Falkan
2026-03-17 19:50:59 -04:00
parent 78e24017a7
commit e2e53ca44a
4 changed files with 32 additions and 33 deletions

View File

@@ -14,10 +14,12 @@
* Supports same-group and cross-group (YOLO) conversions.
*/
let { data }: { data: { units: Unit[]; groups: Group[] } } = $props();
let { data }: { data: { units: Unit[]; groups: Group[]; yoloLabel: string; yoloDescription: string } } = $props();
let units: Unit[] = $derived(data.units);
let groups: Group[] = $derived(data.groups);
let yoloLabel: string = $derived(data.yoloLabel);
let yoloDescription: string = $derived(data.yoloDescription);
// ── Reactive state ──────────────────────────────────────────────────────────
let inputValue = $state<number>(1);
@@ -94,6 +96,8 @@
);
// ── URL sync ────────────────────────────────────────────────────────────────
// Use history.replaceState directly — goto() triggers a SvelteKit navigation
// which re-renders the page and steals focus from the input on every keystroke.
$effect(() => {
if (!browser) return;
const params = new URLSearchParams();
@@ -104,7 +108,7 @@
}
const next = params.toString();
if (next !== window.location.search.slice(1)) {
goto(`?${next}`, { replaceState: true, noScroll: true });
history.replaceState(history.state, '', `?${next}`);
}
});
@@ -176,7 +180,10 @@
<div class="yolo-toggle-row">
<label class="yolo-label">
<input type="checkbox" bind:checked={yoloMode} role="switch" />
YOLO mode <small>(cross-group conversions)</small>
<span class="yolo-label-text">{yoloLabel}</span>
{#if yoloDescription}
<small class="yolo-desc">{yoloDescription}</small>
{/if}
</label>
</div>
@@ -198,17 +205,24 @@
<style>
.yolo-toggle-row {
margin-bottom: 1rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.yolo-label {
display: flex;
display: inline-flex;
align-items: center;
gap: 0.5rem;
cursor: pointer;
user-select: none;
white-space: nowrap;
}
.yolo-label-text {
font-weight: 500;
}
.yolo-desc {
color: var(--pico-muted-color);
white-space: nowrap;
}
.yolo-marker {