From 61537693178f15caacd8a2cf0d0ffb884ba1bb84 Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Sat, 30 May 2026 22:29:43 +0300 Subject: [PATCH] refactor(comparison): switch to 3-section render model via DualFontLayout Rewrite Line.svelte to render leftText / windowChars / rightText regions from a LineRenderModel. Bulk regions render as native shaped text runs so the browser applies kerning and ligatures; per-char DOM is reserved for the N-char crossfade window straddling the slider. Slim Character.svelte: drop the unused proximity prop and the redundant font-size/font-weight/letter-spacing styles now inherited from the line container. Switch SliderArea.svelte to instantiate DualFontLayout and derive each line's render model via computeLineRenderModel(line, sliderPos, containerWidth, WINDOW_SIZE). --- .../ui/Character/Character.svelte | 21 ++------ .../ComparisonView/ui/Line/Line.svelte | 50 ++++++++++--------- .../ui/SliderArea/SliderArea.svelte | 32 ++++++------ 3 files changed, 46 insertions(+), 57 deletions(-) diff --git a/src/widgets/ComparisonView/ui/Character/Character.svelte b/src/widgets/ComparisonView/ui/Character/Character.svelte index 7261b16..e55c63f 100644 --- a/src/widgets/ComparisonView/ui/Character/Character.svelte +++ b/src/widgets/ComparisonView/ui/Character/Character.svelte @@ -3,7 +3,6 @@ Renders a single character with morphing animation --> {#if fontA && fontB} - 0 ? 'transform' : 'auto'} - > + {#each [0, 1] as s (s)} { : 'text-neutral-950 dark:text-white', )} style:font-family={slotFonts[s]} - style:font-weight={typography.weight} style:opacity={slot === s ? '1' : '0'} style:position={slot === s ? 'relative' : 'absolute'} aria-hidden={slot !== s ? true : undefined} @@ -89,7 +77,6 @@ $effect(() => { font-optical-sizing: auto; transition: opacity 0.1s ease-out, - color 0.2s ease-out, - transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); + color 0.2s ease-out; } diff --git a/src/widgets/ComparisonView/ui/Line/Line.svelte b/src/widgets/ComparisonView/ui/Line/Line.svelte index d8cb81f..69c5e08 100644 --- a/src/widgets/ComparisonView/ui/Line/Line.svelte +++ b/src/widgets/ComparisonView/ui/Line/Line.svelte @@ -1,42 +1,46 @@
- {#each chars as c, index} - {@render character?.({ char: c.char, index })} + {#if model.leftText} + {model.leftText} + {/if} + {#each model.windowChars as wc (wc.key)} + {/each} + {#if model.rightText} + {model.rightText} + {/if}
diff --git a/src/widgets/ComparisonView/ui/SliderArea/SliderArea.svelte b/src/widgets/ComparisonView/ui/SliderArea/SliderArea.svelte index 9e3708f..1a513b4 100644 --- a/src/widgets/ComparisonView/ui/SliderArea/SliderArea.svelte +++ b/src/widgets/ComparisonView/ui/SliderArea/SliderArea.svelte @@ -9,10 +9,12 @@ -->