Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function BrowserDownloadCardAction({
className={className}
style={ctaButtonStyle}
>
{children}
<DownloadLabel>{children}</DownloadLabel>
</PlatformDownloadLink>
);
}
Expand All @@ -47,6 +47,15 @@ export function BrowserDownloadCardAction({
className={`${className} cursor-not-allowed opacity-45`}
style={ctaButtonStyle}
>
<DownloadLabel>{children}</DownloadLabel>
</span>
);
}

/** Lets long localized labels wrap inside the fixed-width landing-page cards. */
function DownloadLabel({ children }: { children: React.ReactNode }) {
return (
<span className="min-w-0 text-balance whitespace-normal text-center">
{children}
</span>
);
Expand Down
28 changes: 28 additions & 0 deletions web/tests/browser-download-card-action.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,32 @@ describe("Browser download card action", () => {
expect(action.props.href).toBeUndefined();
expect(action.props.onClick).toBeUndefined();
});

test("wraps long labels inside fixed-width landing-page cards", () => {
const action = BrowserDownloadCardAction({
platform: "linux",
artifact: "run-installer",
href: "/api/download/browser-nightly/linux-x64/run",
available: true,
children: "Download auto-updating installer (.run)",
});

if (action.type !== PlatformDownloadLink) {
throw new Error("enabled download did not render a tracked link");
}

const label = action.props.children as {
type: (props: { children: string }) => {
type: string;
props: { className: string; children: string };
};
props: { children: string };
};
const labelElement = label.type(label.props);
expect(labelElement.type).toBe("span");
expect(labelElement.props.className).toContain("min-w-0");
expect(labelElement.props.className).toContain("whitespace-normal");
expect(labelElement.props.className).toContain("text-center");
expect(labelElement.props.children).toBe("Download auto-updating installer (.run)");
});
});
Loading