import type { ComponentProps, ReactNode } from 'react'; import React from 'react'; import cx from 'classnames'; import { Dialog as AriakitDialog, DialogDismiss as AriakitDialogDismiss } from 'ariakit/dialog'; import { Stack } from '../../layout/stack'; import { BUTTON_GLYPHS, Button } from '../button'; import css from './dialog.module.css'; export { useDialogState } from 'ariakit/dialog'; type AriakitDialogProps = ComponentProps; type DialogProps = { title?: ReactNode; width?: 'narrow' | 'medium' | 'wide' | 'extra-wide'; center?: boolean; modal?: AriakitDialogProps['modal']; state: AriakitDialogProps['state']; } & Omit, 'title'>; export const Dialog = (props: DialogProps) => { const { state, className = '', title = '', width = 'medium', center = false, modal = false, children, } = props; const rootClassName = cx(css.dialog, width && css[`width--${width}`], center && css.center); return ( {!modal && ( {/* null content to prevent DialogDismiss to render the default "x" */} {null} )} {title && (
{typeof title === 'string' ?

{title}

: title}
)}
{children}
); };