diff --git a/web/src/components/citations.tsx b/web/src/components/citations.tsx
index 8444e5b..8dc06bc 100644
--- a/web/src/components/citations.tsx
+++ b/web/src/components/citations.tsx
@@ -96,25 +96,50 @@ export const ShowCitation: React.FC<{ citation: Citation }> = ({
);
};
+const Popup = ({
+ children,
+ content,
+}: {
+ content: string;
+ children: React.ReactElement;
+}) => {
+ return (
+
+ {children}
+
+ {content.split("\n").map((v, i) => (
+
+ {v}
+
+ ))}
+
+
+ );
+};
+
export const CitationRef: React.FC<{ citation?: Citation }> = ({
citation,
}) => {
if (!citation) return null;
+ const split = citation.text.split('"""');
+ const text = split.length === 1 ? citation.text : split[1];
const url =
citation.url && citation.url !== ""
? citation.url
: `https://duckduckgo.com/?q=${encodeURIComponent(citation.title)}`;
return (
-
- [{citation.index}]
-
+
+
+ [{citation.index}]
+
+
);
};
@@ -125,8 +150,7 @@ export const CitationsBlock: React.FC<{
}> = ({ text, citations, textRenderer }) => {
const regex = /\[([a-z]+)\]/g;
return (
-
- {" "}
+
{text.split(regex).map((part, i) => {
// When splitting, the even parts are basic text sections, while the odd ones are
// citations
@@ -136,6 +160,6 @@ export const CitationsBlock: React.FC<{
return ;
}
})}
-
+
);
};
diff --git a/web/src/styles/globals.css b/web/src/styles/globals.css
index 9b83fe8..987409c 100644
--- a/web/src/styles/globals.css
+++ b/web/src/styles/globals.css
@@ -70,3 +70,53 @@ ol {
width: 100%;
border: black solid 1px;
}
+
+/* Tooltip container */
+.popup-container {
+ position: relative;
+ display: inline-block;
+}
+
+/* Tooltip text */
+.popup-container .popup {
+ visibility: hidden;
+ width: 35em;
+ background-color: gray;
+ color: #fff;
+ text-align: center;
+ border-radius: 6px;
+ padding: 10px;
+
+ /* Position the tooltip text */
+ position: absolute;
+ z-index: 1;
+ bottom: 100%;
+ left: 50%;
+ margin-left: -60px;
+
+ /* Fade in tooltip */
+ opacity: 0;
+ transition: opacity 0.3s;
+}
+
+/* Tooltip arrow */
+.popup-container .popup::after {
+ content: "";
+ position: absolute;
+ top: 100%;
+ left: 3.8em;
+ margin-left: -5px;
+ border-width: 5px;
+ border-style: solid;
+ border-color: gray transparent transparent transparent;
+}
+
+/* Show the tooltip text when you mouse over the tooltip container */
+.popup-container:hover .popup {
+ visibility: visible;
+ opacity: 1;
+}
+
+.text-section {
+ padding-bottom: 8px;
+}
diff --git a/web/src/types.ts b/web/src/types.ts
index 6e24438..17f94f2 100644
--- a/web/src/types.ts
+++ b/web/src/types.ts
@@ -4,6 +4,7 @@ export type Citation = {
date: string;
url: string;
index: number;
+ text: string;
};
export type Followup = {