2026-01-18 14:35:35 +03:00
|
|
|
<!--
|
|
|
|
|
Component: FontSampler
|
|
|
|
|
Displays a sample text with a given font in a contenteditable element.
|
|
|
|
|
-->
|
|
|
|
|
<script lang="ts">
|
2026-01-18 14:48:36 +03:00
|
|
|
import {
|
|
|
|
|
FontApplicator,
|
|
|
|
|
type UnifiedFont,
|
|
|
|
|
} from '$entities/Font';
|
2026-01-20 14:21:07 +03:00
|
|
|
import { controlManager } from '$features/SetupFont';
|
2026-01-18 14:35:35 +03:00
|
|
|
import { ContentEditable } from '$shared/ui';
|
|
|
|
|
|
|
|
|
|
interface Props {
|
2026-01-18 15:55:07 +03:00
|
|
|
/**
|
|
|
|
|
* Font info
|
|
|
|
|
*/
|
2026-01-18 14:48:36 +03:00
|
|
|
font: UnifiedFont;
|
2026-01-18 15:55:07 +03:00
|
|
|
/**
|
|
|
|
|
* Text to display
|
|
|
|
|
*/
|
2026-01-18 14:48:36 +03:00
|
|
|
text: string;
|
2026-01-18 15:55:07 +03:00
|
|
|
/**
|
|
|
|
|
* Font settings
|
|
|
|
|
*/
|
2026-01-18 14:35:35 +03:00
|
|
|
fontSize?: number;
|
|
|
|
|
lineHeight?: number;
|
|
|
|
|
letterSpacing?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let {
|
2026-01-18 14:48:36 +03:00
|
|
|
font,
|
|
|
|
|
text = $bindable(),
|
2026-01-18 14:35:35 +03:00
|
|
|
...restProps
|
|
|
|
|
}: Props = $props();
|
2026-01-20 14:21:07 +03:00
|
|
|
|
|
|
|
|
const weight = $derived(controlManager.weight ?? 400);
|
2026-01-18 14:35:35 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="
|
|
|
|
|
w-full rounded-xl
|
|
|
|
|
bg-white p-6 border border-slate-200
|
|
|
|
|
shadow-sm dark:border-slate-800 dark:bg-slate-950
|
|
|
|
|
"
|
2026-01-20 14:21:07 +03:00
|
|
|
style:font-weight={weight}
|
2026-01-18 14:35:35 +03:00
|
|
|
>
|
2026-01-18 14:48:36 +03:00
|
|
|
<FontApplicator id={font.id} name={font.name}>
|
|
|
|
|
<ContentEditable bind:text={text} {...restProps} />
|
|
|
|
|
</FontApplicator>
|
2026-01-18 14:35:35 +03:00
|
|
|
</div>
|