2025-03-28 14:16:20 +01:00
|
|
|
<script lang="ts">
|
2023-05-17 15:34:56 +02:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2025-10-13 16:05:50 +02:00
|
|
|
import { copy_text } from "util/Util";
|
2023-05-19 21:45:42 +02:00
|
|
|
import FileStats from "./FileStats.svelte";
|
2025-03-28 14:16:20 +01:00
|
|
|
import type { FSNavigator } from "./FSNavigator";
|
|
|
|
import EditWindow from "./edit_window/EditWindow.svelte";
|
2025-10-10 00:12:14 +02:00
|
|
|
import { fs_share_url, path_is_shared } from "lib/FilesystemAPI";
|
2025-06-05 21:29:07 +02:00
|
|
|
import ShareDialog from "./ShareDialog.svelte";
|
2025-10-10 00:12:14 +02:00
|
|
|
import { bookmark_add, bookmark_del, bookmarks_store, is_bookmark } from "lib/Bookmarks";
|
2023-05-17 15:34:56 +02:00
|
|
|
|
|
|
|
let dispatch = createEventDispatcher()
|
|
|
|
|
2025-10-13 16:05:50 +02:00
|
|
|
let {
|
|
|
|
nav = $bindable(),
|
|
|
|
details_visible = $bindable(false),
|
|
|
|
edit_window,
|
|
|
|
edit_visible = $bindable(false)
|
|
|
|
}: {
|
|
|
|
nav: FSNavigator;
|
|
|
|
details_visible?: boolean;
|
|
|
|
edit_window: EditWindow;
|
|
|
|
edit_visible?: boolean;
|
|
|
|
} = $props();
|
|
|
|
|
|
|
|
let share_dialog: ShareDialog = $state()
|
|
|
|
let link_copied = $state(false)
|
2023-11-16 12:17:36 +01:00
|
|
|
export const copy_link = () => {
|
2025-10-10 00:12:14 +02:00
|
|
|
const share_url = fs_share_url($nav.path)
|
2023-05-17 19:27:46 +02:00
|
|
|
if (share_url === "") {
|
2024-08-09 13:02:07 +02:00
|
|
|
edit_window.edit(nav.base, true, "share")
|
2023-05-17 19:27:46 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_text(share_url)
|
|
|
|
link_copied = true
|
|
|
|
setTimeout(() => {link_copied = false}, 60000)
|
|
|
|
}
|
2023-05-17 15:34:56 +02:00
|
|
|
</script>
|
|
|
|
|
2025-10-09 15:48:23 +02:00
|
|
|
<div class="toolbar">
|
2023-11-15 15:50:54 +01:00
|
|
|
<div class="grid">
|
2025-10-09 15:48:23 +02:00
|
|
|
<FileStats nav={nav}/>
|
2023-11-15 15:50:54 +01:00
|
|
|
|
|
|
|
<div class="button_row">
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={() => {nav.open_sibling(-1)}}>
|
2023-11-15 15:50:54 +01:00
|
|
|
<i class="icon">skip_previous</i>
|
|
|
|
</button>
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={() => {nav.shuffle = !nav.shuffle}} class:button_highlight={nav.shuffle}>
|
2023-11-15 15:50:54 +01:00
|
|
|
<i class="icon">shuffle</i>
|
|
|
|
</button>
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={() => {nav.open_sibling(1)}}>
|
2023-11-15 15:50:54 +01:00
|
|
|
<i class="icon">skip_next</i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={() => dispatch("download")}>
|
2024-05-08 18:29:59 +02:00
|
|
|
<i class="icon">save</i>
|
|
|
|
<span>Download</span>
|
|
|
|
</button>
|
2023-11-15 15:50:54 +01:00
|
|
|
|
2025-10-10 00:12:14 +02:00
|
|
|
{#if is_bookmark($bookmarks_store, $nav.base.id)}
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={() => bookmark_del($nav.base.id)}>
|
2025-10-10 00:12:14 +02:00
|
|
|
<i class="icon">bookmark_remove</i>
|
|
|
|
<span>Bookmark</span>
|
|
|
|
</button>
|
|
|
|
{:else}
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={() => bookmark_add($nav.base)}>
|
2025-10-10 00:12:14 +02:00
|
|
|
<i class="icon">bookmark_add</i>
|
|
|
|
<span>Bookmark</span>
|
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if path_is_shared($nav.path)}
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={copy_link} class:button_highlight={link_copied}>
|
2023-11-16 12:17:36 +01:00
|
|
|
<i class="icon">content_copy</i>
|
2025-06-05 21:29:07 +02:00
|
|
|
<span><u>C</u>opy link</span>
|
2023-11-15 15:50:54 +01:00
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
|
2024-09-05 14:58:26 +02:00
|
|
|
<!-- Share button is enabled when: The browser has a sharing API, or the user can edit the file (to enable sharing)-->
|
2025-10-10 00:12:14 +02:00
|
|
|
{#if navigator.share !== undefined || $nav.permissions.write === true}
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={(e) => share_dialog.open(e, nav.path)}>
|
2024-02-16 14:50:34 +01:00
|
|
|
<i class="icon">share</i>
|
|
|
|
<span>Share</span>
|
|
|
|
</button>
|
|
|
|
{/if}
|
2023-11-15 15:50:54 +01:00
|
|
|
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={() => details_visible = !details_visible} class:button_highlight={details_visible}>
|
2023-11-16 12:17:36 +01:00
|
|
|
<i class="icon">help</i>
|
|
|
|
<span>Deta<u>i</u>ls</span>
|
2023-05-17 15:34:56 +02:00
|
|
|
</button>
|
2023-05-17 19:27:46 +02:00
|
|
|
|
2024-11-19 15:31:51 +01:00
|
|
|
{#if $nav.base.id !== "me" && $nav.permissions.write === true}
|
2025-10-13 16:05:50 +02:00
|
|
|
<button onclick={() => edit_window.edit(nav.base, true, "file")} class:button_highlight={edit_visible}>
|
2023-11-16 12:17:36 +01:00
|
|
|
<i class="icon">edit</i>
|
|
|
|
<span><u>E</u>dit</span>
|
2023-11-15 15:50:54 +01:00
|
|
|
</button>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2023-05-17 15:34:56 +02:00
|
|
|
</div>
|
|
|
|
|
2025-06-05 21:29:07 +02:00
|
|
|
<ShareDialog nav={nav} bind:this={share_dialog}/>
|
|
|
|
|
2023-05-17 15:34:56 +02:00
|
|
|
<style>
|
|
|
|
.toolbar {
|
2023-11-15 15:50:54 +01:00
|
|
|
flex: 0 0 auto;
|
|
|
|
overflow-x: hidden;
|
2025-10-09 15:48:23 +02:00
|
|
|
overflow-y: hidden;
|
2023-11-15 16:40:55 +01:00
|
|
|
transition: max-height 0.3s;
|
2025-10-09 15:48:23 +02:00
|
|
|
border-top: 1px solid var(--separator);
|
|
|
|
|
|
|
|
background: var(--shaded_background);
|
2024-11-19 15:31:51 +01:00
|
|
|
backdrop-filter: blur(4px);
|
2023-11-15 15:50:54 +01:00
|
|
|
}
|
|
|
|
.grid {
|
|
|
|
display: grid;
|
2024-04-10 18:35:51 +02:00
|
|
|
grid-template-columns: repeat(auto-fit, minmax(7.5em, 1fr));
|
2023-05-17 15:34:56 +02:00
|
|
|
}
|
|
|
|
.button_row {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
}
|
|
|
|
.button_row > * {
|
|
|
|
flex: 1 1 auto;
|
2023-11-16 12:17:36 +01:00
|
|
|
justify-content: center;
|
2023-05-17 15:34:56 +02:00
|
|
|
}
|
|
|
|
</style>
|