import { gloss } from 'gloss' import React, { memo } from 'react' import { Button } from '../buttons/Button' import { Portal } from '../helpers/portal' import { Section, SectionSpecificProps } from '../Section' import { Surface, SurfaceProps } from '../Surface' import { ScrollablePropVal, ViewProps } from '../View/types' import { View } from '../View/View' import { ProvideVisibility } from '../Visibility' export type SimpleModalProps = SectionSpecificProps & SurfaceProps & { open?: boolean onChangeOpen?: (next: boolean) => any closable?: boolean scrollable?: ScrollablePropVal } export type ModalProps = SimpleModalProps & { onClickBackground?: React.MouseEventHandler backgroundProps?: ViewProps children?: React.ReactNode chromeless?: boolean } export const Modal = memo( ({ backgroundProps, onClickBackground, background, children, chromeless, ...props }: ModalProps) => { return ( {/* {props.open && ( )} */} {chromeless && children} {!chromeless && {children}} ) }, ) function SimpleModal({ title, subTitle, scrollable, above, padding, children, open, afterTitle, onChangeOpen, closable, ...props }: SimpleModalProps) { return ( e.stopPropagation()} {...props} >
{afterTitle || null} {!!closable && (
) } const ModalSizedSurface = gloss<{ open?: boolean }, SurfaceProps>(Surface, { opacity: 0, pointerEvents: 'none', conditional: { open: { opacity: 1, pointerEvents: 'auto', }, }, }) const ModalBackground = gloss<{ open?: boolean }, ViewProps>(View, { position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, zIndex: 1000000, justifyContent: 'center', alignItems: 'center', conditional: { open: { pointerEvents: 'auto', }, }, }).theme(({ background, open }) => ({ background: open ? background || 'rgba(0, 0, 0, 0.3)' : 'transparent', }))