diff --git a/src/interface/web/app/components/referencePanel/referencePanel.tsx b/src/interface/web/app/components/referencePanel/referencePanel.tsx index a907a2a9..4419b289 100644 --- a/src/interface/web/app/components/referencePanel/referencePanel.tsx +++ b/src/interface/web/app/components/referencePanel/referencePanel.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from "react"; -import { ArrowCircleDown, ArrowRight } from "@phosphor-icons/react"; +import { ArrowCircleDown, ArrowRight, Code, Note } from "@phosphor-icons/react"; import markdownIt from "markdown-it"; const md = new markdownIt({ @@ -239,10 +239,10 @@ function CodeContextReferenceCard(props: CodeContextReferenceCardProps) { {(props.output_files?.length > 0 && renderOutputFiles(props.output_files?.slice(0, 1), true)) || ( -
-                                {sanitizedCodeSnippet}
-                            
- )} +
+                                    {sanitizedCodeSnippet}
+                                
+ )} @@ -475,6 +475,63 @@ export function constructAllReferences( }; } +interface SimpleIconProps { + type: string; + link?: string; +} + +function SimpleIcon(props: SimpleIconProps) { + + let favicon = ``; + let domain = "unknown"; + + if (props.link) { + try { + domain = new URL(props.link).hostname; + favicon = `https://www.google.com/s2/favicons?domain=${domain}`; + } catch (error) { + console.warn(`Error parsing domain from link: ${props.link}`); + return null; + } + } + + let symbol = null; + + const itemClasses = "!w-4 !h-4 text-muted-foreground inline-flex mr-2 rounded-lg"; + + switch (props.type) { + case "code": + symbol = ; + break; + case "online": + symbol = + ; + break; + case "notes": + symbol = + ; + break; + default: + symbol = null; + } + + console.log("symbol", symbol); + + if (!symbol) { + return null; + } + + return ( +
+ {symbol} +
+ ); +} + export interface TeaserReferenceSectionProps { notesReferenceCardData: NotesContextReferenceData[]; onlineReferenceCardData: OnlineReferenceData[]; @@ -483,25 +540,6 @@ export interface TeaserReferenceSectionProps { } export function TeaserReferencesSection(props: TeaserReferenceSectionProps) { - const [numTeaserSlots, setNumTeaserSlots] = useState(3); - - useEffect(() => { - setNumTeaserSlots(props.isMobileWidth ? 1 : 3); - }, [props.isMobileWidth]); - - const codeDataToShow = props.codeReferenceCardData.slice(0, numTeaserSlots); - const notesDataToShow = props.notesReferenceCardData.slice( - 0, - numTeaserSlots - codeDataToShow.length, - ); - const onlineDataToShow = - notesDataToShow.length + codeDataToShow.length < numTeaserSlots - ? props.onlineReferenceCardData.slice( - 0, - numTeaserSlots - codeDataToShow.length - notesDataToShow.length, - ) - : []; - const shouldShowShowMoreButton = props.notesReferenceCardData.length > 0 || props.codeReferenceCardData.length > 0 || @@ -517,47 +555,20 @@ export function TeaserReferencesSection(props: TeaserReferenceSectionProps) { } return ( -
+

- References

{numReferences} sources

+
+ {shouldShowShowMoreButton && ( + + )} +

-
- {codeDataToShow.map((code, index) => { - return ( - - ); - })} - {notesDataToShow.map((note, index) => { - return ( - - ); - })} - {onlineDataToShow.map((online, index) => { - return ( - - ); - })} - {shouldShowShowMoreButton && ( - - )} -
); } @@ -566,18 +577,52 @@ interface ReferencePanelDataProps { notesReferenceCardData: NotesContextReferenceData[]; onlineReferenceCardData: OnlineReferenceData[]; codeReferenceCardData: CodeReferenceData[]; + isMobileWidth: boolean; } export default function ReferencePanel(props: ReferencePanelDataProps) { + const [numTeaserSlots, setNumTeaserSlots] = useState(3); + + useEffect(() => { + setNumTeaserSlots(props.isMobileWidth ? 1 : 3); + }, [props.isMobileWidth]); + if (!props.notesReferenceCardData && !props.onlineReferenceCardData) { return null; } + const codeDataToShow = props.codeReferenceCardData.slice(0, numTeaserSlots); + const notesDataToShow = props.notesReferenceCardData.slice( + 0, + numTeaserSlots - codeDataToShow.length, + ); + const onlineDataToShow = + notesDataToShow.length + codeDataToShow.length < numTeaserSlots + ? props.onlineReferenceCardData.filter((online) => online.link).slice( + 0, + numTeaserSlots - codeDataToShow.length - notesDataToShow.length, + ) + : []; + return ( - - View references - + + {codeDataToShow.map((code, index) => { + return ( + + ); + })} + {notesDataToShow.map((note, index) => { + return ( + + ); + })} + {onlineDataToShow.map((online, index) => { + return ( + + ); + })} +