diff --git a/components/Dialog.tsx b/components/Dialog.tsx new file mode 100644 index 0000000..d7fb690 --- /dev/null +++ b/components/Dialog.tsx @@ -0,0 +1,44 @@ +import { createRef, JSX } from 'preact' +import { Button } from '@homeman/components/Button.tsx' +import { useEffect } from 'preact/hooks' + +interface Props extends JSX.HTMLAttributes { + headerTitle: string + show?: boolean +} + +export function Dialog( + { show, headerTitle, children, className, ...props }: Props, +) { + const self = createRef() + + useEffect(() => { + if (show) { + self.current?.showModal() + } else { + self.current?.close() + } + return () => { + // cleanup + } + }, [show]) + + return ( + +
+

{headerTitle}

+ +
+ {children} +
+ ) +} diff --git a/components/Nav.tsx b/components/Nav.tsx index 09a4cf3..06b0ca8 100644 --- a/components/Nav.tsx +++ b/components/Nav.tsx @@ -1,26 +1,14 @@ // import { JSX } from 'preact' // import { IS_BROWSER } from '$fresh/runtime.ts' +import { Bars3Outline } from 'preact-heroicons' import { Clock } from '@homeman/islands/Clock.tsx' export function Nav(/* props: {} */) { return (