feat(compare): fill the sticky bar's label rail with a comparison caption

'COMPARING / 3 primary schools' — 0.72rem uppercase eyebrow over a
0.95rem semibold count, sized to sit alongside the 0.92rem chip names
without dominating. Desktop only; mobile pills unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB
This commit is contained in:
Tudor
2026-07-16 21:27:25 +01:00
co-authored by Claude Fable 5
parent 8e0b730629
commit 99b769ca9e
4 changed files with 42 additions and 3 deletions
+2
View File
@@ -204,6 +204,8 @@ test('comparing two schools shows the parent-first sections side by side', async
.locator('[aria-label="Schools in this comparison"]') .locator('[aria-label="Schools in this comparison"]')
.evaluate((el) => getComputedStyle(el).gridTemplateColumns); .evaluate((el) => getComputedStyle(el).gridTemplateColumns);
expect(barTemplate).toMatch(/^200px /); expect(barTemplate).toMatch(/^200px /);
// ...and its label rail carries the comparison caption.
await expect(page.getByText(/^\d+ (primary|secondary) schools?$/)).toBeVisible();
// Ofsted linkout goes to the school's provider page, never a report deep-link // Ofsted linkout goes to the school's provider page, never a report deep-link
const ofstedLink = page.getByRole('link', { name: /Ofsted page/i }).first(); const ofstedLink = page.getByRole('link', { name: /Ofsted page/i }).first();
@@ -72,5 +72,7 @@ test('an all-secondary comparison renders the sections, not an empty primary tab
}); });
expect(screen.getAllByText('Gamma High').length).toBeGreaterThan(0); expect(screen.getAllByText('Gamma High').length).toBeGreaterThan(0);
expect(screen.queryByText(/No primary schools in your comparison/)).toBeNull(); expect(screen.queryByText(/No primary schools in your comparison/)).toBeNull();
// The sticky bar's rail caption reflects the active phase and count.
expect(screen.getByText('2 secondary schools')).toBeInTheDocument();
expect(fetchComparison).not.toHaveBeenCalled(); expect(fetchComparison).not.toHaveBeenCalled();
}); });
@@ -148,10 +148,16 @@
text-overflow: ellipsis; text-overflow: ellipsis;
} }
/* Caption filling the label rail on desktop ("Comparing / 3 primary
schools"). Hidden on mobile, where the bar is a row of compact pills. */
.barCaption {
display: none;
}
/* Desktop (matches the sections' 761px breakpoint): the bar adopts the same /* Desktop (matches the sections' 761px breakpoint): the bar adopts the same
grid template as compareSections' .grid — a 200px row-label rail plus one grid template as compareSections' .grid — a 200px row-label rail plus one
column per school — so each chip sits exactly over the column it labels. column per school — so each chip sits exactly over the column it labels.
The first chip starts after the empty label rail. */ The caption occupies the rail; chips flow into the school columns. */
@media (min-width: 761px) { @media (min-width: 761px) {
.schoolBar { .schoolBar {
display: grid; display: grid;
@@ -164,8 +170,29 @@
min-width: 0; min-width: 0;
} }
.schoolChip:first-child { .barCaption {
grid-column: 2; grid-column: 1;
display: flex;
flex-direction: column;
justify-content: center;
gap: 0.1rem;
padding-right: 0.5rem;
min-width: 0;
}
.barCaptionEyebrow {
font-size: 0.72rem;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--text-muted, #6d685f);
}
.barCaptionCount {
font-size: 0.95rem;
font-weight: 600;
line-height: 1.3;
color: var(--text-primary, #1a1612);
} }
} }
+8
View File
@@ -350,6 +350,14 @@ export function ComparisonView({
style={{ '--school-count': activeSchools.length } as CSSProperties} style={{ '--school-count': activeSchools.length } as CSSProperties}
aria-label="Schools in this comparison" aria-label="Schools in this comparison"
> >
{/* Fills the 200px label rail on desktop (hidden on mobile). */}
<div className={styles.barCaption}>
<span className={styles.barCaptionEyebrow}>Comparing</span>
<span className={styles.barCaptionCount}>
{activeSchools.length} {comparePhase} school
{activeSchools.length === 1 ? '' : 's'}
</span>
</div>
{activeSchools.map((school, index) => ( {activeSchools.map((school, index) => (
<div <div
key={school.urn} key={school.urn}