import classNames from 'classnames'
import {
Dialog as ReakitDialog,
DialogDisclosure,
DialogBackdrop,
DialogInitialState,
DialogStateReturn,
useDialogState as default_useDialogState,
} from 'reakit'
import CancelIcon from '~/icons/compiled/Cancel'
import RenderMarkdown, { ALLOWED_INLINE_ELEMENTS } from '../RenderMarkdown'
export type IVDialogProps = {
dialog: DialogStateReturn
children: React.ReactNode
canClose?: boolean
widthClassName?: string
backdropClassName?: string
renderChildrenWhileHidden?: boolean
} & (
| {
// One of these props is required for an accessibility title.
// Use `title` to show as the modal header. Use `aria-label` to hide the title.
title: string
'aria-label'?: string
}
| {
title?: string
'aria-label': string
}
)
export function useDialogState(state?: DialogInitialState) {
return default_useDialogState({
...state,
animated: 200,
})
}
// Wraps buttons that open a dialog. Reakit will complain if you don't use these, because
// it can't identify the element to return focus to when you close the dialog.
export function IVDialogDisclosure({
children,
...props
}: DialogStateReturn & { children: React.ReactNode }) {
return (