feat(appliedFontsStore): incorporate implemented font weight logic

This commit is contained in:
Ilia Mashkov
2026-01-20 14:21:07 +03:00
parent 55a560b785
commit d4d2d68d9a
4 changed files with 32 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import { appliedFontsManager } from '$entities/Font';
import { controlManager } from '$features/SetupFont';
import { Input } from '$shared/shadcn/ui/input';
import { ComparisonSlider } from '$shared/ui';
import { displayedFontsStore } from '../../model';
@@ -10,7 +11,7 @@ const [fontA, fontB] = $derived(displayedFontsStore.selectedPair);
const hasAnyPairs = $derived(displayedFontsStore.fonts.length > 0);
$effect(() => {
appliedFontsManager.touch(displayedFontsStore.fonts.map(font => font.id));
appliedFontsManager.touch(displayedFontsStore.fonts.map(font => ({ slug: font.id, weight })));
});
</script>
@@ -22,7 +23,13 @@ $effect(() => {
</div>
{#if fontA && fontB}
<ComparisonSlider fontA={fontA} fontB={fontB} text={displayedText} />
<ComparisonSlider
fontA={fontA}
fontB={fontB}
text={displayedText}
weight={weight}
/>
</div>
{/if}
</div>
{/if}

View File

@@ -7,6 +7,7 @@ import {
FontApplicator,
type UnifiedFont,
} from '$entities/Font';
import { controlManager } from '$features/SetupFont';
import { ContentEditable } from '$shared/ui';
interface Props {
@@ -31,6 +32,8 @@ let {
text = $bindable(),
...restProps
}: Props = $props();
const weight = $derived(controlManager.weight ?? 400);
</script>
<div
@@ -39,6 +42,7 @@ let {
bg-white p-6 border border-slate-200
shadow-sm dark:border-slate-800 dark:bg-slate-950
"
style:font-weight={weight}
>
<FontApplicator id={font.id} name={font.name}>
<ContentEditable bind:text={text} {...restProps} />