-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathFilePicker.tsx
More file actions
38 lines (36 loc) · 940 Bytes
/
FilePicker.tsx
File metadata and controls
38 lines (36 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { tw } from "twind";
import { ActionList, ActionMenu } from "@primer/react";
import { TreeNode } from "@githubnext/blocks";
export const FilePicker = ({
files,
onFileSelected,
}: {
files: TreeNode[];
onFileSelected: (path: string) => void;
}) => {
return (
<ActionMenu>
<ActionMenu.Button>+ File</ActionMenu.Button>
<ActionMenu.Overlay>
<ActionList
variant="full"
className={tw(`max-h-[300px] p-1 overflow-y-auto`)}
>
{files.map((file) => {
return (
<ActionList.Item
onSelect={() => {
onFileSelected(file.meta.path);
}}
key={file.path}
className={tw(`text-sm w-full`)}
>
{file.path}
</ActionList.Item>
);
})}
</ActionList>
</ActionMenu.Overlay>
</ActionMenu>
);
};