MCPcopy Create free account
hub / github.com/code-with-antonio/nightcode / Dialog

Function Dialog

packages/cli/src/providers/dialog/index.tsx:66–123  ·  view source on GitHub ↗
({ currentDialog, close }: DialogProps)

Source from the content-addressed store, hash-verified

64};
65
66function Dialog({ currentDialog, close }: DialogProps) {
67 const { isTopLayer } = useKeyboardLayer();
68 const dimensions = useTerminalDimensions();
69 const { colors } = useTheme();
70
71 useKeyboard((key) => {
72 if (!currentDialog || !isTopLayer("dialog")) return;
73
74 if (key.name === "escape") {
75 close();
76 }
77 });
78
79 if (!currentDialog) {
80 return null;
81 }
82
83 const { title, children } = currentDialog;
84
85 return (
86 <box
87 position="absolute"
88 left={0}
89 top={0}
90 width={dimensions.width}
91 height={dimensions.height}
92 justifyContent="center"
93 alignItems="center"
94 backgroundColor={RGBA.fromInts(0, 0, 0, 150)}
95 zIndex={100}
96 onMouseDown={() => close()}
97 >
98 <box
99 width={Math.min(60, dimensions.width - 4)}
100 height="auto"
101 backgroundColor={colors.dialogSurface}
102 paddingX={4}
103 paddingY={1}
104 flexDirection="column"
105 gap={1}
106 onMouseDown={(e) => e.stopPropagation()}
107 >
108 <box
109 paddingBottom={1}
110 flexDirection="row"
111 alignItems="center"
112 justifyContent="space-between"
113 >
114 <text attributes={TextAttributes.BOLD}>{title}</text>
115 <text attributes={TextAttributes.DIM} onMouseDown={() => close()}>
116 esc
117 </text>
118 </box>
119 <box flexGrow={1}>{children}</box>
120 </box>
121 </box>
122 );
123};

Callers

nothing calls this directly

Calls 3

useKeyboardLayerFunction · 0.90
useThemeFunction · 0.90
closeFunction · 0.85

Tested by

no test coverage detected