2026-02-24 17:59:18 +03:00
|
|
|
<!--
|
|
|
|
|
Component: Label
|
|
|
|
|
Inline monospace label. The base primitive for all micrographic text.
|
|
|
|
|
-->
|
2026-02-18 16:56:26 +03:00
|
|
|
<script lang="ts">
|
2026-04-23 09:48:32 +03:00
|
|
|
import { cn } from '$shared/lib';
|
2026-02-24 17:59:18 +03:00
|
|
|
import type { Snippet } from 'svelte';
|
|
|
|
|
import {
|
2026-04-17 08:55:10 +03:00
|
|
|
type LabelFont,
|
2026-02-24 17:59:18 +03:00
|
|
|
type LabelSize,
|
|
|
|
|
type LabelVariant,
|
|
|
|
|
labelSizeConfig,
|
|
|
|
|
labelVariantConfig,
|
|
|
|
|
} from './config';
|
2026-02-18 16:56:26 +03:00
|
|
|
|
|
|
|
|
interface Props {
|
2026-03-02 22:19:35 +03:00
|
|
|
/**
|
|
|
|
|
* Visual variant
|
|
|
|
|
* @default 'default'
|
|
|
|
|
*/
|
2026-02-24 17:59:18 +03:00
|
|
|
variant?: LabelVariant;
|
2026-03-02 22:19:35 +03:00
|
|
|
/**
|
|
|
|
|
* Label size
|
|
|
|
|
* @default 'sm'
|
|
|
|
|
*/
|
2026-02-24 17:59:18 +03:00
|
|
|
size?: LabelSize;
|
2026-03-02 22:19:35 +03:00
|
|
|
/**
|
|
|
|
|
* Uppercase text
|
|
|
|
|
* @default true
|
|
|
|
|
*/
|
2026-02-24 17:59:18 +03:00
|
|
|
uppercase?: boolean;
|
2026-04-17 08:55:10 +03:00
|
|
|
/**
|
|
|
|
|
* Font family
|
|
|
|
|
* @default 'mono'
|
|
|
|
|
*/
|
|
|
|
|
font?: LabelFont;
|
2026-03-02 22:19:35 +03:00
|
|
|
/**
|
|
|
|
|
* Bold text
|
|
|
|
|
* @default false
|
|
|
|
|
*/
|
2026-02-24 17:59:18 +03:00
|
|
|
bold?: boolean;
|
2026-03-02 22:19:35 +03:00
|
|
|
/**
|
|
|
|
|
* Icon snippet
|
|
|
|
|
*/
|
2026-02-24 17:59:18 +03:00
|
|
|
icon?: Snippet;
|
2026-03-02 22:19:35 +03:00
|
|
|
/**
|
|
|
|
|
* Icon placement
|
|
|
|
|
* @default 'left'
|
|
|
|
|
*/
|
2026-02-24 17:59:18 +03:00
|
|
|
iconPosition?: 'left' | 'right';
|
2026-03-02 22:19:35 +03:00
|
|
|
/**
|
|
|
|
|
* Content snippet
|
|
|
|
|
*/
|
2026-02-24 17:59:18 +03:00
|
|
|
children?: Snippet;
|
2026-03-02 22:19:35 +03:00
|
|
|
/**
|
|
|
|
|
* CSS classes
|
|
|
|
|
*/
|
2026-02-18 16:56:26 +03:00
|
|
|
class?: string;
|
|
|
|
|
}
|
2026-02-24 17:59:18 +03:00
|
|
|
|
|
|
|
|
let {
|
|
|
|
|
variant = 'default',
|
|
|
|
|
size = 'sm',
|
2026-04-17 08:55:10 +03:00
|
|
|
font = 'mono',
|
2026-02-24 17:59:18 +03:00
|
|
|
uppercase = true,
|
|
|
|
|
bold = false,
|
|
|
|
|
icon,
|
|
|
|
|
iconPosition = 'left',
|
|
|
|
|
children,
|
2026-02-18 16:56:26 +03:00
|
|
|
class: className,
|
|
|
|
|
}: Props = $props();
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-02-24 17:59:18 +03:00
|
|
|
<span
|
2026-04-23 09:48:32 +03:00
|
|
|
class={cn(
|
2026-02-25 09:56:59 +03:00
|
|
|
'font-mono tracking-widest leading-none',
|
2026-02-24 17:59:18 +03:00
|
|
|
'inline-flex items-center gap-1.5',
|
2026-04-17 08:55:10 +03:00
|
|
|
font === 'primary' && 'font-primary tracking-tight',
|
2026-02-24 17:59:18 +03:00
|
|
|
labelSizeConfig[size],
|
|
|
|
|
labelVariantConfig[variant],
|
|
|
|
|
uppercase && 'uppercase',
|
|
|
|
|
bold && 'font-bold',
|
2026-02-18 16:56:26 +03:00
|
|
|
className,
|
|
|
|
|
)}
|
|
|
|
|
>
|
2026-02-24 17:59:18 +03:00
|
|
|
{#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}
|
2026-02-24 17:59:18 +03:00
|
|
|
|
|
|
|
|
{#if icon && iconPosition === 'right'}
|
|
|
|
|
<span class="inline-flex">{@render icon()}</span>
|
2026-02-18 16:56:26 +03:00
|
|
|
{/if}
|
2026-02-24 17:59:18 +03:00
|
|
|
</span>
|