Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

refactor: simplify DocPopup

Marc Klingen27e5eb5feb27
diff --git a/src/components/layouts/doc-popup.tsx b/src/components/layouts/doc-popup.tsx
index dd8a3de3d4..5968ffe124 100644
--- a/src/components/layouts/doc-popup.tsx
+++ b/src/components/layouts/doc-popup.tsx
@@ -8,30 +8,27 @@ import Link from "next/link";
export type DocPopupProps = {
description: React.ReactNode;
- link: string;
+ href: string;
size?: "sm" | "md" | "lg";
};
-export default function DocPopup({ description, link, size }: DocPopupProps) {
- let sizeClass = "w-4 h-4";
- switch (size) {
- case "sm": {
- sizeClass = "w-4 h-4";
- }
- case "md": {
- sizeClass = "w-6 h-6";
- }
- case "lg": {
- sizeClass = "w-8 h-8";
- }
- }
+export default function DocPopup({
+ description,
+ href,
+ size = "sm",
+}: DocPopupProps) {
+ const sizes = {
+ sm: "w-4 h-4",
+ md: "w-6 h-6",
+ lg: "w-8 h-8",
+ };
return (
<HoverCard openDelay={200}>
<HoverCardTrigger className="mx-2 cursor-pointer">
- <Link href={link} rel="noopener" target="_blank">
+ <Link href={href} rel="noopener" target="_blank">
<div className="whitespace-nowrap text-gray-500 sm:pl-0">
- <HelpCircle className={sizeClass} />
+ <HelpCircle className={sizes[size]} />
</div>
</Link>
</HoverCardTrigger>
diff --git a/src/features/dashboard/components/ChartScores.tsx b/src/features/dashboard/components/ChartScores.tsx
index e92ea48153..9e289ca7d2 100644
--- a/src/features/dashboard/components/ChartScores.tsx
+++ b/src/features/dashboard/components/ChartScores.tsx
@@ -69,7 +69,7 @@ export function ChartScores(props: {
<NoData noDataText="No data">
<DocPopup
description="Scores evaluate LLM quality and can be created manually or using the SDK."
- link="https://langfuse.com/docs/scores"
+ href="https://langfuse.com/docs/scores"
/>
</NoData>
)}
diff --git a/src/features/dashboard/components/MetricTable.tsx b/src/features/dashboard/components/MetricTable.tsx
index 66f6604b86..39fc21b7c8 100644
--- a/src/features/dashboard/components/MetricTable.tsx
+++ b/src/features/dashboard/components/MetricTable.tsx
@@ -79,7 +79,7 @@ export const MetricTable = ({
>
<DocPopup
description="Calculated multiplying the number of tokens with cost per token for each model."
- link="https://langfuse.com/docs/token-usage"
+ href="https://langfuse.com/docs/token-usage"
/>
</TotalMetric>
</DashboardTable>
diff --git a/src/features/dashboard/components/ScoresTable.tsx b/src/features/dashboard/components/ScoresTable.tsx
index 92b59d6557..77225505cc 100644
--- a/src/features/dashboard/components/ScoresTable.tsx
+++ b/src/features/dashboard/components/ScoresTable.tsx
@@ -137,7 +137,7 @@ export const ScoresTable = ({
noDataChildren={
<DocPopup
description="Scores evaluate LLM quality and can be created manually or using the SDK."
- link="https://langfuse.com/docs/scores"
+ href="https://langfuse.com/docs/scores"
/>
}
noDataClassName="mt-0"
diff --git a/src/features/dashboard/components/TracesBarListChart.tsx b/src/features/dashboard/components/TracesBarListChart.tsx
index 38dc1007fd..e002578e3a 100644
--- a/src/features/dashboard/components/TracesBarListChart.tsx
+++ b/src/features/dashboard/components/TracesBarListChart.tsx
@@ -82,7 +82,7 @@ export const TracesBarListChart = ({
<NoData noDataText="No data">
<DocPopup
description="Traces contain details about LLM applications and can be created using the SDK."
- link="https://langfuse.com/docs/integrations/sdk#1-backend-tracing"
+ href="https://langfuse.com/docs/integrations/sdk#1-backend-tracing"
/>
</NoData>
)}
diff --git a/src/features/dashboard/components/TracesTimeSeriesChart.tsx b/src/features/dashboard/components/TracesTimeSeriesChart.tsx
index 796c5e36b0..d5796d2fae 100644
--- a/src/features/dashboard/components/TracesTimeSeriesChart.tsx
+++ b/src/features/dashboard/components/TracesTimeSeriesChart.tsx
@@ -85,7 +85,7 @@ export const TracesTimeSeriesChart = ({
<NoData noDataText="No data available">
<DocPopup
description="Traces contain details about LLM applications and can be created using the SDK."
- link="https://langfuse.com/docs/integrations/sdk#1-backend-tracing"
+ href="https://langfuse.com/docs/integrations/sdk#1-backend-tracing"
/>
</NoData>
)}
diff --git a/src/features/dashboard/components/UserChart.tsx b/src/features/dashboard/components/UserChart.tsx
index e9af3c9a36..2298593ed9 100644
--- a/src/features/dashboard/components/UserChart.tsx
+++ b/src/features/dashboard/components/UserChart.tsx
@@ -149,7 +149,7 @@ export const UserChart = ({
<NoData noDataText="No data">
<DocPopup
description="Consumption per user is tracked by passing their ids on traces."
- link="https://langfuse.com/docs/user-explorer"
+ href="https://langfuse.com/docs/user-explorer"
/>
</NoData>
)}