MogensR commited on
Commit
04e54a9
·
1 Parent(s): e81fbd9

Create web/src/components/ui/button.tsx

Browse files
web/web/src/components/ui/button.tsx ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as React from 'react'
2
+ import { Slot } from '@radix-ui/react-slot'
3
+ import { cva, type VariantProps } from 'class-variance-authority'
4
+ import { cn } from '@/lib/utils'
5
+
6
+ const buttonVariants = cva(
7
+ 'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: 'bg-purple-600 text-white hover:bg-purple-700',
12
+ destructive: 'bg-red-600 text-white hover:bg-red-700',
13
+ outline: 'border border-gray-700 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-white',
14
+ secondary: 'bg-gray-800 text-gray-300 hover:bg-gray-700 hover:text-white',
15
+ ghost: 'text-gray-300 hover:bg-gray-800 hover:text-white',
16
+ link: 'text-purple-400 underline-offset-4 hover:underline',
17
+ },
18
+ size: {
19
+ default: 'h-10 px-4 py-2',
20
+ sm: 'h-9 rounded-md px-3',
21
+ lg: 'h-11 rounded-md px-8',
22
+ icon: 'h-10 w-10',
23
+ },
24
+ },
25
+ defaultVariants: {
26
+ variant: 'default',
27
+ size: 'default',
28
+ },
29
+ }
30
+ )
31
+
32
+ export interface ButtonProps
33
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
34
+ VariantProps<typeof buttonVariants> {
35
+ asChild?: boolean
36
+ }
37
+
38
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
39
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
40
+ const Comp = asChild ? Slot : 'button'
41
+ return (
42
+ <Comp
43
+ className={cn(buttonVariants({ variant, size, className }))}
44
+ ref={ref}
45
+ {...props}
46
+ />
47
+ )
48
+ }
49
+ )
50
+ Button.displayName = 'Button'
51
+
52
+ export { Button, buttonVariants }