feat(school-detail): move Back to a standalone link, dock "Back to top" in the nav

Replicate the Autotrader pattern: pull the page-back control out of the
sticky section-nav bar and place a standalone "← Back" text link above the
header card, on the page background, where it scrolls away with the page.
It keeps the context-aware behaviour (router.back → /search fallback); the
secondary view gains the same fallback for parity (it previously used a bare
router.back() that dead-ends on deep links).

The pinned slot the Back button vacated now holds a "↑ Top" control that
smooth-scrolls to the top, so the sticky bar keeps a useful affordance.
Applies to both primary and secondary detail views.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tudor
2026-07-01 14:48:17 +01:00
co-authored by Claude Opus 4.8
parent ce2bfea91b
commit 14474eccf1
4 changed files with 81 additions and 4 deletions
+14 -3
View File
@@ -106,6 +106,10 @@ export function SchoolDetailView({
}
};
const scrollToTop = () => {
if (typeof window !== 'undefined') window.scrollTo({ top: 0, behavior: 'smooth' });
};
useEffect(() => {
const el = sectionLinksRef.current;
if (!el) return;
@@ -306,6 +310,13 @@ export function SchoolDetailView({
return (
<div className={styles.container}>
{/* Standalone back link, above the header — returns to wherever the
user came from. Scrolls away with the page (the sticky bar keeps a
"back to top" control in its place). */}
<button type="button" onClick={handleBack} className={styles.topBack}>
<span aria-hidden="true"></span> Back
</button>
{/* Header */}
<header className={styles.header}>
<div className={styles.headerContent}>
@@ -439,9 +450,9 @@ export function SchoolDetailView({
{/* Sticky Section Navigation — docks under the global header */}
<nav className={styles.sectionNav} aria-label="Page sections">
<button onClick={handleBack} className={styles.sectionNavBack} aria-label="Back">
<span aria-hidden="true"></span>
<span className={styles.sectionNavBackLabel}>Back</span>
<button onClick={scrollToTop} className={styles.sectionNavBack} aria-label="Back to top">
<span aria-hidden="true"></span>
<span className={styles.sectionNavBackLabel}>Top</span>
</button>
{/* Desktop: scrolling section links */}