Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

Text.tsx

49 lines1.1 KB

1import type { TextProps } from '@/lib/reports/types'
2​
3const variantClasses = {
4 h1: 'text-3xl font-bold',
5 h2: 'text-2xl font-semibold',
6 h3: 'text-xl font-semibold',
7 body: 'text-base',
8 caption: 'text-sm',
9 code: 'font-mono text-sm bg-sky-100/60 text-slate-700 px-1.5 py-0.5 rounded border border-sky-200/50',
11​
12const colorClasses = {
13 default: 'text-[var(--report-text)]',
14 muted: 'text-[var(--report-text-muted)]',
15 accent: 'text-[var(--report-accent)]',
16 success: 'text-[var(--report-success)]',
17 warning: 'text-[var(--report-warning)]',
18 error: 'text-[var(--report-error)]',
20​
21const alignClasses = {
22 left: 'text-left',
23 center: 'text-center',
24 right: 'text-right',
26​
27export function Text({
28 content,
29 variant = 'body',
30 color = 'default',
31 align = 'left',
32}: TextProps) {
33 const Tag =
34 variant === 'h1'
35 ? 'h1'
36 : variant === 'h2'
37 ? 'h2'
38 : variant === 'h3'
39 ? 'h3'
40 : 'p'
41​
42 return (
43 <Tag
44 className={`${variantClasses[variant]} ${colorClasses[color]} ${alignClasses[align]}`}
45 >
46 {content}
47 </Tag>
48 )