Files
fnx_web/svelte/src/wrap/Bookmarks.svelte

72 lines
1.4 KiB
Svelte
Raw Normal View History

2025-10-09 15:48:23 +02:00
<script lang="ts">
import { bookmark_del, bookmarks_store } from "lib/Bookmarks";
import { fs_encode_path } from "lib/FilesystemAPI.svelte";
2025-10-09 15:48:23 +02:00
import { highlight_current_page } from "lib/HighlightCurrentPage";
2025-11-03 19:15:57 +01:00
let { menu_collapsed }: { menu_collapsed: boolean } = $props();
let editing = $state(false)
const toggle_edit = () => {
editing = !editing
}
2025-10-09 15:48:23 +02:00
</script>
2025-11-03 19:15:57 +01:00
{#if $bookmarks_store.length !== 0}
<div class="title">
<div class:hide={menu_collapsed}>Bookmarks</div>
<button onclick={() => toggle_edit()} class:button_highlight={editing}>
<i class="icon">edit</i>
</button>
</div>
2026-01-29 23:41:30 +01:00
{#each $bookmarks_store as bookmark}
<div class="row">
<a class="button" href="/d{fs_encode_path(bookmark.path)}" use:highlight_current_page>
<i class="icon">{bookmark.icon}</i>
<span class:hide={menu_collapsed}>{bookmark.label}</span>
</a>
{#if editing}
<button onclick={() => bookmark_del(bookmark.id)}>
<i class="icon">delete</i>
</button>
{/if}
</div>
{/each}
<div class="title"></div>
{/if}
2025-10-09 15:48:23 +02:00
<style>
.title {
display: flex;
flex-direction: row;
align-items: center;
border-bottom: 1px solid var(--separator);
}
.title > div {
flex: 1 1 auto;
text-align: center;
}
.title > button {
flex: 0 0 auto;
}
2025-10-09 15:48:23 +02:00
.row {
display: flex;
flex-direction: row;
}
.row>a {
flex: 1 1 auto;
}
.row>button {
flex: 0 0 auto;
}
.button {
background: none;
box-shadow: none;
}
2025-11-03 19:15:57 +01:00
.hide {
display: none;
2025-10-09 15:48:23 +02:00
}
</style>