Files

39 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2026-10-05 18:10:18 -04:00
import { CheckCircle2, Info, ShieldAlert, TriangleAlert, type LucideIcon } from 'lucide-react';
import React from 'react';
2026-10-12 09:04:03 -04:00
import { replaceable, useSkin } from '@/themes/skins';
2026-10-05 18:10:18 -04:00
export type AlertType = 'success' | 'info' | 'warning' | 'danger';
2026-10-12 09:04:03 -04:00
export interface AlertProps {
2026-10-05 18:10:18 -04:00
type: AlertType;
title?: React.ReactNode;
className?: string;
children: React.ReactNode;
}
2026-10-12 09:04:03 -04:00
const icons = {
success: CheckCircle2,
info: Info,
warning: TriangleAlert,
danger: ShieldAlert,
} satisfies Record<AlertType, LucideIcon>;
2026-10-05 18:10:18 -04:00
2026-10-12 09:04:03 -04:00
function CoreAlert({ type, title, className, children }: AlertProps) {
const ui = useSkin('Alert', { type });
const AlertIcon = icons[type];
2026-10-05 18:10:18 -04:00
return (
2026-10-12 09:04:03 -04:00
<div role='alert' {...ui('root', className)}>
<AlertIcon aria-hidden {...ui('icon')} />
<div {...ui('body')}>
{title && <p {...ui('title')}>{title}</p>}
<div {...ui('content')}>{children}</div>
2026-10-05 18:10:18 -04:00
</div>
</div>
);
2026-10-05 18:10:18 -04:00
}
2026-10-12 09:04:03 -04:00
const Alert = replaceable('Alert', CoreAlert);
export default Alert;