2025-03-28 14:16:20 +01:00
|
|
|
<script lang="ts">
|
2026-07-30 17:18:46 +02:00
|
|
|
import { fs_node_icon, fs_node_type, fs_encode_path } from "lib/FilesystemAPI.svelte";
|
2025-03-28 14:16:20 +01:00
|
|
|
import type { FSNavigator } from "filesystem/FSNavigator";
|
2025-10-13 23:20:42 +02:00
|
|
|
import { FileAction, type FileActionHandler } from "./FileManagerLib";
|
2022-02-22 19:53:48 +01:00
|
|
|
|
2025-10-13 16:05:50 +02:00
|
|
|
let {
|
|
|
|
|
nav,
|
2025-10-13 23:20:42 +02:00
|
|
|
file_event,
|
2025-10-13 16:05:50 +02:00
|
|
|
show_hidden = false,
|
|
|
|
|
large_icons = false
|
|
|
|
|
}: {
|
2025-10-13 23:20:42 +02:00
|
|
|
nav: FSNavigator
|
|
|
|
|
file_event: FileActionHandler
|
|
|
|
|
show_hidden?: boolean
|
|
|
|
|
large_icons?: boolean
|
2025-10-13 16:05:50 +02:00
|
|
|
} = $props();
|
2022-02-22 19:53:48 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="gallery">
|
2024-08-09 13:02:07 +02:00
|
|
|
{#each $nav.children as child, index (child.path)}
|
2022-02-22 19:53:48 +01:00
|
|
|
<a class="file"
|
2024-08-30 16:17:48 +02:00
|
|
|
href={"/d"+fs_encode_path(child.path)}
|
2025-10-13 23:20:42 +02:00
|
|
|
onclick={e => file_event(FileAction.Click, index, e)}
|
|
|
|
|
oncontextmenu={e => file_event(FileAction.Context, index, e)}
|
2022-02-22 19:53:48 +01:00
|
|
|
class:selected={child.fm_selected}
|
2023-04-19 18:26:50 +02:00
|
|
|
class:hidden={child.name.startsWith(".") && !show_hidden}
|
2023-11-16 19:05:30 +01:00
|
|
|
class:large_icons
|
2022-02-22 19:53:48 +01:00
|
|
|
title={child.name}
|
|
|
|
|
>
|
2026-09-02 00:12:25 +02:00
|
|
|
<img
|
2023-11-16 19:05:30 +01:00
|
|
|
class="node_icon"
|
2023-05-17 15:34:56 +02:00
|
|
|
class:cover={fs_node_type(child) === "image" || fs_node_type(child) === "video"}
|
2026-09-02 00:12:25 +02:00
|
|
|
src={fs_node_icon(child, 256, 256)}
|
|
|
|
|
loading="lazy"
|
|
|
|
|
alt=""
|
|
|
|
|
/>
|
2023-11-16 19:05:30 +01:00
|
|
|
<div class="node_name">
|
|
|
|
|
{child.name}
|
|
|
|
|
</div>
|
2022-02-22 19:53:48 +01:00
|
|
|
</a>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style>
|
2023-11-16 19:05:30 +01:00
|
|
|
.gallery {
|
2022-02-22 19:53:48 +01:00
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
2023-11-16 19:05:30 +01:00
|
|
|
gap: 10px;
|
|
|
|
|
margin: 10px;
|
2022-02-22 19:53:48 +01:00
|
|
|
justify-content: center;
|
|
|
|
|
}
|
2023-11-16 19:05:30 +01:00
|
|
|
.file {
|
|
|
|
|
aspect-ratio: 1;
|
|
|
|
|
width: 150px;
|
|
|
|
|
height: 150px;
|
2026-09-02 00:12:25 +02:00
|
|
|
/* Skips style, layout and paint for nodes which are off-screen. The
|
|
|
|
|
intrinsic size keeps the scrollbar accurate while they're skipped */
|
|
|
|
|
content-visibility: auto;
|
|
|
|
|
contain-intrinsic-size: auto 150px;
|
2022-02-22 19:53:48 +01:00
|
|
|
overflow: hidden;
|
2025-10-13 23:20:42 +02:00
|
|
|
background: var(--body_background);
|
|
|
|
|
/* backdrop-filter: blur(4px); */
|
2025-10-09 15:48:23 +02:00
|
|
|
border-radius: 4px;
|
2024-02-15 18:52:46 +01:00
|
|
|
color: var(--input_text);
|
2023-11-16 19:05:30 +01:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
2022-05-03 14:37:26 +02:00
|
|
|
transition: background 0.2s;
|
2023-11-16 19:05:30 +01:00
|
|
|
text-decoration: none;
|
|
|
|
|
padding: 3px;
|
|
|
|
|
}
|
|
|
|
|
.file.large_icons {
|
|
|
|
|
width: 200px;
|
|
|
|
|
height: 200px;
|
2026-09-02 00:12:25 +02:00
|
|
|
contain-intrinsic-size: auto 200px;
|
2023-11-16 19:05:30 +01:00
|
|
|
}
|
|
|
|
|
|
2023-11-16 19:35:09 +01:00
|
|
|
/* On very small screens we switch to grid layout */
|
2023-11-16 19:05:30 +01:00
|
|
|
@media (max-width: 500px) {
|
|
|
|
|
.gallery {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
|
|
|
|
}
|
|
|
|
|
.file {
|
|
|
|
|
width: unset;
|
|
|
|
|
height: unset;
|
|
|
|
|
max-width: 200px;
|
|
|
|
|
max-height: 200px;
|
|
|
|
|
}
|
|
|
|
|
.file.large_icons {
|
|
|
|
|
width: unset;
|
|
|
|
|
height: unset;
|
|
|
|
|
}
|
2022-02-22 19:53:48 +01:00
|
|
|
}
|
|
|
|
|
.file:hover {
|
2022-05-03 14:37:26 +02:00
|
|
|
background: var(--input_hover_background);
|
2022-02-22 19:53:48 +01:00
|
|
|
}
|
2023-11-16 19:35:09 +01:00
|
|
|
.file.selected {
|
2023-11-16 19:05:30 +01:00
|
|
|
background: var(--highlight_background);
|
|
|
|
|
color: var(--highlight_text_color);
|
2022-02-22 19:53:48 +01:00
|
|
|
}
|
2023-11-16 19:05:30 +01:00
|
|
|
.node_icon {
|
|
|
|
|
flex: 1 1 0;
|
2026-09-02 00:12:25 +02:00
|
|
|
min-height: 0;
|
|
|
|
|
width: 100%;
|
2025-10-09 15:48:23 +02:00
|
|
|
border-radius: 4px;
|
2026-09-02 00:12:25 +02:00
|
|
|
object-fit: contain;
|
2022-02-22 19:53:48 +01:00
|
|
|
}
|
2023-11-16 19:05:30 +01:00
|
|
|
.node_icon.cover {
|
2026-09-02 00:12:25 +02:00
|
|
|
object-fit: cover;
|
2023-05-17 15:34:56 +02:00
|
|
|
}
|
2023-11-16 19:05:30 +01:00
|
|
|
.node_name {
|
|
|
|
|
flex: 0 0 auto;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
line-clamp: 2;
|
|
|
|
|
text-align: center;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
2023-04-19 18:26:50 +02:00
|
|
|
.hidden {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
2022-02-22 19:53:48 +01:00
|
|
|
</style>
|