-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathFileTreeItem.astro
58 lines (49 loc) · 1.43 KB
/
FileTreeItem.astro
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
---
import Icon from "./Icon.astro";
import Tooltip from "./Tooltip.astro";
const TYPE_ICONS = {file: "file", code: "file-code", image: "file-image", directory: "folder"}
const {name, type, open, gitignored} = Astro.props;
const icon = TYPE_ICONS[type];
if (icon === undefined) {
throw new Error(`Invalid file tree item type: ${type}`);
}
export interface Props {
/** Name of the file */
name: string;
/** Type of the entry. This dictates the icon that will be used */
type: "file" | "code" | "image" | "directory";
/** Whether it is ignored and should have a little "blocked" icon next to it. Defaults to false. */
gitignored?: boolean
/** Whether this element should be open/expanded by default. Defaults to false. */
open?: boolean;
}
---
<details class="file-tree-item" open={open}>
<summary>
<Icon name={icon} group="solid"/>
{name}
{gitignored && <Tooltip content="Git ignored" placement="right"><Icon name="ban" group="solid"/></Tooltip>}
</summary>
<slot/>
</details>
<style lang="scss">
details.file-tree-item {
summary {
list-style: none;
margin-left: 1em;
:global(i.fa-solid) {
margin-right: 0.5em;
}
:global(i.fa-ban) {
margin: 0px 0px 0px 1em;
}
}
:global(p) {
margin-top: 0px;
margin-bottom: 0px;
}
& > :global(*) {
margin-left: 2em;
}
}
</style>