feat: persistent Coaster Mode toggle in header top-right
All checks were successful
Build and Deploy / Build & Push (push) Successful in 53s

- Moves the coaster toggle out of WeekNav and into the homepage header
  top-right as "🎢 Coaster Mode", alongside the parks open badge
- State is stored in localStorage ("coasterMode") so the preference
  persists across sessions and page refreshes
- Dropped the ?coasters=1 URL param entirely; the server always fetches
  both rideCounts and coasterCounts, and HomePageClient picks which to
  display client-side — no flash or server round-trip on toggle
- Individual park pages: LiveRidePanel reads localStorage on mount and
  pre-selects the Coasters Only filter when Coaster Mode is active
- Extracted HomePageClient (client component) to own the full homepage
  UI; page.tsx is now pure data-fetching

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Josh Wright
2026-04-05 08:36:38 -04:00
parent 8c3841d9a5
commit 5b575f962e
4 changed files with 207 additions and 146 deletions

View File

@@ -7,8 +7,6 @@ interface WeekNavProps {
weekStart: string; // YYYY-MM-DD (Sunday)
weekDates: string[]; // 7 dates YYYY-MM-DD
isCurrentWeek: boolean;
coastersOnly: boolean;
hasCoasterData: boolean;
}
const MONTHS = [
@@ -33,15 +31,10 @@ function shiftWeek(weekStart: string, delta: number): string {
return d.toISOString().slice(0, 10);
}
export function WeekNav({ weekStart, weekDates, isCurrentWeek, coastersOnly, hasCoasterData }: WeekNavProps) {
export function WeekNav({ weekStart, weekDates, isCurrentWeek }: WeekNavProps) {
const router = useRouter();
const weekParam = `week=${weekStart}`;
const nav = (delta: number) => {
const base = `/?week=${shiftWeek(weekStart, delta)}`;
router.push(coastersOnly ? `${base}&coasters=1` : base);
};
const toggleCoasters = () => {
router.push(coastersOnly ? `/?${weekParam}` : `/?${weekParam}&coasters=1`);
router.push(`/?week=${shiftWeek(weekStart, delta)}`);
};
useEffect(() => {
@@ -99,30 +92,6 @@ export function WeekNav({ weekStart, weekDates, isCurrentWeek, coastersOnly, has
>
</button>
{hasCoasterData && (
<button
onClick={toggleCoasters}
style={{
marginLeft: 8,
display: "flex",
alignItems: "center",
gap: 5,
padding: "4px 12px",
borderRadius: 20,
border: coastersOnly ? "1px solid var(--color-accent)" : "1px solid var(--color-border)",
background: coastersOnly ? "var(--color-accent-muted)" : "var(--color-surface)",
color: coastersOnly ? "var(--color-accent)" : "var(--color-text-muted)",
fontSize: "0.72rem",
fontWeight: 600,
cursor: "pointer",
transition: "background 150ms ease, border-color 150ms ease, color 150ms ease",
whiteSpace: "nowrap",
}}
>
🎢 Coasters
</button>
)}
</div>
);
}