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

90 lines
1.7 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 {
/**
* Visual variant
* @default 'default'
*/
variant?: LabelVariant;
/**
* Label size
* @default 'sm'
*/
size?: LabelSize;
/**
* Uppercase text
* @default true
*/
uppercase?: boolean;
/**
* Bold text
* @default false
*/
bold?: boolean;
/**
* Icon snippet
*/
icon?: Snippet;
/**
* Icon placement
* @default 'left'
*/
iconPosition?: 'left' | 'right';
/**
* Content snippet
*/
children?: Snippet;
/**
* CSS classes
*/
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>