2025-03-28 14:16:20 +01:00
|
|
|
<script lang="ts">
|
2025-01-28 12:00:04 +01:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2025-03-28 14:16:20 +01:00
|
|
|
import { fs_encode_path, fs_node_icon } from "filesystem/FilesystemAPI"
|
|
|
|
|
import type { FSNavigator } from "filesystem/FSNavigator";
|
2025-01-28 12:00:04 +01:00
|
|
|
|
|
|
|
|
let dispatch = createEventDispatcher()
|
|
|
|
|
|
2025-03-28 14:16:20 +01:00
|
|
|
export let nav: FSNavigator
|
2025-01-28 12:00:04 +01:00
|
|
|
export let show_hidden = false
|
|
|
|
|
export let large_icons = false
|
2025-04-02 15:12:38 +02:00
|
|
|
export let hide_edit = false
|
2025-01-28 12:00:04 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="directory">
|
|
|
|
|
{#each $nav.children as child, index (child.path)}
|
|
|
|
|
<a
|
|
|
|
|
href={"/d"+fs_encode_path(child.path)}
|
2025-03-28 14:16:20 +01:00
|
|
|
on:click|preventDefault={e => dispatch("node_click", {index: index, original: e})}
|
|
|
|
|
on:contextmenu={e => dispatch("node_context", {index: index, original: e})}
|
2025-01-28 12:00:04 +01:00
|
|
|
class="node"
|
|
|
|
|
class:node_selected={child.fm_selected}
|
|
|
|
|
class:hidden={child.name.startsWith(".") && !show_hidden}
|
|
|
|
|
>
|
|
|
|
|
<img src={fs_node_icon(child, 64, 64)} class="node_icon" class:large_icons alt="icon"/>
|
|
|
|
|
<div class="node_name">
|
|
|
|
|
{child.name}
|
|
|
|
|
</div>
|
2025-01-30 00:07:36 +01:00
|
|
|
{#if child.id}
|
|
|
|
|
<a
|
|
|
|
|
href="/d/{child.id}"
|
2025-03-28 14:16:20 +01:00
|
|
|
on:click|preventDefault|stopPropagation={e => {dispatch("node_share_click", {index: index, original: e})}}
|
2025-04-02 15:12:38 +02:00
|
|
|
class="button flat action_button"
|
2025-01-30 00:07:36 +01:00
|
|
|
>
|
|
|
|
|
<i class="icon" title="This file / directory is shared. Click to open public link">share</i>
|
|
|
|
|
</a>
|
|
|
|
|
{/if}
|
2025-04-02 15:12:38 +02:00
|
|
|
|
|
|
|
|
{#if $nav.permissions.write && !hide_edit}
|
|
|
|
|
<button class="action_button flat" on:click|preventDefault|stopPropagation={e => dispatch("node_settings", {index: index, original: e})}>
|
|
|
|
|
<i class="icon">edit</i>
|
|
|
|
|
</button>
|
|
|
|
|
{/if}
|
2025-01-28 12:00:04 +01:00
|
|
|
</a>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.directory {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(20em, 1fr));
|
|
|
|
|
gap: 8px;
|
2025-04-02 15:12:38 +02:00
|
|
|
padding: 8px;
|
2025-01-28 12:00:04 +01:00
|
|
|
max-width: 100%;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
.node {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
color: var(--body_text-color);
|
|
|
|
|
padding: 2px;
|
|
|
|
|
align-items: center;
|
|
|
|
|
background: var(--input_background);
|
|
|
|
|
border-radius: 4px;
|
2025-04-02 15:12:38 +02:00
|
|
|
box-shadow: 1px 1px 8px 0px var(--shadow_color);
|
2025-01-28 12:00:04 +01:00
|
|
|
gap: 6px;
|
|
|
|
|
}
|
|
|
|
|
.node:hover:not(.node_selected) {
|
|
|
|
|
background: var(--input_hover_background);
|
|
|
|
|
color: var(--input_text);
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
}
|
|
|
|
|
.node.node_selected {
|
|
|
|
|
background-color: var(--highlight_color) !important;
|
|
|
|
|
color: var(--highlight_text_color);
|
|
|
|
|
}
|
2025-01-30 00:07:36 +01:00
|
|
|
.node>* {
|
2025-01-28 12:00:04 +01:00
|
|
|
flex: 0 0 content;
|
2025-01-30 00:07:36 +01:00
|
|
|
}
|
|
|
|
|
.node_icon {
|
2025-01-28 12:00:04 +01:00
|
|
|
height: 2em;
|
|
|
|
|
width: 2em;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
.node_name {
|
|
|
|
|
flex: 1 1 content;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
line-height: 1em;
|
|
|
|
|
}
|
|
|
|
|
.hidden {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
2025-04-02 15:12:38 +02:00
|
|
|
.flat {
|
|
|
|
|
background: none;
|
|
|
|
|
color: var(--body_text_color);
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
2025-01-28 12:00:04 +01:00
|
|
|
|
|
|
|
|
/* Large icon mode only supported on wide screens */
|
|
|
|
|
@media (min-width: 500px) {
|
|
|
|
|
.node_icon.large_icons {
|
|
|
|
|
height: 4em;
|
|
|
|
|
width: 4em;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|