Files
fnx_web/svelte/src/filesystem/filemanager/CompactView.svelte
T

115 lines
2.5 KiB
Svelte
Raw Normal View History

<script lang="ts">
import { fs_encode_path, fs_node_icon } from "lib/FilesystemAPI.svelte"
2026-10-02 15:10:34 +02:00
import { move_target, type FSNavigator } from "filesystem/FSNavigator";
import { FileAction, type FileActionHandler } from "./FileManagerLib";
2025-01-28 12:00:04 +01:00
2025-10-13 16:05:50 +02:00
let {
nav,
file_event,
2025-10-13 16:05:50 +02:00
show_hidden = false,
large_icons = false,
hide_edit = false
}: {
nav: FSNavigator;
file_event: FileActionHandler
show_hidden?: boolean
large_icons?: boolean
hide_edit?: boolean
2025-10-13 16:05:50 +02:00
} = $props();
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)}
onclick={e => file_event(FileAction.Click, index, e)}
oncontextmenu={e => file_event(FileAction.Context, index, e)}
2026-10-02 15:10:34 +02:00
ondragstart={e => file_event(FileAction.Drag, index, e)}
use:move_target={{nav, node: () => child}}
2025-01-28 12:00:04 +01:00
class="node"
2026-10-02 15:10:34 +02:00
class:node_selected={$nav.selection.has(child.path)}
2025-01-28 12:00:04 +01:00
class:hidden={child.name.startsWith(".") && !show_hidden}
>
2026-10-02 15:10:34 +02:00
<img src={fs_node_icon(child, 64, 64)} class="node_icon" class:large_icons loading="lazy" alt="icon" draggable="false"/>
2025-01-28 12:00:04 +01:00
<div class="node_name">
{child.name}
</div>
2025-10-13 16:05:50 +02:00
{#if child.is_shared()}
2025-10-13 16:05:50 +02:00
<i class="icon" title="This file / directory is shared. Click to open public link">share</i>
2025-01-30 00:07:36 +01:00
{/if}
2025-04-02 15:12:38 +02:00
2025-10-09 15:48:23 +02:00
{#if !hide_edit}
2025-04-30 13:21:11 +02:00
<button
class="action_button flat"
onclick={e => file_event(FileAction.Menu, index, e)}
2025-04-30 13:21:11 +02:00
>
2025-10-09 15:48:23 +02:00
<i class="icon">menu</i>
2025-04-30 13:21:11 +02:00
</button>
2025-10-09 15:48:23 +02:00
{/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;
2026-10-01 02:06:00 +02:00
color: var(--body_text_color);
2025-01-28 12:00:04 +01:00
padding: 2px;
align-items: center;
background: var(--body_background);
2025-01-28 12:00:04 +01:00
border-radius: 4px;
gap: 6px;
content-visibility: auto;
contain-intrinsic-size: auto 2.4em;
2025-01-28 12:00:04 +01:00
}
.node:hover:not(.node_selected) {
background: var(--input_hover_background);
color: var(--input_text);
text-decoration: none;
}
.node.node_selected {
2026-10-01 02:06:00 +02:00
background-color: var(--accent_color) !important;
color: var(--accent_text_color);
2025-01-28 12:00:04 +01:00
}
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;
}
.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>