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
14 changes: 8 additions & 6 deletions packages/web/src/components/topbar.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
/* Narrow screens: the bar wraps so the breadcrumb keeps a full row instead of being squeezed by
the page's buttons. Whatever the page, the crumb must not shrink to a few characters. */
@media (max-width: 700px) {
.topbar.topbar-wrap {
.topbar {
height: auto;
min-height: 48px;
flex-wrap: wrap;
padding-top: 8px;
padding-bottom: 8px;
}
.topbar-wrap .crumbs {
.topbar .crumbs {
flex: 1 1 100%;
overflow: hidden;
}
.topbar-wrap .crumbs a {
.topbar .crumbs a {
min-width: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.topbar-wrap .crumbs > .row:first-child {
.topbar .crumbs > .row:first-child {
flex-shrink: 0;
}
.topbar-wrap > .spacer {
.topbar > .spacer {
display: none;
}
.topbar-wrap > .btn {
.topbar > .btn {
flex: none;
}
}
2 changes: 1 addition & 1 deletion packages/web/src/pages/Trial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export function TrialPage({ jobId, trialId }: { jobId: string; trialId: string }

return (
<>
<TopBar crumbs={crumbs} className="topbar-wrap">
<TopBar crumbs={crumbs}>
{job.revisions[trial.method] &&
!["empty", "oracle"].includes(
job.spec.methods.find((m) => m.name === trial.method)?.agent ?? "",
Expand Down
5 changes: 1 addition & 4 deletions packages/web/src/pages/bench/JobDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ export function BenchJobDetail({ id }: { id: string }) {

return (
<>
<TopBar
className="topbar-wrap"
crumbs={[{ label: "Evaluations", href: "/bench" }, { label: jobLabel(job) }]}
>
<TopBar crumbs={[{ label: "Evaluations", href: "/bench" }, { label: jobLabel(job) }]}>
<Link className="btn sm ghost" href={`/runs?q=bench-${job.id}`}>
Runs
</Link>
Expand Down
36 changes: 36 additions & 0 deletions packages/web/test/topbar.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { readFileSync } from "node:fs";
import { renderToStaticMarkup } from "react-dom/server";
import { expect, it, vi } from "vitest";

vi.mock("../src/lib/router.ts", () => ({
useLocation: () => ({ query: new URLSearchParams(), path: "/benchmarks" }),
navigate: vi.fn(),
setQuery: vi.fn(),
onLinkClick: vi.fn(),
}));

const css = readFileSync(new URL("../src/components/topbar.css", import.meta.url), "utf8");
const { TopBar } = await import("../src/components/TopBar.tsx");

it("wraps the bar itself on narrow screens, not an opt-in page class", () => {
// Narrow screens are a property of the bar: a page that forgot the class lost its breadcrumb.
expect(css).toContain("@media (max-width: 700px)");
expect(css).not.toContain("topbar-wrap");
const narrow = css.slice(css.indexOf("@media (max-width: 700px)"));
expect(narrow).toContain("flex-wrap: wrap");
expect(narrow).toContain(".topbar .crumbs");
});

it("renders breadcrumbs the narrow-screen rules can shrink", () => {
const html = renderToStaticMarkup(
<TopBar crumbs={[{ label: "Benchmarks" }]}>
<a className="btn sm" href="/bench/new">
New evaluation
</a>
</TopBar>,
);
expect(html).toContain('<header class="topbar">');
expect(html).toContain('<div class="crumbs">');
expect(html).toContain('<span class="here ellipsis">Benchmarks</span>');
expect(html).toContain("New evaluation");
});
Loading