diff --git a/__tests__/hero-panel.test.tsx b/__tests__/hero-panel.test.tsx
index dd47b9d..f2c01f5 100644
--- a/__tests__/hero-panel.test.tsx
+++ b/__tests__/hero-panel.test.tsx
@@ -3,6 +3,10 @@ import { Clock } from "lucide-react";
import { describe, expect, it } from "vitest";
import { HeroPanel } from "@/components/molecules/hero-panel";
+function readValueCqi(element: HTMLElement): number {
+ return Number.parseFloat(/([\d.]+)cqi/.exec(element.style.getPropertyValue("--hero-value-size"))?.[1] ?? "");
+}
+
describe("HeroPanel", () => {
it("renders the label and the highlighted value", () => {
render();
@@ -30,6 +34,24 @@ describe("HeroPanel", () => {
expect(screen.getByText("Resumo Financeiro")).toBeInTheDocument();
});
+ it("shrinks the font as the value gets longer so it never wraps", () => {
+ const { rerender } = render();
+ const shortValueCqi = readValueCqi(screen.getByText("R$ 25,00"));
+
+ rerender();
+ const longValueCqi = readValueCqi(screen.getByText("R$ 926.150,68"));
+
+ expect(shortValueCqi).toBeGreaterThan(0);
+ expect(longValueCqi).toBeLessThan(shortValueCqi);
+ });
+
+ it("still asks for a finite size when there is no value to show", () => {
+ const { container } = render();
+ const valueElement = container.querySelector("p.font-black");
+
+ expect(readValueCqi(valueElement as HTMLElement)).toBeGreaterThan(0);
+ });
+
it("omits the footer separator when there is no footer", () => {
render();
diff --git a/components/molecules/hero-panel.tsx b/components/molecules/hero-panel.tsx
index af0dbb6..25d881b 100644
--- a/components/molecules/hero-panel.tsx
+++ b/components/molecules/hero-panel.tsx
@@ -1,4 +1,4 @@
-import type { ElementType, ReactNode } from "react";
+import type { CSSProperties, ElementType, ReactNode } from "react";
import { cn } from "@/lib/utils";
const TONE_CLASSES = {
@@ -7,6 +7,8 @@ const TONE_CLASSES = {
blue: "bg-blue-600 shadow-blue-500/30",
} as const;
+const VALUE_INLINE_SIZE_CQI = 208;
+
interface HeroPanelProps {
icon: ElementType;
label: string;
@@ -37,8 +39,15 @@ export function HeroPanel({ icon: Icon, label, value, tone, badge, footer, child
{badge}
-