import React, { useRef } from 'react'; import { BoxDivProps, SilkeBox } from '../silke-box'; import { SilkeButton } from '../silke-button'; import { SilkeIcon, SilkeIcons } from '../silke-icon'; import { SilkeText } from '../silke-text'; import styles from './silke-alert-banner.scss'; export type AlertBannerKind = 'warning' | 'error' | 'success' | 'information'; export type SilkeAlertBannerProps = { kind: AlertBannerKind; title?: string | React.ReactNode; subtitle?: string | React.ReactNode; icon?: SilkeIcons; /** * Will add a remove button to notification */ onRemove?: (e: React.MouseEvent) => void; /** * On click of action button * */ onAction?: () => void; actionLabel?: string; fluid?: boolean; } & Omit; const ICON_KIND: Record = { warning: 'error.triangle', error: 'ban', success: 'check.circle.outline', information: 'tooltip', }; export function SilkeAlertBanner({ title, subtitle, className, kind = 'information', onAction, actionLabel, onRemove, fluid = false, icon, ...rest }: SilkeAlertBannerProps) { const cl: string[] = [styles.notificationBox]; const iconRef = useRef(); if (className) cl.push(className); if (kind) cl.push(styles[kind]); if (fluid) cl.push(styles.fluid); return ( {title && {title}} {subtitle && {subtitle}} {onAction && ( )} {onRemove && ( )} ); }