File size: 3,841 Bytes
a8b4b87 | 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | import React from 'react';
import { cn } from '@/lib/utils';
import { Loader2 } from 'lucide-react';
export const Button = React.forwardRef<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement> & { variant?: 'default' | 'outline' | 'ghost' | 'destructive', size?: 'default' | 'sm' | 'lg' | 'icon', isLoading?: boolean }>(
({ className, variant = 'default', size = 'default', isLoading, children, disabled, ...props }, ref) => {
return (
<button
ref={ref}
disabled={disabled || isLoading}
className={cn(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
{
'bg-primary text-primary-foreground shadow hover:bg-primary/90': variant === 'default',
'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground': variant === 'outline',
'hover:bg-accent hover:text-accent-foreground': variant === 'ghost',
'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90': variant === 'destructive',
'h-9 px-4 py-2': size === 'default',
'h-8 rounded-md px-3 text-xs': size === 'sm',
'h-10 rounded-md px-8': size === 'lg',
'h-9 w-9': size === 'icon',
},
className
)}
{...props}
>
{isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
{children}
</button>
);
}
);
Button.displayName = "Button";
export const Input = React.forwardRef<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}
{...props}
/>
);
}
);
Input.displayName = "Input";
export const Select = React.forwardRef<HTMLSelectElement, React.SelectHTMLAttributes<HTMLSelectElement>>(
({ className, ...props }, ref) => {
return (
<select
className={cn(
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}
{...props}
/>
);
}
);
Select.displayName = "Select";
export const Badge = ({ className, variant = 'default', children }: { className?: string, variant?: 'default' | 'active' | 'error' | 'running' | 'success' | 'failed' | 'partial' | 'draft' | 'paused', children: React.ReactNode }) => {
return (
<div className={cn(
"inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors",
{
'bg-secondary text-secondary-foreground': variant === 'default',
'conduit-badge-active': variant === 'active',
'conduit-badge-error': variant === 'error',
'conduit-badge-running': variant === 'running',
'conduit-badge-success': variant === 'success',
'conduit-badge-failed': variant === 'failed',
'conduit-badge-partial': variant === 'partial',
'conduit-badge-draft': variant === 'draft',
'conduit-badge-paused': variant === 'paused',
},
className
)}>
{children}
</div>
);
};
|