support delete bookmarks

This commit is contained in:
Julian Freeman
2026-04-17 16:27:57 -04:00
parent 42905bf6d3
commit 45662dc642
10 changed files with 946 additions and 24 deletions

View File

@@ -1,27 +1,88 @@
<script setup lang="ts">
import { computed } from "vue";
import type { BookmarkSortKey, BookmarkSummary } from "../../types/browser";
defineProps<{
const props = defineProps<{
bookmarks: BookmarkSummary[];
sortKey: BookmarkSortKey;
selectedBookmarkUrls: string[];
deleteBusy: boolean;
}>();
const emit = defineEmits<{
"update:sortKey": [value: BookmarkSortKey];
showProfiles: [url: string];
toggleBookmark: [url: string];
toggleAllBookmarks: [];
deleteBookmark: [url: string];
deleteSelected: [];
}>();
const allSelected = computed(
() =>
props.bookmarks.length > 0 &&
props.bookmarks.every((bookmark) => props.selectedBookmarkUrls.includes(bookmark.url)),
);
function isSelected(url: string) {
return props.selectedBookmarkUrls.includes(url);
}
</script>
<template>
<section class="table-section">
<div class="bookmarks-toolbar">
<label class="toolbar-checkbox" :class="{ disabled: !bookmarks.length }">
<input
type="checkbox"
class="native-checkbox"
:checked="allSelected"
:disabled="!bookmarks.length || deleteBusy"
@change="emit('toggleAllBookmarks')"
/>
<span class="custom-checkbox" :class="{ checked: allSelected }" aria-hidden="true">
<svg viewBox="0 0 16 16">
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
</svg>
</span>
<span>Select All</span>
</label>
<button
class="danger-button"
type="button"
:disabled="!selectedBookmarkUrls.length || deleteBusy"
@click="emit('deleteSelected')"
>
{{ deleteBusy ? "Deleting..." : `Delete Selected (${selectedBookmarkUrls.length})` }}
</button>
</div>
<div v-if="bookmarks.length" class="data-table">
<div class="data-table-header bookmarks-grid">
<div class="header-cell checkbox-cell">Pick</div>
<button class="header-cell sortable" :class="{ active: sortKey === 'title' }" type="button" @click="emit('update:sortKey', 'title')">Name</button>
<button class="header-cell sortable" :class="{ active: sortKey === 'url' }" type="button" @click="emit('update:sortKey', 'url')">URL</button>
<div class="header-cell actions-cell">Profiles</div>
<div class="header-cell actions-cell">Actions</div>
</div>
<div class="data-table-body styled-scrollbar">
<article v-for="bookmark in bookmarks" :key="bookmark.url" class="data-table-row bookmarks-grid">
<div class="row-cell checkbox-cell">
<label class="table-checkbox" :class="{ disabled: deleteBusy }">
<input
type="checkbox"
class="native-checkbox"
:checked="isSelected(bookmark.url)"
:disabled="deleteBusy"
@change="emit('toggleBookmark', bookmark.url)"
/>
<span class="custom-checkbox" :class="{ checked: isSelected(bookmark.url) }" aria-hidden="true">
<svg viewBox="0 0 16 16">
<path d="M3.5 8.2L6.4 11.1L12.5 4.9" />
</svg>
</span>
</label>
</div>
<div class="row-cell primary-cell">
<strong :title="bookmark.title">{{ bookmark.title }}</strong>
</div>
@@ -31,6 +92,14 @@ const emit = defineEmits<{
<span>View</span>
<span class="badge neutral">{{ bookmark.profileIds.length }}</span>
</button>
<button
class="danger-button inline-danger-button"
type="button"
:disabled="deleteBusy"
@click="emit('deleteBookmark', bookmark.url)"
>
Delete
</button>
</div>
</article>
</div>
@@ -43,11 +112,21 @@ const emit = defineEmits<{
<style scoped>
.table-section {
display: flex;
flex-direction: column;
gap: 10px;
padding: 0;
height: 100%;
min-height: 0;
}
.bookmarks-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.data-table {
display: flex;
flex-direction: column;
@@ -68,7 +147,7 @@ const emit = defineEmits<{
.bookmarks-grid {
display: grid;
grid-template-columns: minmax(180px, 0.9fr) minmax(260px, 1.2fr) 154px;
grid-template-columns: 52px minmax(180px, 0.9fr) minmax(260px, 1.2fr) 250px;
gap: 12px;
align-items: center;
}
@@ -102,6 +181,79 @@ const emit = defineEmits<{
color: var(--text);
}
.toolbar-checkbox {
display: inline-flex;
align-items: center;
gap: 10px;
color: var(--text);
font-size: 0.88rem;
cursor: pointer;
}
.toolbar-checkbox.disabled {
opacity: 0.55;
cursor: default;
}
.native-checkbox {
position: absolute;
opacity: 0;
pointer-events: none;
}
.table-checkbox {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.table-checkbox.disabled {
cursor: default;
opacity: 0.5;
}
.custom-checkbox {
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border: 1px solid rgba(148, 163, 184, 0.34);
border-radius: 7px;
background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.92));
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.78),
0 4px 10px rgba(15, 23, 42, 0.06);
}
.custom-checkbox svg {
width: 12px;
height: 12px;
}
.custom-checkbox path {
fill: none;
stroke: #fff;
stroke-width: 2.2;
stroke-linecap: round;
stroke-linejoin: round;
opacity: 0;
}
.custom-checkbox.checked {
border-color: rgba(47, 111, 237, 0.2);
background: linear-gradient(135deg, #2f6fed, #5aa1f7);
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.22),
0 8px 18px rgba(47, 111, 237, 0.22);
}
.custom-checkbox.checked path {
opacity: 1;
}
.data-table-row {
padding: 12px 14px;
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
@@ -153,20 +305,32 @@ const emit = defineEmits<{
.actions-cell {
display: flex;
justify-content: flex-end;
gap: 8px;
}
.checkbox-cell {
display: flex;
justify-content: center;
}
.inline-danger-button {
padding: 6px 10px;
border-radius: 10px;
font-size: 0.8rem;
}
@media (max-width: 900px) {
.bookmarks-grid {
grid-template-columns: minmax(160px, 0.9fr) minmax(200px, 1fr) 148px;
grid-template-columns: 52px minmax(160px, 0.9fr) minmax(200px, 1fr) 236px;
}
}
@media (max-width: 720px) {
.bookmarks-grid {
grid-template-columns: minmax(0, 1fr) 132px;
grid-template-columns: 52px minmax(0, 1fr) 152px;
}
.bookmarks-grid > :nth-child(2) {
.bookmarks-grid > :nth-child(3) {
display: none;
}
}