2025-03-02 13:35:38 +08:00
|
|
|
import { cva, VariantProps } from 'class-variance-authority';
|
|
|
|
import React from 'react';
|
|
|
|
import { cn } from '@/lib/classMerge';
|
|
|
|
import { Text } from '../typography';
|
|
|
|
import { Xmark } from '../icons';
|
|
|
|
|
2025-03-05 02:44:32 +08:00
|
|
|
const statusVariants = cva('shadow p-3 rounded', {
|
2025-03-02 13:35:38 +08:00
|
|
|
variants: {
|
|
|
|
variant: {
|
|
|
|
danger: 'bg-danger-foreground text-white',
|
2025-03-26 06:28:07 +08:00
|
|
|
default: 'bg-background text-foreground border'
|
2025-03-02 13:35:38 +08:00
|
|
|
}
|
2025-03-26 06:28:07 +08:00
|
|
|
},
|
|
|
|
defaultVariants: {
|
|
|
|
variant: 'default'
|
2025-03-02 13:35:38 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2025-03-05 02:44:32 +08:00
|
|
|
export const StatusCard: React.FC<
|
2025-03-02 13:35:38 +08:00
|
|
|
{
|
2025-03-05 02:44:32 +08:00
|
|
|
message: string;
|
2025-03-02 13:35:38 +08:00
|
|
|
title?: string;
|
|
|
|
className?: string;
|
|
|
|
onClose?: () => void;
|
2025-03-05 02:44:32 +08:00
|
|
|
extra?: React.ReactNode;
|
|
|
|
} & VariantProps<typeof statusVariants>
|
2025-03-26 06:28:07 +08:00
|
|
|
> = ({ message, title, variant = 'default', className, onClose, extra }) => {
|
2025-03-02 13:35:38 +08:00
|
|
|
return (
|
2025-03-05 02:44:32 +08:00
|
|
|
<div className={cn('flex flex-col gap-1', statusVariants({ variant }), className)}>
|
2025-03-02 13:35:38 +08:00
|
|
|
{title && <Text variant={'inherit'}>{title}</Text>}
|
|
|
|
<Text
|
|
|
|
className={cn(
|
|
|
|
variant === 'danger' && 'text-white',
|
|
|
|
variant === 'default' && 'text-text-secondary',
|
|
|
|
'leading-[1.3]'
|
|
|
|
)}>
|
2025-03-05 02:44:32 +08:00
|
|
|
{message}
|
2025-03-02 13:35:38 +08:00
|
|
|
</Text>
|
2025-03-05 02:44:32 +08:00
|
|
|
|
|
|
|
{extra && extra}
|
2025-03-02 13:35:38 +08:00
|
|
|
{onClose && (
|
|
|
|
<div onClick={onClose} className="absolute top-2 right-2">
|
|
|
|
<Xmark />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|