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

119 lines
2.9 KiB
Svelte
Raw Normal View History

<script lang="ts">
2025-01-28 12:00:04 +01:00
import { createEventDispatcher } from "svelte";
import { fs_encode_path, fs_node_icon, node_is_shared } from "filesystem/FilesystemAPI"
import type { FSNavigator } from "filesystem/FSNavigator";
2025-04-30 13:21:11 +02:00
import { FileAction } from "./FileManagerLib";
2025-01-28 12:00:04 +01:00
let dispatch = createEventDispatcher()
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-04-30 13:21:11 +02:00
on:click={e => dispatch("file", {index: index, action: FileAction.Click, original: e})}
on:contextmenu={e => dispatch("file", {index: index, action: FileAction.Context, 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>
{#if node_is_shared(child)}
2025-01-30 00:07:36 +01:00
<a
href="/d/{child.id}"
2025-04-30 13:21:11 +02:00
on:click={e => dispatch("file", {index: index, action: FileAction.Share, 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}
2025-04-30 13:21:11 +02:00
<button
class="action_button flat"
on:click={e => dispatch("file", {index: index, action: FileAction.Edit, original: e})}
>
2025-04-02 15:12:38 +02:00
<i class="icon">edit</i>
</button>
{/if}
2025-04-30 13:21:11 +02:00
<button
class="action_button flat"
on:click={e => dispatch("file", {index: index, action: FileAction.Download, original: e})}
>
<i class="icon">save</i>
</button>
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>