diff options
Diffstat (limited to 'src/ui/objects/Dialog.tsx')
| -rw-r--r-- | src/ui/objects/Dialog.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/ui/objects/Dialog.tsx b/src/ui/objects/Dialog.tsx new file mode 100644 index 0000000..8ab6c4f --- /dev/null +++ b/src/ui/objects/Dialog.tsx | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | import type { HTMLAttributes } from "corvos/plugins/jsx.ts"; | ||
| 2 | |||
| 3 | import { Icon } from "$/ui/objects/Icon.tsx"; | ||
| 4 | |||
| 5 | import { Container } from "../layouts/Container.tsx"; | ||
| 6 | import { ActionButton } from "./ActionButton.tsx"; | ||
| 7 | import { Divider } from "./Divider.tsx"; | ||
| 8 | import { Heading } from "./Heading.tsx"; | ||
| 9 | |||
| 10 | export type Props = HTMLAttributes<"dialog"> & { | ||
| 11 | title: string; | ||
| 12 | divider?: boolean; | ||
| 13 | children?: JSX.Element; | ||
| 14 | }; | ||
| 15 | |||
| 16 | export const Dialog = ({ children, title, divider, class: cls, ...props }: Props) => ( | ||
| 17 | <dialog popover="auto" class:list={["o-dialog is-modal", cls]} closedby="any" {...props}> | ||
| 18 | <Container fixed class="o-dialog__content"> | ||
| 19 | <header class="o-dialog__header"> | ||
| 20 | <Heading as="h1" class="u-mbs-0" level="xxl"> | ||
| 21 | {title} | ||
| 22 | </Heading> | ||
| 23 | |||
| 24 | <ActionButton | ||
| 25 | command="close" | ||
| 26 | commandfor={props.id} | ||
| 27 | as="button" | ||
| 28 | pill | ||
| 29 | size="lg" | ||
| 30 | level="quiet" | ||
| 31 | icon={<Icon icon="x" variant="bold" />} | ||
| 32 | class="u-mis-auto" | ||
| 33 | /> | ||
| 34 | </header> | ||
| 35 | |||
| 36 | {divider && <Divider level="faint" class="o-dialog__divider" />} | ||
| 37 | |||
| 38 | <div class="o-dialog__body">{children}</div> | ||
| 39 | </Container> | ||
| 40 | </dialog> | ||
| 41 | ); | ||
