import React, { HTMLAttributes, useRef } from 'react'; import { BoxSpace, SilkeBox } from '../silke-box'; import { SilkeButton, SilkeButtonSet, SilkeButtonSetProps } from '../silke-button'; import { SilkeIcon } from '../silke-icon'; import { SilkePopover } from '../silke-popover'; import { SilkeTitle } from '../silke-text'; import styles from './silke-modal.scss'; export type SilkeModalProps = { title?: React.ReactNode; children?: React.ReactNode; hide?: boolean; pad?: BoxSpace; size?: 'small' | 'default' | 'large'; rounded?: boolean | 'tiny' | 'small' | 'medium' | 'full'; onBack?: () => void; onClose?: () => void; hideCloseButton?: boolean; contextId?: string; logo?: boolean; gap?: BoxSpace; }; export function SilkeModal({ title, children, pad, rounded, onBack, onClose, hideCloseButton, contextId = 'silke.modal', logo, gap = 'm', size = 'default', ...rest }: SilkeModalProps) { const modalRef = useRef(null); let cl = styles.modal; if (size) cl += ' ' + styles[`-${size}`]; return ( <> {!rest.hide && (
)} e.stopPropagation()} onClick={(e: React.MouseEvent) => e.stopPropagation()} > {(title || (onClose && !hideCloseButton) || onBack || logo) && ( {onBack && ( )} {logo && ( Vev logo )} {title && {title}} {!hideCloseButton && onClose && ( )} )} {children} ); } export function SilkeModalContent({ className, children, ...rest }: HTMLAttributes) { let cl = styles.content; if (className) cl += ' ' + className; return (
{children}
); } export function SilkeModalActions({ children, ...rest }: Omit) { return ( {children} ); }