Files
frontend-svelte/src/shared/ui/Label/Label.svelte
T

61 lines
1.3 KiB
Svelte
Raw Normal View History

<!--
Component: Label
Inline monospace label. The base primitive for all micrographic text.
-->
2026-02-18 16:56:26 +03:00
<script lang="ts">
import { cn } from '$shared/shadcn/utils/shadcn-utils';
import type { Snippet } from 'svelte';
import {
type LabelSize,
type LabelVariant,
labelSizeConfig,
labelVariantConfig,
} from './config';
2026-02-18 16:56:26 +03:00
interface Props {
variant?: LabelVariant;
size?: LabelSize;
uppercase?: boolean;
bold?: boolean;
icon?: Snippet;
iconPosition?: 'left' | 'right';
children?: Snippet;
2026-02-18 16:56:26 +03:00
class?: string;
}
let {
variant = 'default',
size = 'sm',
uppercase = true,
bold = false,
icon,
iconPosition = 'left',
children,
2026-02-18 16:56:26 +03:00
class: className,
}: Props = $props();
</script>
<span
2026-02-18 16:56:26 +03:00
class={cn(
2026-02-25 09:56:59 +03:00
'font-mono tracking-widest leading-none',
'inline-flex items-center gap-1.5',
labelSizeConfig[size],
labelVariantConfig[variant],
uppercase && 'uppercase',
bold && 'font-bold',
2026-02-18 16:56:26 +03:00
className,
)}
>
{#if icon && iconPosition === 'left'}
<span class="inline-flex">{@render icon()}</span>
{/if}
{#if children}
<span>{@render children()}</span>
2026-02-18 16:56:26 +03:00
{/if}
{#if icon && iconPosition === 'right'}
<span class="inline-flex">{@render icon()}</span>
2026-02-18 16:56:26 +03:00
{/if}
</span>