From dc398cf6a79cceff518111d4cf8c0536c5dcef74 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 10 Nov 2025 21:53:56 +0800 Subject: [PATCH] chore(web): unify metadata badge styling and fix event handling - Remove MetadataBadge component and inline styles consistently - Add pointer/mouse event handlers to prevent drag interference - Fix LocationDisplay mode handling and popover interaction - Clean up RelationList empty state logic --- .../memo-metadata/AttachmentCard.tsx | 8 ++- .../memo-metadata/LocationDisplay.tsx | 63 ++++++++++--------- .../memo-metadata/MetadataBadge.tsx | 46 -------------- .../components/memo-metadata/RelationCard.tsx | 26 ++++++-- .../components/memo-metadata/RelationList.tsx | 16 +++-- web/src/components/memo-metadata/index.ts | 1 - 6 files changed, 73 insertions(+), 87 deletions(-) delete mode 100644 web/src/components/memo-metadata/MetadataBadge.tsx diff --git a/web/src/components/memo-metadata/AttachmentCard.tsx b/web/src/components/memo-metadata/AttachmentCard.tsx index 4b60f03e..45ab4968 100644 --- a/web/src/components/memo-metadata/AttachmentCard.tsx +++ b/web/src/components/memo-metadata/AttachmentCard.tsx @@ -28,7 +28,7 @@ const AttachmentCard = ({ attachment, mode, onRemove, onClick, className, showTh return (
@@ -41,6 +41,12 @@ const AttachmentCard = ({ attachment, mode, onRemove, onClick, className, showTh {onRemove && ( + )}
diff --git a/web/src/components/memo-metadata/MetadataBadge.tsx b/web/src/components/memo-metadata/MetadataBadge.tsx deleted file mode 100644 index 2ce092af..00000000 --- a/web/src/components/memo-metadata/MetadataBadge.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { XIcon } from "lucide-react"; -import { ReactNode } from "react"; -import { cn } from "@/lib/utils"; - -interface MetadataBadgeProps { - icon: ReactNode; - children: ReactNode; - onRemove?: () => void; - onClick?: () => void; - className?: string; - maxWidth?: string; -} - -/** - * Shared badge component for metadata display (Location, Tags, etc.) - * Provides consistent styling across editor and view modes - */ -const MetadataBadge = ({ icon, children, onRemove, onClick, className, maxWidth = "max-w-[160px]" }: MetadataBadgeProps) => { - return ( -
- {icon} - {children} - {onRemove && ( - - )} -
- ); -}; - -export default MetadataBadge; diff --git a/web/src/components/memo-metadata/RelationCard.tsx b/web/src/components/memo-metadata/RelationCard.tsx index 9ae34daf..f4237e55 100644 --- a/web/src/components/memo-metadata/RelationCard.tsx +++ b/web/src/components/memo-metadata/RelationCard.tsx @@ -27,14 +27,30 @@ const RelationCard = ({ memo, mode, onRemove, parentPage, className }: RelationC return (
{memo.snippet} - + {onRemove && ( + + )}
); } @@ -43,7 +59,7 @@ const RelationCard = ({ memo, mode, onRemove, parentPage, className }: RelationC return ( - {memoId.slice(0, 6)} + {memoId.slice(0, 6)} {memo.snippet} ); diff --git a/web/src/components/memo-metadata/RelationList.tsx b/web/src/components/memo-metadata/RelationList.tsx index 85ff0f4d..1c75a6d0 100644 --- a/web/src/components/memo-metadata/RelationList.tsx +++ b/web/src/components/memo-metadata/RelationList.tsx @@ -52,13 +52,17 @@ const RelationList = observer(({ relations, currentMemoName, mode, onRelationsCh // Fetch full memo details for editor mode useEffect(() => { - if (mode === "edit" && referencingRelations.length > 0) { + if (mode === "edit") { (async () => { - const requests = referencingRelations.map(async (relation) => { - return await memoStore.getOrFetchMemoByName(relation.relatedMemo!.name, { skipStore: true }); - }); - const list = await Promise.all(requests); - setReferencingMemos(list); + if (referencingRelations.length > 0) { + const requests = referencingRelations.map(async (relation) => { + return await memoStore.getOrFetchMemoByName(relation.relatedMemo!.name, { skipStore: true }); + }); + const list = await Promise.all(requests); + setReferencingMemos(list); + } else { + setReferencingMemos([]); + } })(); } }, [mode, relations]); diff --git a/web/src/components/memo-metadata/index.ts b/web/src/components/memo-metadata/index.ts index 78fa92ba..0f9a43a5 100644 --- a/web/src/components/memo-metadata/index.ts +++ b/web/src/components/memo-metadata/index.ts @@ -8,7 +8,6 @@ export { default as AttachmentList } from "./AttachmentList"; export { default as RelationList } from "./RelationList"; // Base components (can be used for other metadata types) -export { default as MetadataBadge } from "./MetadataBadge"; export { default as MetadataCard } from "./MetadataCard"; export { default as AttachmentCard } from "./AttachmentCard"; export { default as RelationCard } from "./RelationCard";