Skip to content

Commit f1e80a8

Browse files
Subash-MohanDanelegend
authored andcommitted
fix: update SourceTag component to use variant prop for sizing (#8582)
1 parent 35de80c commit f1e80a8

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

web/src/app/app/message/MemoizedTextComponents.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const MemoizedLink = memo(
165165

166166
return (
167167
<SourceTag
168-
inlineCitation
168+
variant="inlineCitation"
169169
displayName={displayName}
170170
sources={[sourceInfo]}
171171
onSourceClick={handleSourceClick}

web/src/app/app/message/messageComponents/MessageToolbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const SourcesTagWrapper = React.memo(function SourcesTagWrapper({
7777

7878
return (
7979
<SourceTag
80+
variant="button"
8081
displayName="Sources"
8182
sources={sources}
8283
onSourceClick={handleSourceClick}

web/src/refresh-components/buttons/source-tag/SourceTag.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const sizeClasses = {
3434
tag: {
3535
container: "rounded-08 p-1 gap-1",
3636
},
37+
button: {
38+
container: "rounded-08 h-[2.25rem] min-w-[2.25rem] p-2 gap-1",
39+
},
3740
} as const;
3841

3942
/**
@@ -271,8 +274,8 @@ const QueryText = ({
271274
* Props for the SourceTag component.
272275
*/
273276
export interface SourceTagProps {
274-
/** Use inline citation size (smaller, for use within text) */
275-
inlineCitation?: boolean;
277+
/** Sizing variant: "inlineCitation" for compact in-text use, "button" for interactive contexts, "tag" (default) for standard display */
278+
variant?: "inlineCitation" | "tag" | "button";
276279

277280
/** Display name shown on the tag (e.g., "Google Drive", "Business Insider") */
278281
displayName: string;
@@ -314,7 +317,7 @@ export interface SourceTagProps {
314317
* - Shows stacked source icons + display name
315318
* - Hovering opens a details card with source navigation
316319
*
317-
* **Inline Citation** (`inlineCitation`):
320+
* **Inline Citation** (`variant="inlineCitation"`):
318321
* - Compact size for use within text content
319322
* - Shows "+N" count for multiple sources
320323
*
@@ -341,7 +344,7 @@ export interface SourceTagProps {
341344
*
342345
* // Inline citation within text
343346
* <SourceTag
344-
* inlineCitation
347+
* variant="inlineCitation"
345348
* displayName="Source 1"
346349
* sources={multipleSources}
347350
* />
@@ -355,7 +358,7 @@ export interface SourceTagProps {
355358
* ```
356359
*/
357360
const SourceTagInner = ({
358-
inlineCitation,
361+
variant = "tag",
359362
displayName,
360363
displayUrl,
361364
sources,
@@ -367,6 +370,8 @@ const SourceTagInner = ({
367370
toggleSource,
368371
tooltipText,
369372
}: SourceTagProps) => {
373+
const inlineCitation = variant === "inlineCitation";
374+
370375
const [currentIndex, setCurrentIndex] = useState(0);
371376
const [isOpen, setIsOpen] = useState(false);
372377
const [expanded, setExpanded] = useState(false);
@@ -383,7 +388,7 @@ const SourceTagInner = ({
383388

384389
const extraCount = sources.length - 1;
385390

386-
const size = inlineCitation ? "inlineCitation" : "tag";
391+
const size = variant;
387392
const styles = sizeClasses[size];
388393

389394
// Shared text styling props

0 commit comments

Comments
 (0)