-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontrol-button.tsx
More file actions
45 lines (41 loc) · 1.07 KB
/
control-button.tsx
File metadata and controls
45 lines (41 loc) · 1.07 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
36
37
38
39
40
41
42
43
44
45
import { type ElementType } from 'react'
import { forwardRef } from 'react'
import { Badge, Button, Group, Text, type BadgeProps } from '@mantine/core'
import { type IconProps } from '@tabler/icons-react'
type ControlButtonProps = {
onClick: () => void
isActive?: boolean
icon: ElementType<IconProps>
label: string
badgeCount: number
badgeColor?: BadgeProps['color']
}
export const ControlButton = forwardRef<HTMLButtonElement, ControlButtonProps>(
(
{ isActive = false, onClick, icon: Icon, label, badgeCount, badgeColor },
ref
) => {
return (
<Button
ref={ref}
variant={isActive ? 'light' : 'white'}
color="gray"
c="black"
size="xs"
leftSection={<Icon size={14} />}
onClick={onClick}
>
<Group gap={6}>
<Text size="xs" fw={500}>
{label}
</Text>
{badgeCount && (
<Badge variant="light" size="sm" radius="sm" color={badgeColor}>
{badgeCount}
</Badge>
)}
</Group>
</Button>
)
}
)