Host fonts locally and guard FOUC

This commit is contained in:
Codex
2026-03-07 23:37:31 +00:00
parent c1aebbb5e2
commit 856b752c0b
11 changed files with 153 additions and 22 deletions

View File

@@ -14,8 +14,6 @@
let val2 = '';
let val3 = '';
let activeField: 1 | 2 | 3 = 1;
let swapSnapshot: { val1: string; val2: string } | null = null;
let isSwapFlipped = false;
$: has3 = ['3col', '3col-mul'].includes(config.type) || !!config.labels.in3;
$: isTextInput = ['base', 'text-bin', 'bin-text', 'dec-frac', 'dms-dd', 'dd-dms'].includes(config.type);
@@ -27,13 +25,7 @@
let paramsInitializing = true;
function resetSwapState() {
swapSnapshot = null;
isSwapFlipped = false;
}
function handleInput(source: 1 | 2 | 3) {
resetSwapState();
activeField = source;
const result = solve(config, source, val1, val2, val3);
if (source !== 1) val1 = result.val1;
@@ -42,23 +34,14 @@
}
function swap() {
if (isSwapFlipped && swapSnapshot) {
val1 = swapSnapshot.val1;
val2 = swapSnapshot.val2;
resetSwapState();
} else {
swapSnapshot = { val1, val2 };
[val1, val2] = [val2, val1];
isSwapFlipped = true;
}
activeField = activeField === 1 ? 2 : 1;
const nextSource: 1 | 2 = activeField === 1 ? 2 : 1;
handleInput(nextSource);
}
function clear() {
val1 = '';
val2 = '';
val3 = '';
resetSwapState();
}
onMount(() => {