Skip to content

Commit a0b8d1d

Browse files
refactor: ui for prompts picker (#227)
* refactor: ui for prompts picker * fix: correct the data-source * fix: use position sticky & shadow for dialog scroll
1 parent 6363c3f commit a0b8d1d

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

src/features/workspace/components/workspace-custom-instructions.tsx

+32-25
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Dialog,
99
DialogCloseButton,
1010
DialogContent,
11+
DialogFooter,
1112
DialogHeader,
1213
DialogModal,
1314
DialogModalOverlay,
@@ -20,6 +21,7 @@ import {
2021
SearchField,
2122
SearchFieldClearButton,
2223
Text,
24+
TextLink,
2325
} from "@stacklok/ui-kit";
2426
import {
2527
Dispatch,
@@ -48,11 +50,7 @@ import { useQueryGetWorkspaceCustomInstructions } from "../hooks/use-query-get-w
4850
import { useMutationSetWorkspaceCustomInstructions } from "../hooks/use-mutation-set-workspace-custom-instructions";
4951
import Fuse from "fuse.js";
5052
import systemPrompts from "../constants/built-in-system-prompts.json";
51-
import {
52-
Download01,
53-
MessageTextSquare02,
54-
SearchMd,
55-
} from "@untitled-ui/icons-react";
53+
import { MessageTextSquare02, SearchMd } from "@untitled-ui/icons-react";
5654

5755
type DarkModeContextValue = {
5856
preference: "dark" | "light" | null;
@@ -170,17 +168,20 @@ function PromptPresetPicker({ onActivate }: PromptPresetPickerProps) {
170168
return (
171169
<>
172170
<DialogHeader>
173-
<div className="w-1/3">
174-
<DialogTitle>Choose a prompt template</DialogTitle>
175-
</div>
176-
<div className="w-1/3">
177-
<SearchField
178-
className="w-full max-w-96"
179-
value={query}
180-
onChange={setQuery}
181-
>
171+
<DialogTitle>Choose a prompt template</DialogTitle>
172+
<DialogCloseButton />
173+
</DialogHeader>
174+
<DialogContent className="p-0 relative">
175+
<div
176+
className="bg-base pt-4 px-4 pb-2 mb-2 sticky top-0 z-10"
177+
style={{
178+
boxShadow: "0px 4px 4px 4px var(--bg-base)",
179+
}}
180+
>
181+
<SearchField className="w-full" value={query} onChange={setQuery}>
182182
<FieldGroup>
183183
<Input
184+
isBorderless
184185
icon={<SearchMd />}
185186
placeholder="Type to search"
186187
autoFocus
@@ -189,15 +190,11 @@ function PromptPresetPicker({ onActivate }: PromptPresetPickerProps) {
189190
</FieldGroup>
190191
</SearchField>
191192
</div>
192-
<div className="w-1/3 flex justify-end">
193-
<DialogCloseButton />
194-
</div>
195-
</DialogHeader>
196-
<DialogContent>
197-
<div className="grid grid-flow-row grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4 overflow-auto justify-around ">
193+
194+
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4 px-4 pb-4">
198195
{fuse.search(query.length > 0 ? query : " ").map(({ item }) => {
199196
return (
200-
<Card className=" flex flex-col">
197+
<Card className="min-h-96">
201198
<h2 className="font-bold p-2 flex gap-2 items-center">
202199
<MessageTextSquare02 className="size-4" />
203200
<div className="truncate">{item.name}</div>
@@ -224,21 +221,31 @@ function PromptPresetPicker({ onActivate }: PromptPresetPickerProps) {
224221
</div>
225222
</div>
226223
<Button
227-
isIcon
228224
slot="close"
229225
variant="secondary"
230226
onPress={() => {
231227
handleActivate(item.text);
232228
}}
233229
>
234-
<Download01 />
230+
Use prompt
235231
</Button>
236232
</div>
237233
</Card>
238234
);
239235
})}
240236
</div>
241237
</DialogContent>
238+
<DialogFooter>
239+
<span className="ml-auto">
240+
Prompt templates sourced from{" "}
241+
<TextLink
242+
className="text-primary"
243+
href="https://github.com/PatrickJS/awesome-cursorrules"
244+
>
245+
PatrickJS/awesome-cursorrules
246+
</TextLink>
247+
</span>
248+
</DialogFooter>
242249
</>
243250
);
244251
}
@@ -324,12 +331,12 @@ export function WorkspaceCustomInstructions({
324331
</CardBody>
325332
<CardFooter className="justify-end gap-2">
326333
<DialogTrigger>
327-
<Button>Use a preset</Button>
334+
<Button variant="secondary">Use a preset</Button>
328335
<DialogModalOverlay isDismissable>
329336
<DialogModal isDismissable>
330337
<Dialog
331338
width="lg"
332-
className="flex flex-col p-4 gap-4 "
339+
className="min-h-[44rem]"
333340
style={{ maxWidth: "min(calc(100vw - 64px), 1200px)" }}
334341
>
335342
<PromptPresetPicker

0 commit comments

Comments
 (0)