favoriting

This commit is contained in:
2026-03-06 13:53:26 -06:00
parent 10d76eb3c1
commit 09557d49a4
8 changed files with 155 additions and 29 deletions
+21 -2
View File
@@ -1,8 +1,8 @@
import { type Component, createSignal, createMemo, createEffect, onCleanup, For, Show } from "solid-js";
import { store, renameTagDefinition, updateNote, removeNote, restoreNote, setActiveNoteId, cleanupNoteAttachments } from "@/store";
import { store, renameTagDefinition, updateNote, removeNote, restoreNote, setActiveNoteId, cleanupNoteAttachments, getFavoriteTag } from "@/store";
import { pb } from "@/lib/pocketbase";
import { type Note } from "@/store";
import { Trash2, Lock, Unlock, Search, Link, X, ChevronRight, ChevronDown, FileText, Plus } from "lucide-solid";
import { Trash2, Lock, Unlock, Search, Link, X, ChevronRight, ChevronDown, FileText, Plus, Star } from "lucide-solid";
import { Button } from "@/components/ui/button";
import { DragDropProvider, DragDropSensors, SortableProvider, createSortable, closestCenter } from "@thisbeyond/solid-dnd";
import { cn } from "@/lib/utils";
@@ -505,6 +505,25 @@ export const NotepadView: Component<{
</Show>
</div>
<Button
variant="ghost"
size="sm"
class={cn(
"h-8 w-8 p-0 transition-all rounded-xl border border-border/40 shadow-sm",
note().tags?.includes(getFavoriteTag()) ? "bg-amber-500/10 text-amber-500 hover:bg-amber-500/20" : "text-muted-foreground hover:bg-muted"
)}
onClick={async (e) => {
e.stopPropagation();
const favTag = getFavoriteTag();
const currentTags = note().tags || [];
const isFav = currentTags.includes(favTag);
const newTags = isFav ? currentTags.filter(t => t !== favTag) : [...currentTags, favTag];
await handleUpdateNote(note().id, { tags: newTags });
}}
title="Toggle Favorite"
>
<Star size={14} class={cn(note().tags?.includes(getFavoriteTag()) && "fill-amber-500")} />
</Button>
<Show when={isOwner}>
<Button
variant="ghost"