diff --git a/.changeset/funny-turtles-shout.md b/.changeset/funny-turtles-shout.md new file mode 100644 index 00000000..6a2fd212 --- /dev/null +++ b/.changeset/funny-turtles-shout.md @@ -0,0 +1,5 @@ +--- +"@tszhong0411/ui": patch +--- + +update alert component diff --git a/packages/ui/src/alert.tsx b/packages/ui/src/alert.tsx index 255a4dcd..79649fab 100644 --- a/packages/ui/src/alert.tsx +++ b/packages/ui/src/alert.tsx @@ -1,32 +1,38 @@ import { cn } from '@tszhong0411/utils' import { cva, type VariantProps } from 'class-variance-authority' +import { AlertOctagonIcon, AlertTriangleIcon, InfoIcon } from 'lucide-react' import * as React from 'react' export const alertVariants = cva( - 'flex w-full justify-start gap-4 rounded-lg border p-4', + 'my-6 flex flex-row gap-2 rounded-lg border bg-card p-3 text-sm text-muted-foreground shadow-md', { variants: { variant: { - default: '', - danger: 'border-red-200/30 bg-red-900/30 text-red-200', + error: 'border-red-200/30 bg-red-900/30 text-red-200', info: 'border-blue-200/30 bg-blue-900/30 text-blue-200', warning: 'border-yellow-200/30 bg-yellow-700/30 text-yellow-200' } }, defaultVariants: { - variant: 'default' + variant: 'info' } } ) -type AlertProps = { - icon?: React.ReactNode -} & React.HTMLAttributes & +type AlertProps = { title?: string } & React.HTMLAttributes & VariantProps export const Alert = React.forwardRef( (props, ref) => { - const { variant, className, icon, children, ...rest } = props + const { variant, className, title, children, ...rest } = props + + const icons = { + info: , + warning: ( + + ), + error: + } return (
( className={cn(alertVariants({ variant, className }))} {...rest} > -
{icon}
-
{children}
+ {variant ? icons[variant] : icons['info']} +
+ {title ? ( +
{title}
+ ) : null} +
{children}
+
) }