Skip to content

Commit 9f4bb04

Browse files
committed
Factor Badge out into its own thing.
1 parent 438b373 commit 9f4bb04

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { VariantProps } from 'class-variance-authority'
2+
import { twMerge } from 'tailwind-merge'
3+
import { statBadge, typeIcons } from '@/components/design'
4+
5+
export type BadgeProps = VariantProps<typeof statBadge> & {
6+
type: keyof typeof typeIcons
7+
text?: number | string
8+
}
9+
10+
const Badge = ({ text, type }: BadgeProps) => {
11+
const Icon = typeIcons[type]
12+
return (
13+
<span
14+
className={twMerge(
15+
statBadge({
16+
type,
17+
}),
18+
)}
19+
>
20+
{type === 'blank' || <Icon className='w-3 h-3' />}
21+
{text || type}
22+
</span>
23+
)
24+
}
25+
26+
export default Badge

browser-extension/tests/playground/claude.tsx

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,13 @@
1-
import type { VariantProps } from 'class-variance-authority'
21
import { Eye, EyeOff, Search, Settings, Trash2 } from 'lucide-react'
32
import { useMemo, useState } from 'react'
43
import { twMerge } from 'tailwind-merge'
4+
import Badge from '@/components/Badge'
55
import { statBadge, typeIcons } from '@/components/design'
66
import type { CommentTableRow } from '@/entrypoints/background'
77
import type { FilterState } from '@/entrypoints/popup/popup'
88
import { EnhancerRegistry } from '@/lib/registries'
99
import { generateMockDrafts } from './replicaData'
1010

11-
// StatBadge component
12-
export type BadgeProps = VariantProps<typeof statBadge> & {
13-
type: keyof typeof typeIcons
14-
text?: number | string
15-
}
16-
17-
const Badge = ({ text, type }: BadgeProps) => {
18-
const Icon = typeIcons[type]
19-
return (
20-
<span
21-
className={twMerge(
22-
statBadge({
23-
type,
24-
}),
25-
)}
26-
>
27-
{type === 'blank' || <Icon className='w-3 h-3' />}
28-
{text || type}
29-
</span>
30-
)
31-
}
32-
3311
interface Segment<T> {
3412
text?: string
3513
type: keyof typeof typeIcons

0 commit comments

Comments
 (0)