MCPcopy Create free account
hub / github.com/dailydotdev/apps / PromptElement

Function PromptElement

packages/shared/src/components/modals/Prompt.tsx:20–94  ·  view source on GitHub ↗
(props: Partial<ModalProps>)

Source from the content-addressed store, hash-verified

18);
19
20export function PromptElement(props: Partial<ModalProps>): ReactElement | null {
21 const { prompt } = usePrompt();
22 if (!prompt || !prompt.options) {
23 return null;
24 }
25 const { options } = prompt;
26 const { onFail, onSuccess } = prompt;
27 const {
28 title,
29 description,
30 icon,
31 content,
32 promptSize = Modal.Size.Small,
33 cancelButton = {},
34 okButton = {},
35 className = {},
36 shouldCloseOnOverlayClick,
37 } = options;
38 return (
39 <Modal
40 isOpen
41 kind={Modal.Kind.FlexibleCenter}
42 size={promptSize}
43 onRequestClose={onFail}
44 className={className.modal}
45 overlayClassName="!z-max"
46 isDrawerOnMobile
47 drawerProps={{ displayCloseButton: false, appendOnRoot: true }}
48 shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
49 {...props}
50 >
51 <Modal.Body>
52 {icon && <div className="mx-auto mb-2">{icon}</div>}
53 <Title className={className.title}>{title}</Title>
54 {!!description && (
55 <Description className={className.description}>
56 {description}
57 </Description>
58 )}
59 {content}
60 <Buttons className={className.buttons}>
61 {cancelButton !== null && (
62 <Button
63 variant={cancelButton.variant ?? ButtonVariant.Secondary}
64 color={cancelButton.color}
65 icon={cancelButton.icon}
66 iconPosition={cancelButton.iconPosition}
67 onClick={onFail}
68 {...cancelButton}
69 className={classNames(
70 'w-full tablet:w-auto',
71 cancelButton.className,
72 )}
73 >
74 {cancelButton?.title ?? 'Cancel'}
75 </Button>
76 )}
77 {okButton !== null && (

Callers

nothing calls this directly

Calls 1

usePromptFunction · 0.90

Tested by

no test coverage detected