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-30 00:56:21 +03:00
|
|
|
import {
|
|
|
|
|
ContentEditable,
|
2026-02-06 15:56:48 +03:00
|
|
|
Footnote,
|
2026-02-06 12:17:11 +03:00
|
|
|
// IconButton,
|
2026-01-30 00:56:21 +03:00
|
|
|
} from '$shared/ui';
|
2026-02-06 12:17:11 +03:00
|
|
|
// import XIcon from '@lucide/svelte/icons/x';
|
2026-01-18 14:35:35 +03:00
|
|
|
|
|
|
|
|
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-30 17:42:06 +03:00
|
|
|
/**
|
|
|
|
|
* Index of the font sampler
|
|
|
|
|
*/
|
|
|
|
|
index?: number;
|
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-30 17:42:06 +03:00
|
|
|
index = 0,
|
2026-01-18 14:35:35 +03:00
|
|
|
...restProps
|
|
|
|
|
}: Props = $props();
|
2026-01-20 14:21:07 +03:00
|
|
|
|
2026-01-30 00:56:21 +03:00
|
|
|
const fontWeight = $derived(controlManager.weight);
|
2026-02-07 11:28:13 +03:00
|
|
|
const fontSize = $derived(controlManager.renderedSize);
|
2026-01-30 00:56:21 +03:00
|
|
|
const lineHeight = $derived(controlManager.height);
|
|
|
|
|
const letterSpacing = $derived(controlManager.spacing);
|
2026-01-18 14:35:35 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="
|
2026-02-06 14:48:44 +03:00
|
|
|
w-full h-full rounded-xl sm:rounded-2xl
|
2026-01-30 17:42:06 +03:00
|
|
|
flex flex-col
|
2026-02-10 23:19:27 +03:00
|
|
|
backdrop-blur-md bg-background-80
|
|
|
|
|
border border-border-muted
|
2026-01-30 17:42:06 +03:00
|
|
|
shadow-[0_1px_3px_rgba(0,0,0,0.04)]
|
|
|
|
|
relative overflow-hidden
|
2026-01-18 14:35:35 +03:00
|
|
|
"
|
2026-01-30 00:56:21 +03:00
|
|
|
style:font-weight={fontWeight}
|
2026-01-18 14:35:35 +03:00
|
|
|
>
|
2026-02-10 23:19:27 +03:00
|
|
|
<div class="px-4 sm:px-5 md:px-6 py-2.5 sm:py-3 border-b border-border-subtle flex items-center justify-between">
|
2026-02-06 14:48:44 +03:00
|
|
|
<div class="flex items-center gap-2 sm:gap-2.5">
|
2026-02-06 15:56:48 +03:00
|
|
|
<Footnote>
|
2026-01-30 17:42:06 +03:00
|
|
|
typeface_{String(index).padStart(3, '0')}
|
2026-02-06 15:56:48 +03:00
|
|
|
</Footnote>
|
2026-02-10 23:19:27 +03:00
|
|
|
<div class="w-px h-2 sm:h-2.5 bg-border-subtle"></div>
|
|
|
|
|
<Footnote class="tracking-[0.15em] font-bold text-foreground">
|
2026-01-30 17:42:06 +03:00
|
|
|
{font.name}
|
2026-02-06 15:56:48 +03:00
|
|
|
</Footnote>
|
2026-01-30 17:42:06 +03:00
|
|
|
</div>
|
|
|
|
|
|
2026-02-06 12:17:11 +03:00
|
|
|
<!--
|
|
|
|
|
<IconButton
|
|
|
|
|
onclick={removeSample}
|
|
|
|
|
class="w-5 h-5 rounded-full hover:bg-transparent flex items-center justify-center transition-colors group translate-x-1/2 cursor-pointer"
|
|
|
|
|
>
|
|
|
|
|
{#snippet icon({ className })}
|
|
|
|
|
<XIcon class={className} />
|
|
|
|
|
{/snippet}
|
|
|
|
|
</IconButton>
|
|
|
|
|
-->
|
2026-01-30 00:56:21 +03:00
|
|
|
</div>
|
2026-01-30 17:42:06 +03:00
|
|
|
|
2026-02-06 14:48:44 +03:00
|
|
|
<div class="p-4 sm:p-5 md:p-8 relative z-10">
|
2026-02-10 18:13:03 +03:00
|
|
|
<FontApplicator {font} weight={fontWeight}>
|
2026-01-30 00:56:21 +03:00
|
|
|
<ContentEditable
|
|
|
|
|
bind:text={text}
|
|
|
|
|
{...restProps}
|
|
|
|
|
fontSize={fontSize}
|
|
|
|
|
lineHeight={lineHeight}
|
|
|
|
|
letterSpacing={letterSpacing}
|
|
|
|
|
/>
|
|
|
|
|
</FontApplicator>
|
|
|
|
|
</div>
|
2026-01-30 17:42:06 +03:00
|
|
|
|
2026-02-10 23:19:27 +03:00
|
|
|
<div class="px-4 sm:px-5 md:px-6 py-1.5 sm:py-2 border-t border-border-subtle w-full flex flex-row gap-2 sm:gap-4 bg-background mt-auto">
|
2026-02-06 15:56:48 +03:00
|
|
|
<Footnote class="text-[7px] sm:text-[8px] tracking-wider ml-auto">
|
2026-01-30 17:42:06 +03:00
|
|
|
SZ:{fontSize}PX
|
2026-02-06 15:56:48 +03:00
|
|
|
</Footnote>
|
2026-02-10 23:19:27 +03:00
|
|
|
<div class="w-px h-2 sm:h-2.5 self-center bg-border-subtle hidden sm:block"></div>
|
2026-02-06 15:56:48 +03:00
|
|
|
<Footnote class="text-[7px] sm:text-[8px] tracking-wider">
|
2026-01-30 17:42:06 +03:00
|
|
|
WGT:{fontWeight}
|
2026-02-06 15:56:48 +03:00
|
|
|
</Footnote>
|
2026-02-10 23:19:27 +03:00
|
|
|
<div class="w-px h-2 sm:h-2.5 self-center bg-border-subtle hidden sm:block"></div>
|
2026-02-06 15:56:48 +03:00
|
|
|
<Footnote class="text-[7px] sm:text-[8px] tracking-wider">
|
2026-01-30 17:42:06 +03:00
|
|
|
LH:{lineHeight?.toFixed(2)}
|
2026-02-06 15:56:48 +03:00
|
|
|
</Footnote>
|
2026-02-10 23:19:27 +03:00
|
|
|
<div class="w-px h-2 sm:h-2.5 self-center bg-border-subtle hidden sm:block"></div>
|
2026-02-06 15:56:48 +03:00
|
|
|
<Footnote class="text-[0.4375rem] sm:text-[0.5rem] tracking-wider">
|
2026-01-30 17:42:06 +03:00
|
|
|
LTR:{letterSpacing}
|
2026-02-06 15:56:48 +03:00
|
|
|
</Footnote>
|
2026-01-30 17:42:06 +03:00
|
|
|
</div>
|
2026-01-18 14:35:35 +03:00
|
|
|
</div>
|