Files
fnx_web/svelte/src/filesystem/filemanager/GalleryView.svelte

79 lines
1.7 KiB
Svelte
Raw Normal View History

2022-02-22 19:53:48 +01:00
<script>
import { createEventDispatcher } from "svelte"
import { 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
2022-02-22 19:53:48 +01:00
</script>
<div class="gallery">
{#each state.children as child, index (child.path)}
<a class="file"
2023-04-19 19:47:08 +02:00
href={state.path_root+child.path_uri}
2022-02-22 19:53:48 +01:00
on:click|preventDefault={() => {dispatch("node_click", index)}}
class:selected={child.fm_selected}
2023-04-19 18:26:50 +02:00
class:hidden={child.name.startsWith(".") && !show_hidden}
2022-02-22 19:53:48 +01:00
title={child.name}
>
<div
class="icon_container"
class:cover={fs_node_type(child) === "image" || fs_node_type(child) === "video"}
style='background-image: url("{fs_node_icon(child, 256, 256)}");'>
2022-02-22 19:53:48 +01:00
</div>
{child.name}
</a>
{/each}
</div>
<style>
.gallery{
padding: 16px;
overflow: hidden;
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.file{
2022-05-03 14:37:26 +02:00
width: 200px;
max-width: 42%;
2022-05-03 14:37:26 +02:00
height: 200px;
2022-02-22 19:53:48 +01:00
margin: 8px;
overflow: hidden;
border-radius: 8px;
2022-03-29 21:41:46 +02:00
background: var(--input_background);
2022-05-03 14:37:26 +02:00
word-break: break-all;
2022-02-22 19:53:48 +01:00
text-align: center;
line-height: 1.2em;
display: inline-block;
text-overflow: ellipsis;
text-decoration: none;
vertical-align: top;
2022-03-29 21:41:46 +02:00
color: var(--body_text_color);
2022-05-03 14:37:26 +02:00
transition: background 0.2s;
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
}
.selected {
2022-05-03 14:37:26 +02:00
box-shadow: 0 0 2px 2px var(--highlight_color);
text-decoration: none;
2022-02-22 19:53:48 +01:00
}
.icon_container {
margin: 3px;
height: 148px;
border-radius: 6px;
2022-02-22 19:53:48 +01:00
background-position: center;
background-size: contain;
background-repeat: no-repeat;
font-size: 22px;
text-align: left;
}
.icon_container.cover {
background-size: cover;
}
2023-04-19 18:26:50 +02:00
.hidden {
display: none;
}
2022-02-22 19:53:48 +01:00
</style>