feat(row): redesign to clean 3-line layout with stats on second row
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:
@@ -1,6 +1,10 @@
|
||||
/**
|
||||
* 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';
|
||||
@@ -25,10 +29,9 @@ export function SchoolRow({
|
||||
}: SchoolRowProps) {
|
||||
const trend = calculateTrend(school.rwm_expected_pct, school.prev_rwm_expected_pct);
|
||||
|
||||
const hasProgress =
|
||||
school.reading_progress != null ||
|
||||
school.writing_progress != null ||
|
||||
school.maths_progress != null;
|
||||
// Use reading progress as representative; fall back to writing, then maths
|
||||
const progressScore =
|
||||
school.reading_progress ?? school.writing_progress ?? school.maths_progress ?? null;
|
||||
|
||||
const handleCompareClick = () => {
|
||||
if (isInCompare) {
|
||||
@@ -40,118 +43,105 @@ export function SchoolRow({
|
||||
|
||||
return (
|
||||
<div className={`${styles.row} ${isInCompare ? styles.rowInCompare : ''}`}>
|
||||
<div className={styles.rowMain}>
|
||||
{/* Line 1: Name + score on left, actions pinned right */}
|
||||
<div className={styles.rowTop}>
|
||||
<div className={styles.nameScore}>
|
||||
<a href={`/school/${school.urn}`} className={styles.schoolName}>
|
||||
{school.school_name}
|
||||
</a>
|
||||
{/* Left: three content lines */}
|
||||
<div className={styles.rowContent}>
|
||||
|
||||
<div className={styles.scoreBlock}>
|
||||
{school.rwm_expected_pct != null ? (
|
||||
<>
|
||||
<strong className={styles.scoreValue}>
|
||||
{formatPercentage(school.rwm_expected_pct, 0)}
|
||||
</strong>
|
||||
{school.prev_rwm_expected_pct != null && (
|
||||
<span
|
||||
className={`${styles.trend} ${styles[`trend${trend.charAt(0).toUpperCase() + trend.slice(1)}`]}`}
|
||||
title={`Previous year: ${formatPercentage(school.prev_rwm_expected_pct)}`}
|
||||
>
|
||||
{trend === 'up' && (
|
||||
<svg viewBox="0 0 16 16" fill="none" width="10" height="10">
|
||||
<path d="M8 3L14 10H2L8 3Z" fill="currentColor" />
|
||||
</svg>
|
||||
)}
|
||||
{trend === 'down' && (
|
||||
<svg viewBox="0 0 16 16" fill="none" width="10" height="10">
|
||||
<path d="M8 13L2 6H14L8 13Z" fill="currentColor" />
|
||||
</svg>
|
||||
)}
|
||||
{trend === 'stable' && (
|
||||
<svg viewBox="0 0 16 16" fill="none" width="10" height="10">
|
||||
<rect x="2" y="7" width="12" height="2" rx="1" fill="currentColor" />
|
||||
</svg>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className={styles.scoreNA}>—</span>
|
||||
)}
|
||||
<span className={styles.scoreLabel}>R, W & M</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.rowActions}>
|
||||
<a href={`/school/${school.urn}`} className={styles.btnView}>
|
||||
View
|
||||
</a>
|
||||
{(onAddToCompare || onRemoveFromCompare) && (
|
||||
<button
|
||||
onClick={handleCompareClick}
|
||||
className={isInCompare ? styles.btnRemove : styles.btnCompare}
|
||||
>
|
||||
{isInCompare ? '✓ Remove' : '+ Add'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{/* Line 1: School name + type */}
|
||||
<div className={styles.line1}>
|
||||
<a href={`/school/${school.urn}`} className={styles.schoolName}>
|
||||
{school.school_name}
|
||||
</a>
|
||||
{school.school_type && (
|
||||
<span className={styles.schoolType}>{school.school_type}</span>
|
||||
)}
|
||||
</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>
|
||||
)}
|
||||
{/* Line 2: Key stats */}
|
||||
<div className={styles.line2}>
|
||||
{school.rwm_expected_pct != null ? (
|
||||
<span className={styles.stat}>
|
||||
<strong className={styles.statValue}>
|
||||
{formatPercentage(school.rwm_expected_pct, 0)}
|
||||
</strong>
|
||||
{school.prev_rwm_expected_pct != null && (
|
||||
<span
|
||||
className={`${styles.trend} ${styles[`trend${trend.charAt(0).toUpperCase() + trend.slice(1)}`]}`}
|
||||
title={`Previous year: ${formatPercentage(school.prev_rwm_expected_pct)}`}
|
||||
>
|
||||
{trend === 'up' && (
|
||||
<svg viewBox="0 0 16 16" fill="none" width="9" height="9">
|
||||
<path d="M8 3L14 10H2L8 3Z" fill="currentColor" />
|
||||
</svg>
|
||||
)}
|
||||
{trend === 'down' && (
|
||||
<svg viewBox="0 0 16 16" fill="none" width="9" height="9">
|
||||
<path d="M8 13L2 6H14L8 13Z" fill="currentColor" />
|
||||
</svg>
|
||||
)}
|
||||
{trend === 'stable' && (
|
||||
<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" />
|
||||
</svg>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
<span className={styles.statLabel}>R, W & M</span>
|
||||
</span>
|
||||
) : (
|
||||
<span className={styles.stat}>
|
||||
<strong className={styles.statValue}>—</strong>
|
||||
<span className={styles.statLabel}>R, W & 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>
|
||||
)}
|
||||
</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>
|
||||
|
||||
{/* 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>
|
||||
|
||||
{/* Right: actions, vertically centred */}
|
||||
<div className={styles.rowActions}>
|
||||
<a href={`/school/${school.urn}`} className={styles.btnView}>
|
||||
View
|
||||
</a>
|
||||
{(onAddToCompare || onRemoveFromCompare) && (
|
||||
<button
|
||||
onClick={handleCompareClick}
|
||||
className={isInCompare ? styles.btnRemove : styles.btnCompare}
|
||||
>
|
||||
{isInCompare ? '✓ Remove' : '+ Add'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user