feat(FontSampler): edit FontSampler to applt font-family through FontApplicator component
This commit is contained in:
@@ -3,26 +3,25 @@
|
|||||||
Displays a sample text with a given font in a contenteditable element.
|
Displays a sample text with a given font in a contenteditable element.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { appliedFontsManager } from '$entities/Font';
|
import {
|
||||||
|
FontApplicator,
|
||||||
|
type UnifiedFont,
|
||||||
|
} from '$entities/Font';
|
||||||
import { ContentEditable } from '$shared/ui';
|
import { ContentEditable } from '$shared/ui';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
fontId: string;
|
font: UnifiedFont;
|
||||||
text?: string;
|
text: string;
|
||||||
fontSize?: number;
|
fontSize?: number;
|
||||||
lineHeight?: number;
|
lineHeight?: number;
|
||||||
letterSpacing?: number;
|
letterSpacing?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
fontId,
|
font,
|
||||||
|
text = $bindable(),
|
||||||
...restProps
|
...restProps
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
// Ensure the font is registered as soon as this sampler appears
|
|
||||||
$effect(() => {
|
|
||||||
appliedFontsManager.registerFonts([fontId]);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -31,7 +30,8 @@ $effect(() => {
|
|||||||
bg-white p-6 border border-slate-200
|
bg-white p-6 border border-slate-200
|
||||||
shadow-sm dark:border-slate-800 dark:bg-slate-950
|
shadow-sm dark:border-slate-800 dark:bg-slate-950
|
||||||
"
|
"
|
||||||
style:font-family={fontId}
|
|
||||||
>
|
>
|
||||||
<ContentEditable {...restProps} />
|
<FontApplicator id={font.id} name={font.name}>
|
||||||
|
<ContentEditable bind:text={text} {...restProps} />
|
||||||
|
</FontApplicator>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user