mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 12:49:40 +02:00
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
54 lines
1.4 KiB
Svelte
54 lines
1.4 KiB
Svelte
<script lang="ts">
|
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
import type { Snippet } from 'svelte';
|
|
|
|
type TextVariant = 'body' | 'body-secondary' | 'small' | 'large' | 'muted';
|
|
type TextAlign = 'left' | 'center' | 'right';
|
|
type TextWeight = 'normal' | 'medium' | 'semibold' | 'bold';
|
|
|
|
interface Props extends HTMLAttributes<HTMLParagraphElement> {
|
|
variant?: TextVariant;
|
|
align?: TextAlign;
|
|
weight?: TextWeight;
|
|
class?: string;
|
|
children?: Snippet;
|
|
}
|
|
|
|
let {
|
|
variant = 'body',
|
|
align = 'left',
|
|
weight = 'normal',
|
|
class: className = '',
|
|
children,
|
|
...restProps
|
|
}: Props = $props();
|
|
|
|
const variantClasses: Record<TextVariant, string> = {
|
|
body: 'text-base text-theme leading-relaxed',
|
|
'body-secondary': 'text-base text-theme-secondary leading-relaxed',
|
|
small: 'text-sm text-theme',
|
|
large: 'text-lg text-theme leading-relaxed',
|
|
muted: 'text-sm text-theme-muted',
|
|
};
|
|
|
|
const alignClasses: Record<TextAlign, string> = {
|
|
left: 'text-left',
|
|
center: 'text-center',
|
|
right: 'text-right',
|
|
};
|
|
|
|
const weightClasses: Record<TextWeight, string> = {
|
|
normal: 'font-normal',
|
|
medium: 'font-medium',
|
|
semibold: 'font-semibold',
|
|
bold: 'font-bold',
|
|
};
|
|
|
|
const classes = $derived(
|
|
`${variantClasses[variant]} ${alignClasses[align]} ${weightClasses[weight]} ${className}`
|
|
);
|
|
</script>
|
|
|
|
<p class={classes} {...restProps}>
|
|
{@render children?.()}
|
|
</p>
|