summaryrefslogtreecommitdiffhomepage
path: root/packages/console/app/src/component/modal.tsx
blob: d6dc8a3de53ea8857df01af2b19bfc190f6f9b11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { JSX, Show } from "solid-js"
import "./modal.css"

interface ModalProps {
  open: boolean
  onClose: () => void
  title?: string
  children: JSX.Element
}

export function Modal(props: ModalProps) {
  return (
    <Show when={props.open}>
      <div data-component="modal" data-slot="overlay" onClick={props.onClose}>
        <div data-slot="content" onClick={(e) => e.stopPropagation()}>
          <Show when={props.title}>
            <h2 data-slot="title">{props.title}</h2>
          </Show>
          {props.children}
        </div>
      </div>
    </Show>
  )
}