feat(row): redesign to clean 3-line layout with stats on second row
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 32s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 1m6s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s

Line 1: school name (bold) + school type (muted gray)
Line 2: R,W&M %  ·  Progress score + band  ·  Pupil count
Line 3: local authority  ·  distance (location searches)

Actions (View / Add) are vertically centred on the right across all lines.
Progress uses reading score, falling back to writing then maths. Removed
the old nameScore grouping and separate meta/progress rows in favour of
the cleaner 3-line structure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 09:27:22 +00:00
parent a11e322017
commit c49593d4d6
2 changed files with 171 additions and 237 deletions

View File

@@ -1,10 +1,12 @@
.row { .row {
display: flex; display: flex;
align-items: center;
gap: 1rem;
background: var(--bg-card, white); background: var(--bg-card, white);
border: 1px solid var(--border-color, #e5dfd5); border: 1px solid var(--border-color, #e5dfd5);
border-left: 3px solid transparent; border-left: 3px solid transparent;
border-radius: 8px; border-radius: 8px;
padding: 0.875rem 1rem; padding: 0.75rem 1rem;
transition: border-color 0.15s ease, box-shadow 0.15s ease; transition: border-color 0.15s ease, box-shadow 0.15s ease;
animation: rowFadeIn 0.3s ease-out both; animation: rowFadeIn 0.3s ease-out both;
} }
@@ -20,37 +22,24 @@
} }
@keyframes rowFadeIn { @keyframes rowFadeIn {
from { from { opacity: 0; transform: translateY(6px); }
opacity: 0; to { opacity: 1; transform: translateY(0); }
transform: translateY(8px);
}
to {
opacity: 1;
transform: translateY(0);
}
} }
.rowMain { /* ── Left content column ─────────────────────────────── */
.rowContent {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.3rem; gap: 0.2rem;
} }
/* Line 1: name+score on the left, actions pinned right */ /* Line 1: name + type */
.rowTop { .line1 {
display: flex;
align-items: center;
gap: 1rem;
}
/* Name + score grouped together on the left */
.nameScore {
display: flex; display: flex;
align-items: baseline; align-items: baseline;
gap: 0.75rem; gap: 0.625rem;
flex: 1;
min-width: 0; min-width: 0;
} }
@@ -62,65 +51,89 @@
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
min-width: 0;
flex-shrink: 1; flex-shrink: 1;
min-width: 0;
} }
.schoolName:hover { .schoolName:hover {
color: var(--accent-coral, #e07256); color: var(--accent-coral, #e07256);
} }
/* Score block: value + label inline */ .schoolType {
.scoreBlock { font-size: 0.8rem;
display: flex; color: var(--text-muted, #8a847a);
align-items: baseline;
gap: 0.3rem;
flex-shrink: 0;
white-space: nowrap; white-space: nowrap;
flex-shrink: 0;
} }
.scoreValue { /* Line 2: stats */
font-size: 1.0625rem; .line2 {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 0 1.25rem;
}
.stat {
display: inline-flex;
align-items: baseline;
gap: 0.3rem;
}
.statValue {
font-size: 0.9375rem;
font-weight: 700; font-weight: 700;
color: var(--text-primary, #1a1612); color: var(--text-primary, #1a1612);
font-family: var(--font-playfair), 'Playfair Display', serif; font-family: var(--font-playfair), 'Playfair Display', serif;
line-height: 1.2; display: inline-flex;
display: flex;
align-items: center; align-items: center;
gap: 0.2rem; gap: 0.2rem;
} }
.scoreNA { .statLabel {
font-size: 1rem;
color: var(--text-muted, #8a847a);
}
.scoreLabel {
font-size: 0.75rem; font-size: 0.75rem;
color: var(--text-muted, #8a847a); color: var(--text-muted, #8a847a);
white-space: nowrap; white-space: nowrap;
} }
/* Trend arrow */ /* Trend arrows */
.trend { .trend {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
margin-left: 2px; margin-left: 1px;
} }
.trendUp { .trendUp { color: var(--accent-teal, #2d7d7d); }
color: var(--accent-teal, #2d7d7d); .trendDown { color: var(--accent-coral, #e07256); }
} .trendStable { color: var(--text-muted, #8a847a); }
.trendDown { /* Line 3: location */
color: var(--accent-coral, #e07256); .line3 {
} display: flex;
align-items: center;
.trendStable { flex-wrap: wrap;
gap: 0 0;
font-size: 0.8rem;
color: var(--text-muted, #8a847a); color: var(--text-muted, #8a847a);
} }
/* Action buttons — pinned right, slightly larger on desktop */ .line3 span:not(:last-child)::after {
content: '·';
margin: 0 0.4rem;
color: var(--border-color, #e5dfd5);
}
.distanceBadge {
display: inline-block;
padding: 0.0625rem 0.375rem;
font-size: 0.75rem;
font-weight: 600;
background: var(--accent-teal, #2d7d7d);
color: white;
border-radius: 3px;
}
/* ── Right actions column ────────────────────────────── */
.rowActions { .rowActions {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -128,7 +141,7 @@
flex-shrink: 0; flex-shrink: 0;
} }
/* Equalise <a> and <button> rendering */ /* Equalise <a> and <button> */
.rowActions > * { .rowActions > * {
height: 2rem; height: 2rem;
line-height: 1; line-height: 1;
@@ -198,102 +211,33 @@
color: var(--text-primary, #1a1612); color: var(--text-primary, #1a1612);
} }
/* Line 2: Meta tags */ /* ── Mobile ──────────────────────────────────────────── */
.rowMeta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.25rem 0;
font-size: 0.8rem;
color: var(--text-muted, #8a847a);
}
.rowMeta span:not(:last-child)::after {
content: '·';
margin: 0 0.4rem;
color: var(--border-color, #e5dfd5);
}
.distanceBadge {
display: inline-block;
padding: 0.0625rem 0.375rem;
font-size: 0.75rem;
font-weight: 600;
background: var(--accent-teal, #2d7d7d);
color: white;
border-radius: 3px;
margin-left: 0.25rem;
}
/* Line 3: Progress scores */
.rowProgress {
display: flex;
flex-wrap: wrap;
gap: 0.25rem 1rem;
margin-top: 0.125rem;
}
.progressItem {
font-size: 0.8rem;
color: var(--text-secondary, #5c564d);
}
.progressValue {
color: var(--text-primary, #1a1612);
margin: 0 0.25rem;
}
.progressBand {
font-style: normal;
font-size: 0.75rem;
color: var(--text-muted, #8a847a);
}
/* Mobile */
@media (max-width: 640px) { @media (max-width: 640px) {
.row { .row {
padding: 0.75rem;
border-radius: 6px;
}
.rowTop {
flex-wrap: wrap; flex-wrap: wrap;
gap: 0.5rem; padding: 0.75rem;
gap: 0.625rem;
} }
/* School name takes full width, score+actions wrap below */ .rowContent {
.nameScore {
flex-basis: 100%; flex-basis: 100%;
min-width: 0;
} }
.schoolName { .schoolName {
white-space: normal; white-space: normal;
} }
/* Score block stays inline with label visible */ .line2 {
.scoreBlock { gap: 0 1rem;
align-items: baseline;
} }
.scoreLabel {
font-size: 0.7rem;
}
/* Actions move to end of the wrapped row */
.rowActions { .rowActions {
margin-left: auto; width: 100%;
gap: 0.375rem; gap: 0.375rem;
} }
.btnView, .rowActions > * {
.btnCompare, flex: 1;
.btnRemove { justify-content: center;
padding: 0.4375rem 0.875rem;
font-size: 0.875rem;
}
.rowProgress {
gap: 0.375rem 0.75rem;
} }
} }

View File

@@ -1,6 +1,10 @@
/** /**
* SchoolRow Component * SchoolRow Component
* Compact row-based school display for search results list view * Three-line row for school search results
*
* Line 1: School name · School type
* Line 2: R,W&M % · Progress score · Pupil count
* Line 3: Local authority · Distance
*/ */
import type { School } from '@/lib/types'; import type { School } from '@/lib/types';
@@ -25,10 +29,9 @@ export function SchoolRow({
}: SchoolRowProps) { }: SchoolRowProps) {
const trend = calculateTrend(school.rwm_expected_pct, school.prev_rwm_expected_pct); const trend = calculateTrend(school.rwm_expected_pct, school.prev_rwm_expected_pct);
const hasProgress = // Use reading progress as representative; fall back to writing, then maths
school.reading_progress != null || const progressScore =
school.writing_progress != null || school.reading_progress ?? school.writing_progress ?? school.maths_progress ?? null;
school.maths_progress != null;
const handleCompareClick = () => { const handleCompareClick = () => {
if (isInCompare) { if (isInCompare) {
@@ -40,18 +43,24 @@ export function SchoolRow({
return ( return (
<div className={`${styles.row} ${isInCompare ? styles.rowInCompare : ''}`}> <div className={`${styles.row} ${isInCompare ? styles.rowInCompare : ''}`}>
<div className={styles.rowMain}> {/* Left: three content lines */}
{/* Line 1: Name + score on left, actions pinned right */} <div className={styles.rowContent}>
<div className={styles.rowTop}>
<div className={styles.nameScore}> {/* Line 1: School name + type */}
<div className={styles.line1}>
<a href={`/school/${school.urn}`} className={styles.schoolName}> <a href={`/school/${school.urn}`} className={styles.schoolName}>
{school.school_name} {school.school_name}
</a> </a>
{school.school_type && (
<span className={styles.schoolType}>{school.school_type}</span>
)}
</div>
<div className={styles.scoreBlock}> {/* Line 2: Key stats */}
<div className={styles.line2}>
{school.rwm_expected_pct != null ? ( {school.rwm_expected_pct != null ? (
<> <span className={styles.stat}>
<strong className={styles.scoreValue}> <strong className={styles.statValue}>
{formatPercentage(school.rwm_expected_pct, 0)} {formatPercentage(school.rwm_expected_pct, 0)}
</strong> </strong>
{school.prev_rwm_expected_pct != null && ( {school.prev_rwm_expected_pct != null && (
@@ -60,30 +69,68 @@ export function SchoolRow({
title={`Previous year: ${formatPercentage(school.prev_rwm_expected_pct)}`} title={`Previous year: ${formatPercentage(school.prev_rwm_expected_pct)}`}
> >
{trend === 'up' && ( {trend === 'up' && (
<svg viewBox="0 0 16 16" fill="none" width="10" height="10"> <svg viewBox="0 0 16 16" fill="none" width="9" height="9">
<path d="M8 3L14 10H2L8 3Z" fill="currentColor" /> <path d="M8 3L14 10H2L8 3Z" fill="currentColor" />
</svg> </svg>
)} )}
{trend === 'down' && ( {trend === 'down' && (
<svg viewBox="0 0 16 16" fill="none" width="10" height="10"> <svg viewBox="0 0 16 16" fill="none" width="9" height="9">
<path d="M8 13L2 6H14L8 13Z" fill="currentColor" /> <path d="M8 13L2 6H14L8 13Z" fill="currentColor" />
</svg> </svg>
)} )}
{trend === 'stable' && ( {trend === 'stable' && (
<svg viewBox="0 0 16 16" fill="none" width="10" height="10"> <svg viewBox="0 0 16 16" fill="none" width="9" height="9">
<rect x="2" y="7" width="12" height="2" rx="1" fill="currentColor" /> <rect x="2" y="7" width="12" height="2" rx="1" fill="currentColor" />
</svg> </svg>
)} )}
</span> </span>
)} )}
</> <span className={styles.statLabel}>R, W &amp; M</span>
</span>
) : ( ) : (
<span className={styles.scoreNA}></span> <span className={styles.stat}>
<strong className={styles.statValue}></strong>
<span className={styles.statLabel}>R, W &amp; M</span>
</span>
)}
{progressScore != null && (
<span className={styles.stat}>
<strong className={styles.statValue}>{formatProgress(progressScore)}</strong>
<span className={styles.statLabel}>
progress · {progressBand(progressScore)}
</span>
</span>
)}
{school.total_pupils != null && (
<span className={styles.stat}>
<strong className={styles.statValue}>{school.total_pupils.toLocaleString()}</strong>
<span className={styles.statLabel}>pupils</span>
</span>
)} )}
<span className={styles.scoreLabel}>R, W &amp; M</span>
</div>
</div> </div>
{/* Line 3: Location + distance */}
<div className={styles.line3}>
{school.local_authority && (
<span>{school.local_authority}</span>
)}
{isLocationSearch && school.distance != null && (
<span className={styles.distanceBadge}>
{school.distance.toFixed(1)} mi
</span>
)}
{!isLocationSearch &&
school.religious_denomination &&
school.religious_denomination !== 'Does not apply' && (
<span>{school.religious_denomination}</span>
)}
</div>
</div>
{/* Right: actions, vertically centred */}
<div className={styles.rowActions}> <div className={styles.rowActions}>
<a href={`/school/${school.urn}`} className={styles.btnView}> <a href={`/school/${school.urn}`} className={styles.btnView}>
View View
@@ -98,62 +145,5 @@ export function SchoolRow({
)} )}
</div> </div>
</div> </div>
{/* Line 2: Meta tags */}
<div className={styles.rowMeta}>
{school.local_authority && <span>{school.local_authority}</span>}
{school.school_type && <span>{school.school_type}</span>}
{!isLocationSearch &&
school.religious_denomination &&
school.religious_denomination !== 'Does not apply' && (
<span>{school.religious_denomination}</span>
)}
{isLocationSearch && school.distance != null && (
<span className={styles.distanceBadge}>
{school.distance.toFixed(1)} mi
</span>
)}
</div>
{/* Line 3: Progress scores with plain-language bands */}
{hasProgress && (
<div className={styles.rowProgress}>
{school.reading_progress != null && (
<span className={styles.progressItem}>
Reading{' '}
<strong className={styles.progressValue}>
{formatProgress(school.reading_progress)}
</strong>
<em className={styles.progressBand}>
{progressBand(school.reading_progress)}
</em>
</span>
)}
{school.writing_progress != null && (
<span className={styles.progressItem}>
Writing{' '}
<strong className={styles.progressValue}>
{formatProgress(school.writing_progress)}
</strong>
<em className={styles.progressBand}>
{progressBand(school.writing_progress)}
</em>
</span>
)}
{school.maths_progress != null && (
<span className={styles.progressItem}>
Maths{' '}
<strong className={styles.progressValue}>
{formatProgress(school.maths_progress)}
</strong>
<em className={styles.progressBand}>
{progressBand(school.maths_progress)}
</em>
</span>
)}
</div>
)}
</div>
</div>
); );
} }