Skip to content
Merged
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
29 changes: 14 additions & 15 deletions src/components/benchmark-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
// they always saw.
const allowedViews = viewsForBenchmark(benchmark);
const defaultView = defaultViewFor(benchmark);
const [view, setView, viewMounted] = useViewPreference(

Check failure on line 183 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useViewPreference" is called conditionally. React Hooks must be called in the exact same order in every component render
benchmark.slug,
defaultView,
allowedViews,
Expand All @@ -191,7 +191,7 @@
// hidden when they switch to distribution or donut - the model is
// "this is the field of providers the reader chose to focus on",
// not "what each view chose to drop". Resets on bench navigation.
const [excluded, setExcluded] = useState<Set<string>>(() => new Set());

Check failure on line 194 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render
const toggleExclude = (slug: string) =>
setExcluded((prev) => {
const next = new Set(prev);
Expand All @@ -207,8 +207,8 @@
// being split between the dimension row and the chart toolbar.
const chartRegions = chartOnlyRegions(benchmark);
const showChartRegionRow = regionOptions.length === 0 && chartRegions.length > 1;
const [chartRegion, setChartRegion] = useState<string>("all");

Check failure on line 210 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useState" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
const chartRegionOptions: ChainOption[] = useMemo(

Check failure on line 211 in src/components/benchmark-body.tsx

View workflow job for this annotation

GitHub Actions / check

React Hook "useMemo" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?
() => [
{ value: "all", label: "All" },
...chartRegions.map((r) => ({ value: r, label: REGION_DISPLAY[r] ?? r })),
Expand Down Expand Up @@ -291,7 +291,20 @@

{!isDraft && (
<>
<div className="mt-8 card-soft rounded-xl p-4 sm:p-6 lg:p-8">
<div className="mt-8 card-soft rounded-xl p-4 sm:p-6 lg:p-8 relative">
{/* View switcher floats in the card's top-right corner so it
doesn't reserve a vertical band of its own. The chart fills
the card top-to-bottom; the switcher sits in the existing
card padding and never competes with the chart for space.
Popover opens downward (default) since there's room below
the corner before the chart geometry begins. */}
<div className="absolute top-3 right-3 sm:top-4 sm:right-4 z-10">
<ViewSwitcher
allowed={allowedViews}
value={view}
onChange={setView}
/>
</div>
{/* Fade-in until the localStorage view preference resolves.
Without this the SSR-default view paints first, then
useViewPreference swaps to the saved view in a visible
Expand Down Expand Up @@ -332,20 +345,6 @@
/>
)}
</div>
{/* Footer row hosts the view switcher. Sat at the top before
this revision and ate ~40 px of header to a button most
readers never used; bottom placement keeps the chart
pinned to the top of the card and lets the control hide
in the visual margin. Popover opens upward so it doesn't
spill into the product ledger below. */}
<div className="mt-4 pt-3 border-t border-rule/60 flex items-center justify-end">
<ViewSwitcher
allowed={allowedViews}
value={view}
onChange={setView}
direction="up"
/>
</div>
</div>

<div className="mt-8 card-soft rounded-xl p-4 sm:p-6 lg:p-8">
Expand Down
Loading