Repository navigation
Expand file tree
/
Copy pathdocument-controls.tsx
More file actions
57 lines (56 loc) · 1.9 KB
/
Copy pathdocument-controls.tsx
File metadata and controls
57 lines (56 loc) · 1.9 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
import { splitTitleIcon } from "@web/shared/utils/resource-title.js";
import { BookOpen, FileText, FileCode2, Table2, Presentation, SquarePen } from "lucide-react";
import { Select } from "@web/shared/components/select.js";
import { useI18n } from "@web/shared/i18n.js";
import type { Resource } from "@web/shared/api.js";
import "@web/features/documents/document-icons.css";
import "./resource-metadata.css";
export function FileIcon({ r, size = "regular" }: {
r: Pick<Resource, "kind"> & { format?: Resource["format"] | null; title?: string };
size?: "regular" | "compact";
}) {
const icon = r.title ? splitTitleIcon(r.title).icon : null;
if (icon) return <span className={`file-glyph title-emoji${size === "compact" ? " compact" : ""}`} aria-hidden="true">{icon}</span>;
const Icon =
r.kind === "library"
? BookOpen
: r.format === "spreadsheet"
? Table2
: r.format === "canvas"
? SquarePen
: r.format === "presentation"
? Presentation
: r.format === "markdown"
? FileCode2
: FileText;
return (
<span
className={"file-glyph " + (r.kind === "library" ? "library" : r.format) + (size === "compact" ? " compact" : "")}
aria-hidden="true"
>
<Icon size={size === "compact" ? 15 : 19} />
</span>
);
}
export function TypeFilter({
value,
change,
}: {
value: string;
change: (v: string) => void;
}) {
const { t } = useI18n();
return (
<Select
aria-label={t("doc.filterType")}
value={value}
onChange={(e) => change(e.target.value)}
>
<option value="">{t("doc.filter.all")}</option>
<option value="rich_text">{t("shell.type.rich")}</option>
<option value="spreadsheet">{t("shell.type.sheet")}</option>
<option value="presentation">{t("shell.type.slides")}</option>
<option value="markdown">{t("shell.type.markdown")}</option>
</Select>
);
}