This repository was archived by the owner on Jun 19, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathSearchedContributorsTable.tsx
More file actions
91 lines (87 loc) · 3.25 KB
/
SearchedContributorsTable.tsx
File metadata and controls
91 lines (87 loc) · 3.25 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { CheckedState } from "@radix-ui/react-checkbox";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "components/shared/Table";
import { Avatar } from "components/atoms/Avatar/avatar-hover-card";
import Checkbox from "components/atoms/Checkbox/checkbox";
import Search from "components/atoms/Search/search";
interface SearchedContributorsTableProps {
type: "by-contributors" | "by-org";
contributors: Map<string, boolean>;
onFilter: (filterTerm: string) => void;
onToggleContributor: (contributor: string, checked: boolean) => void;
onToggleAllContributors: (checked: boolean) => void;
}
export const SearchedContributorsTable = ({
type,
contributors = new Map(),
onFilter,
onToggleContributor,
onToggleAllContributors,
}: SearchedContributorsTableProps) => {
const allChecked = [...contributors.values()].every((checked) => checked);
return (
<div className="border border-light-slate-7 rounded-lg">
<Table className="not-sr-only">
<TableHeader>
<TableRow className="bg-light-slate-3">
<TableHead className="flex justify-between items-center gap-6">
<div className="flex gap-2">
<Checkbox
onCheckedChange={(checked: CheckedState) => {
onToggleAllContributors(!!checked);
}}
checked={allChecked}
label={type === "by-contributors" ? "Selected contributors" : "Selected organization contributors"}
/>
</div>
<form
className="pr-2"
role="search"
onSubmit={(event) => {
event.preventDefault;
}}
>
<Search
placeholder="Filter contributors"
labelText="Filter contributors from the list"
className="w-full"
name="query"
onChange={onFilter}
/>
</form>
</TableHead>
</TableRow>
</TableHeader>
</Table>
<div className="overflow-y-scroll h-60">
<Table>
<TableHeader className="sr-only">
<TableRow className=" bg-light-slate-3">
<TableHead>Selected contributors</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{[...contributors.entries()].map(([contributor, checked]) => {
const [owner] = contributor.split("/");
return (
<TableRow key={contributor}>
<TableCell className="flex gap-2 items-center w-full">
<label className="flex items-center gap-2">
<Checkbox
onCheckedChange={(checked: CheckedState) => {
onToggleContributor(contributor, !!checked);
}}
checked={checked}
/>
<Avatar contributor={owner} size="xsmall" />
<span>{contributor}</span>
</label>
</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</div>
</div>
);
};