From 094dda687d8ccc04de2c4dc8d1d6d731a437f9a2 Mon Sep 17 00:00:00 2001 From: celine Date: Tue, 25 Nov 2025 19:47:59 -0500 Subject: [PATCH] added a posts button to scope publications in the @ mention dropdown --- components/Mention.tsx | 142 +++++++++++++++++++++++++++++++++-------- 1 file changed, 114 insertions(+), 28 deletions(-) diff --git a/components/Mention.tsx b/components/Mention.tsx index 124689fd..b3a74af9 100644 --- a/components/Mention.tsx +++ b/components/Mention.tsx @@ -133,7 +133,15 @@ export function MentionAutocomplete(props: { if (!mentionCoords || suggestions.length === 0) return null; - const headerStyle = "text-xs text-tertiary font-bold pt-1 px-2"; + + const getHeader = (type: Mention["type"]) => { + switch (type) { + case "did": + return "People"; + case "publication": + return "Publications"; + } + }; const sortedSuggestions = [...suggestions].sort((a, b) => { const order: Mention["type"][] = ["did", "publication"]; @@ -180,26 +188,47 @@ export function MentionAutocomplete(props: { return ( <> {showHeader && ( - -
-
Publications
-
+ <> + {index > 0 && ( +
+ )} +
+ {getHeader(result.type)} +
+ + )} + {result.type === "did" ? ( + { + if (mentionRange) { + props.onSelect(result, mentionRange); + setMentionQuery(null); + setMentionRange(null); + setMentionCoords(null); + } + }} + onMouseDown={(e) => e.preventDefault()} + displayName={result.displayName} + handle={result.handle} + selected={index === suggestionIndex} + /> + ) : ( + { + if (mentionRange) { + props.onSelect(result, mentionRange); + setMentionQuery(null); + setMentionRange(null); + setMentionCoords(null); + } + }} + onMouseDown={(e) => e.preventDefault()} + pubName={result.name} + selected={index === suggestionIndex} + /> )} - { - if (mentionRange) { - props.onSelect(result, mentionRange); - setMentionQuery(null); - setMentionRange(null); - setMentionCoords(null); - } - }} - onMouseDown={(e) => e.preventDefault()} - result={resultText} - subtext={subtext} - selected={index === suggestionIndex} - /> ); })} @@ -218,24 +247,81 @@ const Result = (props: { selected?: boolean; }) => { return ( -
props.onClick()} + ${props.selected ? "bg-[var(--accent-light)]" : ""}`} + onClick={() => { + props.onClick(); + }} onMouseDown={(e) => props.onMouseDown(e)} > -
-
{props.result}
+
+ {props.result}
{props.subtext && (
{props.subtext}
)} -
+ + ); +}; + +const ScopeButton = (props: { + onClick: () => void; + children: React.ReactNode; +}) => { + return ( + + ); +}; + +const DidResult = (props: { + displayName?: string; + handle: string; + onClick: () => void; + onMouseDown: (e: React.MouseEvent) => void; + selected?: boolean; +}) => { + return ( + + ); +}; + +const PublicationResult = (props: { + pubName: string; + onClick: () => void; + onMouseDown: (e: React.MouseEvent) => void; + selected?: boolean; +}) => { + return ( + +
{props.pubName}
+ {}}>Posts + + } + {...props} + /> ); }; -- 2.54.0