2022-02-22 19:53:48 +01:00
|
|
|
<script>
|
|
|
|
import { createEventDispatcher } from "svelte"
|
2023-05-30 16:59:11 +02:00
|
|
|
import { fs_encode_path, fs_node_icon, fs_node_type } from "../FilesystemUtil";
|
2022-02-22 19:53:48 +01:00
|
|
|
let dispatch = createEventDispatcher()
|
|
|
|
|
|
|
|
export let state
|
2023-04-19 18:26:50 +02:00
|
|
|
export let show_hidden = false
|
2023-11-16 19:05:30 +01:00
|
|
|
export let large_icons = false
|
2022-02-22 19:53:48 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="gallery">
|
|
|
|
{#each state.children as child, index (child.path)}
|
|
|
|
<a class="file"
|
2023-05-30 16:59:11 +02:00
|
|
|
href={"/d"+fs_encode_path(child.path)}
|
2023-11-16 19:05:30 +01:00
|
|
|
on:click|preventDefault={() => dispatch("node_click", index)}
|
|
|
|
on:contextmenu={e => dispatch("node_context", {event: e, index: index})}
|
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}
|
|
|
|
>
|
|
|
|
<div
|
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"}
|
2023-05-30 15:51:10 +02:00
|
|
|
style='background-image: url("{fs_node_icon(child, 256, 256)}");'>
|
2022-02-22 19:53:48 +01:00
|
|
|
</div>
|
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;
|
2022-02-22 19:53:48 +01:00
|
|
|
overflow: hidden;
|
|
|
|
border-radius: 8px;
|
2022-03-29 21:41:46 +02:00
|
|
|
background: var(--input_background);
|
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;
|
2024-02-16 11:49:38 +01:00
|
|
|
box-shadow: 1px 1px 0px 0px var(--shadow_color);
|
2023-11-16 19:05:30 +01:00
|
|
|
}
|
|
|
|
.file.large_icons {
|
|
|
|
width: 200px;
|
|
|
|
height: 200px;
|
|
|
|
}
|
|
|
|
|
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;
|
2022-10-17 17:48:04 +02:00
|
|
|
border-radius: 6px;
|
2022-02-22 19:53:48 +01:00
|
|
|
background-position: center;
|
|
|
|
background-size: contain;
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
}
|
2023-11-16 19:05:30 +01:00
|
|
|
.node_icon.cover {
|
2023-05-17 15:34:56 +02:00
|
|
|
background-size: cover;
|
|
|
|
}
|
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>
|