🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(dashboard): stack metric labels under big numbers (#16266)
Nikita Kabardine491ab993002
diff --git a/web/src/features/dashboard/components/TotalMetric.stories.tsx b/web/src/features/dashboard/components/TotalMetric.stories.tsxnew file mode 100644index 0000000000..239dc728b7--- /dev/null+++ b/web/src/features/dashboard/components/TotalMetric.stories.tsx@@ -0,0 +1,59 @@+import { Info } from "lucide-react";+import { expect, within } from "storybook/test";+import preview from "../../../../.storybook/preview";+import { TotalMetric } from "./TotalMetric";++const meta = preview.meta({+ component: TotalMetric,+});++export default meta;++export const Default = meta.story({+ args: {+ metric: "434.15K",+ description: "Total traces tracked",+ },+});++export const Currency = meta.story({+ args: {+ metric: "$9,753.19",+ description: "Total cost",+ },+});++export const WithInfoIcon = meta.story({+ args: {+ metric: "$9,753.19",+ description: "Total cost",+ children: <Info className="text-muted-foreground h-3 w-3" />,+ },+});++// Dashboard tiles sit three-across, so the metric used to share a row with+// its label and wrap into a stacked word list. The label now sits under the+// number even in a tile-width container.+export const TestStacksLabelUnderMetric = meta.story({+ name: "(Test) Stacks label under metric",+ render: () => (+ <div className="w-60">+ <TotalMetric metric="434.15K" description="Total traces tracked" />+ </div>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const metric = canvas.getByText("434.15K");+ const description = canvas.getByText("Total traces tracked");+ const metricRect = metric.getBoundingClientRect();+ const descriptionRect = description.getBoundingClientRect();++ await expect(descriptionRect.top).toBeGreaterThanOrEqual(+ metricRect.bottom - 1,+ );+ await expect(Math.abs(descriptionRect.left - metricRect.left)).toBeLessThan(+ 2,+ );+ await expect(descriptionRect.height).toBeLessThan(metricRect.height);+ },+});diff --git a/web/src/features/dashboard/components/TotalMetric.tsx b/web/src/features/dashboard/components/TotalMetric.tsxindex b700582287..d80ac7a391 100644--- a/web/src/features/dashboard/components/TotalMetric.tsx+++ b/web/src/features/dashboard/components/TotalMetric.tsx@@ -14,15 +14,16 @@ export const TotalMetric = ({children?: ReactNode;}) => {return (- <div- className={cn(- "animate-in flex items-baseline justify-start space-x-2",- className,- )}- >+ <div className={cn("animate-in flex flex-col items-start", className)}><div className="text-3xl font-bold">{metric}</div>- <p className="text-muted-foreground text-sm">{description}</p>- {children}+ {description || children ? (+ <div className="flex min-w-0 items-center gap-1">+ {description ? (+ <p className="text-muted-foreground text-sm">{description}</p>+ ) : null}+ {children}+ </div>+ ) : null}</div>);};