This commit is contained in:
@@ -1,15 +1,6 @@
|
||||
import type { ElementType, ReactNode } from 'react';
|
||||
|
||||
type LabelVariant =
|
||||
| 'h1'
|
||||
| 'h2'
|
||||
| 'h3'
|
||||
| 'h4'
|
||||
| 'body'
|
||||
| 'body2'
|
||||
| 'caption'
|
||||
| 'error'
|
||||
| 'code';
|
||||
type LabelVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'body' | 'body2' | 'caption' | 'error' | 'code';
|
||||
|
||||
type LabelProps<T extends ElementType> = {
|
||||
variant?: LabelVariant;
|
||||
@@ -27,7 +18,7 @@ const variantClassMap: Record<LabelVariant, string> = {
|
||||
body2: 'ui-body-secondary text-sm',
|
||||
caption: 'ui-kicker text-xs font-semibold uppercase tracking-[0.12em]',
|
||||
error: 'ui-error text-sm',
|
||||
code: 'ui-code text-sm font-mono'
|
||||
code: 'ui-code text-sm font-mono',
|
||||
};
|
||||
|
||||
const variantTagMap: Record<LabelVariant, ElementType> = {
|
||||
@@ -39,14 +30,14 @@ const variantTagMap: Record<LabelVariant, ElementType> = {
|
||||
body2: 'p',
|
||||
caption: 'p',
|
||||
error: 'p',
|
||||
code: 'code'
|
||||
code: 'code',
|
||||
};
|
||||
|
||||
export function Label<T extends ElementType = 'p'>({
|
||||
variant = 'body',
|
||||
as,
|
||||
className = '',
|
||||
children
|
||||
children,
|
||||
}: Readonly<LabelProps<T>>) {
|
||||
const Component = as ?? variantTagMap[variant];
|
||||
const classes = `${variantClassMap[variant]} ${className}`.trim();
|
||||
|
||||
Reference in New Issue
Block a user