MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / Modal

Function Modal

apps/web/ui/Modal/index.tsx:15–62  ·  view source on GitHub ↗
({
  className,
  open,
  close,
  children,
  size,
  position,
}: ModalProps)

Source from the content-addressed store, hash-verified

13};
14
15export default function Modal({
16 className,
17 open,
18 close,
19 children,
20 size,
21 position,
22}: ModalProps) {
23 const ref = useRef(null);
24 if (!open) {
25 return null;
26 }
27
28 return (
29 <Portal id="modal-portal">
30 <div className={classNames(styles.modal, className)}>
31 <div
32 className={classNames(styles.overlay, {
33 [styles.full]: size === 'full',
34 })}
35 />
36 <div className={styles.container}>
37 <div
38 className={classNames(styles.center, {
39 [styles.top]: position === 'top',
40 })}
41 onClick={(event) => {
42 if (event.target === ref.current) {
43 close(true);
44 }
45 }}
46 ref={ref}
47 >
48 <div
49 className={classNames(styles.content, {
50 [styles.full]: size === 'full',
51 [styles.lg]: size === 'lg',
52 [styles.xl]: size === 'xl',
53 })}
54 >
55 <div>{children}</div>
56 </div>
57 </div>
58 </div>
59 </div>
60 </Portal>
61 );
62}

Callers

nothing calls this directly

Calls 1

closeFunction · 0.85

Tested by

no test coverage detected