Files
fnx_web/svelte/src/wrap/Tree.svelte

102 lines
2.3 KiB
Svelte
Raw Normal View History

2026-01-29 23:41:30 +01:00
<script lang="ts">
import { global_navigator } from "filesystem/FSNavigator";
import { fs_encode_path, FSNode } from "lib/FilesystemAPI.svelte";
2026-01-30 12:26:36 +01:00
import { highlight_current_page } from "lib/HighlightCurrentPage";
2026-01-29 23:41:30 +01:00
import { onMount } from "svelte";
let siblings: FSNode[] = $state([])
onMount(() => {
return global_navigator.subscribe(async () => {
siblings = await global_navigator.get_siblings()
})
})
</script>
{#if $global_navigator.path.length > 1}
<div class="title">
<div>Parent directories</div>
<button title="Navigate up" onclick={() => global_navigator.navigate_up()}>
2026-01-30 17:17:03 +01:00
<i class="icon small">north</i>
2026-01-29 23:41:30 +01:00
</button>
</div>
2026-01-30 17:17:03 +01:00
{#each $global_navigator.path.slice(0, $global_navigator.path.length-1) as node (node.id)}
2026-01-29 23:41:30 +01:00
{#if node.type === "dir"}
<div class="row">
<a class="button" href="/d{fs_encode_path(node.path)}">
{#if node.is_shared()}
2026-01-30 12:26:36 +01:00
<i class="icon small">folder_shared</i>
2026-01-29 23:41:30 +01:00
{:else}
2026-01-30 12:26:36 +01:00
<i class="icon small">folder</i>
2026-01-29 23:41:30 +01:00
{/if}
<span>{node.name}</span>
</a>
</div>
{/if}
{/each}
<div class="title"></div>
{/if}
{#if siblings.length !== 0}
<div class="title">
<button title="Open previous sibling" onclick={() => global_navigator.open_sibling(-1)}>
2026-01-30 17:17:03 +01:00
<i class="icon small">west</i>
2026-01-29 23:41:30 +01:00
</button>
<div>Siblings</div>
<button title="Open next sibling" onclick={() => global_navigator.open_sibling(1)}>
2026-01-30 17:17:03 +01:00
<i class="icon small">east</i>
2026-01-29 23:41:30 +01:00
</button>
</div>
2026-01-30 17:17:03 +01:00
{#each siblings as node (node.id)}
2026-01-29 23:41:30 +01:00
{#if !node.is_hidden()}
<div class="row">
2026-01-30 12:26:36 +01:00
<a class="button" href="/d{fs_encode_path(node.path)}" use:highlight_current_page>
{#if node.is_shared()}
<i class="icon small">folder_shared</i>
{:else if node.type === "dir"}
<i class="icon small">folder</i>
2026-01-29 23:41:30 +01:00
{:else}
2026-01-30 12:26:36 +01:00
<i class="icon small">image</i>
2026-01-29 23:41:30 +01:00
{/if}
<span>{node.name}</span>
</a>
</div>
{/if}
{/each}
<div class="title"></div>
{/if}
<style>
.title {
display: flex;
flex-direction: row;
align-items: center;
border-bottom: 1px solid var(--separator);
}
.title > div {
flex: 1 1 auto;
text-align: center;
margin: 3px;
}
.row {
display: flex;
flex-direction: row;
}
.row>a {
flex: 1 1 auto;
}
.row>a>span {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.button {
background: none;
box-shadow: none;
}
</style>