forked from koshikraj/ottopus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbadge.tsx
More file actions
35 lines (31 loc) · 1.16 KB
/
Copy pathbadge.tsx
File metadata and controls
35 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type { HTMLAttributes } from 'react'
import { cn } from '@/lib/cn'
export type Tone = 'neutral' | 'plan' | 'ok' | 'warn' | 'block' | 'coral'
/**
* Tinted background with matching text — never a solid fill with white on it.
* Each pair is the contrast-checked combination from the design tokens.
*/
export const TONE_CLASSES: Record<Tone, string> = {
neutral: 'bg-[var(--ot-surface-3)] text-[var(--ot-text-2)]',
plan: 'bg-[var(--ot-plan-bg)] text-[var(--ot-plan-text)]',
ok: 'bg-[var(--ot-ok-bg)] text-[var(--ot-ok-text)]',
warn: 'bg-[var(--ot-warn-bg)] text-[var(--ot-warn-text)]',
block: 'bg-[var(--ot-block-bg)] text-[var(--ot-block-text)]',
coral: 'bg-[var(--ot-coral-soft)] text-[var(--ot-coral-text)]',
}
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
tone?: Tone
}
export function Badge({ tone = 'neutral', className, ...props }: BadgeProps) {
return (
<span
className={cn(
'inline-flex w-fit items-center gap-1.5 rounded-[var(--ot-radius-pill)]',
'px-2.5 py-1 text-[12px] font-medium leading-none whitespace-nowrap',
TONE_CLASSES[tone],
className,
)}
{...props}
/>
)
}