mirror of
https://github.com/ChiChou/entdb.git
synced 2026-12-06 03:33:50 +01:00
feat(home): timeline at every size, with a toolbar and a grid view
- A centred toolbar under the filter: Timeline | Grid, the platform tabs (or All builds in the grid) in one fixed-width slot, and Time Machine. The header keeps one row on home. - The grid view returns as ?view=grid / ?view=all, remembered per browser. - Both views share one frame, centred at the timeline's content width. - Each version's builds read oldest to newest, every line full but the first; Home/End still reach the latest and the oldest. - The filter count sits under the toolbar, moving nothing; the Mac tab is always "macOS". - The panel is pinned only where the window fits it: no inner scroll bar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e31bd84c24
commit
9b1acb78f8
8 files changed
+562
-592
No files matched your search
@@ -1,41 +1,15 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* The directory on very wide screens: one timeline in sight at a time,
|
||||
* chosen with tabs (iOS; the Mac, OS X running on into macOS), and beside it
|
||||
* the latest release.
|
||||
*
|
||||
* - The tabs say what is behind them (how many builds, as a tooltip), so
|
||||
* the one not shown is still found, with number keys as in the Time
|
||||
* Machine. They sit in the header (sticky); the way into the Time
|
||||
* Machine heads the column on the right.
|
||||
* - iOS first: the most releases, and what most visits are about (a Mac
|
||||
* visitor is as likely to be after iOS). The choice is in the URL
|
||||
* (?platform=mac, shareable) and remembered for the next visit; a URL's
|
||||
* wins.
|
||||
* - The column on the right is always the line's latest release: its
|
||||
* figures (each a link to what it counts; "+N −M" to what changed), how
|
||||
* the line grew, and its largest topics as a cloud. Any other build: its
|
||||
* card, opened beside it in the timeline.
|
||||
*/
|
||||
|
||||
import { ArrowRight, History } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { BetaBadge } from "@/components/beta-badge";
|
||||
import { HeaderPortal } from "@/components/header-portal";
|
||||
import {
|
||||
type Figures,
|
||||
byVersionDesc,
|
||||
useFigures,
|
||||
} from "@/components/latest-releases";
|
||||
import {
|
||||
ReleaseTimeline,
|
||||
buildKey,
|
||||
widestRow,
|
||||
} from "@/components/release-timeline";
|
||||
import { ReleaseTimeline, buildKey } from "@/components/release-timeline";
|
||||
import {
|
||||
changesHref,
|
||||
compact,
|
||||
@@ -58,8 +32,6 @@ export interface DirectoryLine {
|
||||
}
|
||||
|
||||
const STORAGE_KEY = "entdb:directory-line";
|
||||
/** Where this layout starts (min-[1800px] in the classes). */
|
||||
const WIDE_PX = 1800;
|
||||
/** The URL's record of the chosen line: ?platform=mac. */
|
||||
const PARAM = "platform";
|
||||
|
||||
@@ -75,7 +47,15 @@ function isTyping(target: EventTarget | null) {
|
||||
);
|
||||
}
|
||||
|
||||
export function DirectoryTabs({ lines }: { lines: DirectoryLine[] }) {
|
||||
export function DirectoryTabs({
|
||||
lines,
|
||||
toolbar,
|
||||
}: {
|
||||
lines: DirectoryLine[];
|
||||
/** Above the timeline (and panel), as wide as they are together, given
|
||||
* the platform tabs to hold. */
|
||||
toolbar?: (tabs: React.ReactNode) => React.ReactNode;
|
||||
}) {
|
||||
const params = useSearchParams();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
@@ -122,8 +102,6 @@ export function DirectoryTabs({ lines }: { lines: DirectoryLine[] }) {
|
||||
const onKey = (event: KeyboardEvent) => {
|
||||
if (event.metaKey || event.ctrlKey || event.altKey) return;
|
||||
if (isTyping(event.target)) return;
|
||||
// Only where the tabs are shown (mounted at every width, hidden below).
|
||||
if (!window.matchMedia(`(min-width: ${WIDE_PX}px)`).matches) return;
|
||||
const next = lines[Number(event.key) - 1];
|
||||
if (!next) return;
|
||||
event.preventDefault();
|
||||
@@ -139,7 +117,6 @@ export function DirectoryTabs({ lines }: { lines: DirectoryLine[] }) {
|
||||
);
|
||||
|
||||
if (!line) return null;
|
||||
const widest = widestRow(lines.map((l) => l.sources));
|
||||
const head = line.sources[0];
|
||||
const latest = head ? [...head.list].sort(byVersionDesc)[0] : undefined;
|
||||
// The whole line, oldest first (OS X, then macOS), for the growth chart.
|
||||
@@ -151,57 +128,60 @@ export function DirectoryTabs({ lines }: { lines: DirectoryLine[] }) {
|
||||
// The tabs: in the header (sticky: the timeline is taller than the
|
||||
// window), centred with the filter; compact,
|
||||
// like the header's other toggles, each line's build count its tooltip.
|
||||
// The tabs, handed to the toolbar (with the other ways of seeing the
|
||||
// list) rather than taking a row of their own.
|
||||
const tabs = (
|
||||
<div
|
||||
role="tablist"
|
||||
aria-label="Platform"
|
||||
className="inline-flex h-9 shrink-0 items-stretch rounded-lg border border-border bg-muted/30 p-[3px]"
|
||||
>
|
||||
{lines.map((l, n) => {
|
||||
const active = l === line;
|
||||
const count = l.sources.reduce((sum, s) => sum + s.list.length, 0);
|
||||
return (
|
||||
<button
|
||||
key={l.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={active}
|
||||
aria-controls={`timeline-${l.id}`}
|
||||
aria-keyshortcuts={String(n + 1)}
|
||||
title={`${count} builds (${n + 1})`}
|
||||
onClick={() => choose(l.id)}
|
||||
className={cn(
|
||||
// Equal widths: the group never resizes (AGENTS.md).
|
||||
"flex w-[4.5rem] items-center justify-center rounded-md text-sm transition-colors",
|
||||
active
|
||||
? "bg-background font-medium text-foreground shadow-sm"
|
||||
: "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{l.title}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
// Then the timeline, and beside it the latest release (the panel takes
|
||||
// more of the width on very large screens).
|
||||
return (
|
||||
<>
|
||||
{/* In the header's centre, just before the filter (the portal is a
|
||||
row: order-first puts it ahead of the filter rendered earlier). */}
|
||||
<HeaderPortal>
|
||||
<div
|
||||
role="tablist"
|
||||
aria-label="Platform"
|
||||
className="order-first hidden h-9 shrink-0 items-stretch rounded-lg border border-border bg-muted/30 p-[3px] min-[1800px]:inline-flex"
|
||||
>
|
||||
{lines.map((l, n) => {
|
||||
const active = l === line;
|
||||
const count = l.sources.reduce((sum, s) => sum + s.list.length, 0);
|
||||
return (
|
||||
<button
|
||||
key={l.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={active}
|
||||
aria-controls={`timeline-${l.id}`}
|
||||
aria-keyshortcuts={String(n + 1)}
|
||||
title={`${count} builds (${n + 1})`}
|
||||
onClick={() => choose(l.id)}
|
||||
className={cn(
|
||||
"flex items-center rounded-md px-3 text-sm transition-colors",
|
||||
active
|
||||
? "bg-background font-medium text-foreground shadow-sm"
|
||||
: "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{l.title}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</HeaderPortal>
|
||||
{/* Timeline and panel centred together, each its own width: the
|
||||
timeline as wide as the widest row of either line (switching
|
||||
lines moves nothing; no empty stretch where a line's rows are
|
||||
short), the panel fixed. Widths are the timeline's own
|
||||
{/* Timeline (and on very wide screens the panel) centred, each its
|
||||
own width: the timeline as wide as the widest row of either line
|
||||
(switching lines moves nothing; no empty stretch where a line's
|
||||
rows are short; narrower screens: their width), the panel fixed. Widths are the timeline's own
|
||||
(release-timeline.tsx): a build 6.5rem + 0.25rem gap, the axis
|
||||
6.5rem + 1.5rem gap; a size up from 2400px. */}
|
||||
<div className="grid grid-cols-[auto_26rem] items-start justify-center gap-x-10 min-[2400px]:grid-cols-[auto_40rem] min-[2400px]:gap-x-16">
|
||||
<div className="grid grid-cols-1 items-start min-[1800px]:grid-cols-[minmax(0,1fr)_26rem] min-[1800px]:gap-x-10 min-[2400px]:grid-cols-[minmax(0,1fr)_40rem] min-[2400px]:gap-x-16">
|
||||
{toolbar?.(tabs)}
|
||||
<section
|
||||
id={`timeline-${line.id}`}
|
||||
role="tabpanel"
|
||||
aria-label={line.title}
|
||||
className="[--axis:8rem] [--leaf:6.75rem] min-[2400px]:[--axis:9.5rem] min-[2400px]:[--leaf:8.875rem]"
|
||||
style={{ width: `calc(${widest} * var(--leaf) + var(--axis))` }}
|
||||
// The frame's width for it (oslist.tsx).
|
||||
className="w-[var(--tw)] max-w-full"
|
||||
>
|
||||
<ReleaseTimeline
|
||||
key={line.id}
|
||||
@@ -220,17 +200,6 @@ export function DirectoryTabs({ lines }: { lines: DirectoryLine[] }) {
|
||||
line grew; any other build: its card, beside it in the line. */}
|
||||
{head && latest && (
|
||||
<BuildPanel
|
||||
lead={
|
||||
<Link
|
||||
href="/time-machine"
|
||||
className="depth-banner group relative inline-flex items-center gap-2 overflow-hidden rounded-full border px-4 py-2 text-sm font-medium transition-colors hover:border-primary/50"
|
||||
>
|
||||
<span className="depth-stars" aria-hidden="true" />
|
||||
<History className="relative h-4 w-4 text-primary" />
|
||||
<span className="relative">Time Machine</span>
|
||||
<ArrowRight className="relative h-4 w-4 text-muted-foreground transition-transform group-hover:translate-x-0.5" />
|
||||
</Link>
|
||||
}
|
||||
group={head.group}
|
||||
os={latest}
|
||||
figures={figures[buildKey(head.group, latest)]}
|
||||
@@ -254,14 +223,11 @@ export function DirectoryTabs({ lines }: { lines: DirectoryLine[] }) {
|
||||
* very wide screen doesn't stretch it.
|
||||
*/
|
||||
function BuildPanel({
|
||||
lead,
|
||||
group,
|
||||
os,
|
||||
figures,
|
||||
children,
|
||||
}: {
|
||||
/** First in the column, above the release (the way into the Time Machine). */
|
||||
lead?: React.ReactNode;
|
||||
group: string;
|
||||
os: OS;
|
||||
figures?: Figures;
|
||||
@@ -278,11 +244,14 @@ function BuildPanel({
|
||||
return (
|
||||
<aside
|
||||
aria-live="polite"
|
||||
className="sticky top-20 max-h-[calc(100vh-6rem)] overflow-y-auto"
|
||||
// Very wide screens only: below, there's no room beside the timeline
|
||||
// (and no hover to bring other builds into it). Kept in view while
|
||||
// the timeline scrolls only where the window is tall enough for all
|
||||
// of it (under 600px, plus the header); in a shorter window it scrolls
|
||||
// with the page: never a scroll bar of its own.
|
||||
className="hidden min-[1800px]:block [@media(min-height:760px)]:sticky [@media(min-height:760px)]:top-20"
|
||||
>
|
||||
<div className="max-w-[40rem] space-y-7 min-[2400px]:max-w-none">
|
||||
{lead && <div>{lead}</div>}
|
||||
|
||||
{/* One line: the build is right beside, outlined in the timeline;
|
||||
this only names it (for one hovered far down the line). */}
|
||||
<header className="flex flex-wrap items-baseline gap-x-3 gap-y-1 text-sm text-muted-foreground">
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* The directory as a grid, the home page's earlier view, kept for whoever
|
||||
* prefers it (?view=grid): a section per platform (iOS, macOS, OS X), each
|
||||
* its major releases (the latest of each major; every build of the newest
|
||||
* two), or with All builds (?view=all) every build, by major.
|
||||
*/
|
||||
|
||||
import Link from "next/link";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { BetaBadge } from "@/components/beta-badge";
|
||||
import { getPlatformName } from "@/components/oslist";
|
||||
import type { Group, OS } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/** Up to four cards a row: a row is read, a long one isn't. */
|
||||
const GRID = "grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4";
|
||||
|
||||
function byVersionDesc(a: OS, b: OS) {
|
||||
const x = a.version.split(".").map(Number);
|
||||
const y = b.version.split(".").map(Number);
|
||||
for (let i = 0; i < Math.max(x.length, y.length); i++) {
|
||||
const d = (y[i] ?? 0) - (x[i] ?? 0);
|
||||
if (d) return d;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Builds by major version, newest first. */
|
||||
function byMajor(list: OS[]) {
|
||||
const bucket = new Map<string, OS[]>();
|
||||
for (const os of [...list].sort(byVersionDesc)) {
|
||||
const major = os.version.split(".")[0];
|
||||
bucket.set(major, [...(bucket.get(major) ?? []), os]);
|
||||
}
|
||||
return [...bucket];
|
||||
}
|
||||
|
||||
/**
|
||||
* The major releases: every OS X release; for iOS and macOS, every build of
|
||||
* the newest two majors, the latest build of each older one.
|
||||
*/
|
||||
function majorReleases(group: Group) {
|
||||
if (group.name === "osx") return [...group.list].sort(byVersionDesc);
|
||||
const majors = byMajor(group.list);
|
||||
return majors.flatMap(([, builds], i) =>
|
||||
i < 2 ? builds : builds.slice(0, 1),
|
||||
);
|
||||
}
|
||||
|
||||
export function GridView({
|
||||
groups,
|
||||
all,
|
||||
}: {
|
||||
groups: Group[];
|
||||
/** Every build (All builds), else the major releases. */
|
||||
all: boolean;
|
||||
}) {
|
||||
return (
|
||||
// In the home page's frame (oslist.tsx), as wide as the timeline.
|
||||
<div>
|
||||
{groups.map((group) => (
|
||||
<PlatformSection key={group.name} group={group} all={all} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PlatformSection({ group, all }: { group: Group; all: boolean }) {
|
||||
const releases = useMemo(() => majorReleases(group), [group]);
|
||||
const majors = useMemo(() => byMajor(group.list), [group]);
|
||||
return (
|
||||
<section id={group.name} className="mt-10 scroll-mt-20 first:mt-0">
|
||||
<h2 className="mb-3 flex items-baseline gap-2 text-xl font-semibold">
|
||||
{getPlatformName(group.name)}
|
||||
<span className="text-sm font-normal text-muted-foreground tabular-nums">
|
||||
{all ? `${group.list.length} builds` : `${releases.length} releases`}
|
||||
</span>
|
||||
</h2>
|
||||
{all ? (
|
||||
<div className="space-y-4">
|
||||
{majors.map(([major, builds]) => (
|
||||
<div key={major}>
|
||||
<h3 className="mb-2 text-xs font-medium text-muted-foreground">
|
||||
{getPlatformName(group.name)} {major}
|
||||
</h3>
|
||||
<ul className={GRID}>
|
||||
{builds.map((os) => (
|
||||
<Card key={os.build} group={group.name} os={os} />
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<ul className={GRID}>
|
||||
{releases.map((os) => (
|
||||
<Card key={os.build} group={group.name} os={os} />
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function Card({ group, os }: { group: string; os: OS }) {
|
||||
const codename = !os.name.endsWith(os.version);
|
||||
return (
|
||||
<li className="list-none">
|
||||
<Link
|
||||
data-nav-item
|
||||
href={`/os/keys?os=${group}/${os.version}_${os.build}`}
|
||||
className={cn(
|
||||
"block rounded-lg border p-3 transition-colors hover:bg-accent/50",
|
||||
os.beta
|
||||
? "border-amber-400/50 hover:border-amber-500/70 dark:border-amber-500/40"
|
||||
: "border-border hover:border-foreground/20",
|
||||
)}
|
||||
>
|
||||
{codename && (
|
||||
<div className="mb-1 truncate text-xs text-muted-foreground">
|
||||
{os.name}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="flex items-center gap-1.5 font-medium">
|
||||
{os.version}
|
||||
{os.beta && <BetaBadge />}
|
||||
</span>
|
||||
<span className="font-mono text-xs text-muted-foreground">
|
||||
{os.build}
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
@@ -1,66 +1,53 @@
|
||||
/**
|
||||
* The home page while its lists load, shaped like each layout it becomes
|
||||
* (oslist.tsx), so nothing jumps when they arrive:
|
||||
*
|
||||
* - Phones: the one-line Time Machine, the grid (the platform filter is
|
||||
* in the header).
|
||||
* - Up to very wide: the Time Machine line, then a grid per platform.
|
||||
* - Very wide screens: rows of builds set against the axis, the version
|
||||
* labels, and the panel beside (the tabs are in the header).
|
||||
*
|
||||
* The Time Machine card is static: the real one, not a placeholder.
|
||||
* The home page while its lists load, shaped like what it becomes
|
||||
* (oslist.tsx, directory-tabs.tsx, release-timeline.tsx), so nothing jumps
|
||||
* when they arrive: the view toolbar, then the timeline (centred at its
|
||||
* width; beside it the panel, on very wide screens), or the grid.
|
||||
*/
|
||||
|
||||
import { TimeMachineCard } from "@/components/latest-releases";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
|
||||
/** Loading placeholders: iOS first (no codename line), then macOS, OS X. */
|
||||
/** Builds per version on the timeline: roughly iOS, newest first. */
|
||||
const ROWS = [4, 7, 8, 8, 8, 9, 9, 8, 5, 5, 4, 4, 5, 2, 2, 2, 4, 2, 3];
|
||||
|
||||
/** Placeholder widths that vary but don't flicker between renders. */
|
||||
const widths = ["w-12", "w-14", "w-16", "w-10", "w-14"];
|
||||
|
||||
/** The view toolbar's shape (view-toolbar.tsx). */
|
||||
function ToolbarSkeleton() {
|
||||
return (
|
||||
// Shaped like the toolbar (view-toolbar.tsx): one centred group.
|
||||
<div className="col-span-full mb-10 flex flex-wrap items-center justify-center gap-2 [@media(min-height:900px)]:mb-14">
|
||||
<Skeleton className="h-9 w-20 rounded-lg sm:w-[13.5rem]" />
|
||||
<Skeleton className="h-9 w-[9.5rem] rounded-lg" />
|
||||
<Skeleton className="h-9 w-36 rounded-lg" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** The grid view's sections (grid-view.tsx): iOS, macOS, OS X. */
|
||||
const SECTIONS = [
|
||||
{ cards: 12, codenames: false },
|
||||
{ cards: 8, codenames: true },
|
||||
{ cards: 4, codenames: true },
|
||||
];
|
||||
|
||||
/** Builds per version on the wide timeline: roughly iOS, newest first. */
|
||||
const ROWS = [4, 7, 8, 8, 8, 9, 9, 8, 5, 5, 4, 4, 5, 2, 2, 2, 4, 2, 3];
|
||||
|
||||
/** Placeholder widths that vary but don't flicker between renders. */
|
||||
const widths = ["w-12", "w-14", "w-16", "w-10", "w-14"];
|
||||
|
||||
export function HomeSkeleton({
|
||||
grid,
|
||||
section,
|
||||
sectionTitle,
|
||||
}: {
|
||||
/** The page's own classes, so the placeholders line up exactly. */
|
||||
grid: string;
|
||||
section: string;
|
||||
sectionTitle: string;
|
||||
}) {
|
||||
return (
|
||||
<div aria-busy="true" aria-label="Loading builds">
|
||||
{/* Up to very wide screens. */}
|
||||
<div className="min-[1800px]:hidden">
|
||||
{/* The way into the Time Machine (static: the real one). */}
|
||||
<div className="mx-auto mb-6 max-w-[80rem] sm:mb-8">
|
||||
<TimeMachineCard />
|
||||
</div>
|
||||
{SECTIONS.map(({ cards, codenames }, s) => (
|
||||
export function HomeSkeleton({ grid = false }: { grid?: boolean }) {
|
||||
if (grid)
|
||||
return (
|
||||
<div aria-busy="true" aria-label="Loading builds">
|
||||
<ToolbarSkeleton />
|
||||
{SECTIONS.map(({ cards, codenames }, n) => (
|
||||
// biome-ignore lint/suspicious/noArrayIndexKey: static placeholder sections
|
||||
<section key={s} className={section}>
|
||||
<div className={sectionTitle}>
|
||||
<Skeleton className="h-7 w-20" />
|
||||
<Skeleton className="h-4 w-16" />
|
||||
</div>
|
||||
<div className={grid}>
|
||||
<section key={n} className="mt-10 first:mt-0">
|
||||
<Skeleton className="mb-3 h-7 w-32" />
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4">
|
||||
{Array.from({ length: cards }, (_, i) => (
|
||||
<div
|
||||
// biome-ignore lint/suspicious/noArrayIndexKey: static placeholder cards
|
||||
key={i}
|
||||
className="rounded-lg border border-border/50 p-3"
|
||||
>
|
||||
{/* Only cards with a codename ("macOS Tahoe") have the
|
||||
small label line; iOS cards are just version + build. */}
|
||||
{codenames && <Skeleton className="mb-1 h-4 w-24" />}
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<Skeleton className="h-6 w-14" />
|
||||
@@ -72,16 +59,13 @@ export function HomeSkeleton({
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Very wide screens: as directory-tabs.tsx and release-timeline.tsx. */}
|
||||
<div className="hidden min-[1800px]:block">
|
||||
<div className="grid grid-cols-[auto_26rem] items-start justify-center gap-x-10 min-[2400px]:grid-cols-[auto_40rem] min-[2400px]:gap-x-16">
|
||||
<ol
|
||||
className="[--axis:8rem] [--leaf:6.75rem] min-[2400px]:[--axis:9.5rem] min-[2400px]:[--leaf:8.875rem]"
|
||||
style={{
|
||||
width: `calc(${Math.max(...ROWS)} * var(--leaf) + var(--axis))`,
|
||||
}}
|
||||
>
|
||||
);
|
||||
return (
|
||||
<div aria-busy="true" aria-label="Loading builds">
|
||||
<div>
|
||||
<div className="grid grid-cols-1 items-start min-[1800px]:grid-cols-[minmax(0,1fr)_26rem] min-[1800px]:gap-x-10 min-[2400px]:grid-cols-[minmax(0,1fr)_40rem] min-[2400px]:gap-x-16">
|
||||
<ToolbarSkeleton />
|
||||
<ol className="w-[var(--tw)] max-w-full">
|
||||
{ROWS.map((count, i) => (
|
||||
<li
|
||||
// biome-ignore lint/suspicious/noArrayIndexKey: static placeholder rows
|
||||
@@ -96,7 +80,7 @@ export function HomeSkeleton({
|
||||
<span className="relative z-10 mt-1 h-[11px] w-[11px] shrink-0 rounded-full border-2 border-muted-foreground/40 bg-background" />
|
||||
<Skeleton className="h-5 w-7" />
|
||||
</div>
|
||||
<ul className="col-start-1 row-start-1 flex flex-wrap justify-end gap-1 min-[2400px]:gap-1.5">
|
||||
<ul className="col-start-1 row-start-1 flex flex-row-reverse flex-wrap-reverse gap-1 min-[2400px]:gap-1.5">
|
||||
{Array.from({ length: count }, (_, j) => (
|
||||
<li
|
||||
// biome-ignore lint/suspicious/noArrayIndexKey: static placeholder builds
|
||||
@@ -114,8 +98,7 @@ export function HomeSkeleton({
|
||||
))}
|
||||
</ol>
|
||||
|
||||
<div className="space-y-7">
|
||||
<Skeleton className="h-9 w-40 rounded-full" />
|
||||
<div className="hidden space-y-7 min-[1800px]:block">
|
||||
<Skeleton className="h-5 w-64" />
|
||||
<div className="flex gap-10">
|
||||
{[0, 1, 2].map((i) => (
|
||||
|
||||
@@ -3,15 +3,12 @@
|
||||
/**
|
||||
* Latest releases' figures (keys, files, change since the previous build),
|
||||
* from each platform's stats.json (hundreds of KB: fetched once the page is
|
||||
* up), for the very wide directory (directory-tabs.tsx); and the line into
|
||||
* the Time Machine shown above the grid on smaller screens.
|
||||
* up), for the directory's panel and build cards (directory-tabs.tsx).
|
||||
*/
|
||||
|
||||
import { createEngine } from "@/lib/engine";
|
||||
import type { BuildStats } from "@/lib/engine/types";
|
||||
import type { OS } from "@/lib/types";
|
||||
import { ArrowRight, History } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export interface Figures {
|
||||
@@ -66,32 +63,3 @@ export function useFigures(groups: string[]) {
|
||||
}, [key]);
|
||||
return figures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Up to very wide screens, above the grid: just the way into the Time
|
||||
* Machine. The latest releases need no line of their own: the grid opens
|
||||
* on them. (Very wide screens: directory-tabs.tsx.)
|
||||
*/
|
||||
export function LatestReleases() {
|
||||
return (
|
||||
<div className="mx-auto mb-6 max-w-[80rem] sm:mb-8">
|
||||
<TimeMachineCard />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** The way into the Time Machine, one line in its starfield (about a grid
|
||||
* card wide; phones: the full width). */
|
||||
export function TimeMachineCard() {
|
||||
return (
|
||||
<Link
|
||||
href="/time-machine"
|
||||
className="depth-banner group relative flex items-center gap-2.5 overflow-hidden rounded-xl border px-4 py-2.5 text-sm font-medium transition-colors hover:border-primary/50 sm:max-w-xs"
|
||||
>
|
||||
<span className="depth-stars" aria-hidden="true" />
|
||||
<History className="relative h-4 w-4 shrink-0 text-primary" />
|
||||
<span className="relative flex-1">Time Machine</span>
|
||||
<ArrowRight className="relative h-4 w-4 text-muted-foreground transition-transform group-hover:translate-x-0.5" />
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
+11
-51
@@ -1,13 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { goHome } from "@/lib/navigate";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Folder, Key, Layers, Moon, Sun } from "lucide-react";
|
||||
import { Folder, Key, Moon, Sun } from "lucide-react";
|
||||
import { useTheme } from "next-themes";
|
||||
import Link from "next/link";
|
||||
import { usePathname, useSearchParams } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { HEADER_PORTAL_ID, HEADER_PORTAL_LEFT_ID } from "./header-portal";
|
||||
import { HEADER_PORTAL_ID } from "./header-portal";
|
||||
import { KeyboardShortcuts } from "./keyboard-shortcuts";
|
||||
import { VersionSwitcher } from "./version-switcher";
|
||||
|
||||
@@ -48,7 +45,9 @@ function OSBreadcrumb({
|
||||
return (
|
||||
<div className="flex items-center gap-2 sm:gap-4 text-sm min-w-0">
|
||||
<div className="flex items-center gap-1 sm:gap-2 shrink-0">
|
||||
<span className="text-muted-foreground hidden sm:inline">
|
||||
{/* A fixed width ("iOS", "mac", "osx"): the controls after it stay
|
||||
put across platforms. */}
|
||||
<span className="hidden w-7 text-muted-foreground sm:inline-block">
|
||||
{platform}
|
||||
</span>
|
||||
<VersionSwitcher currentOs={os} />
|
||||
@@ -86,41 +85,6 @@ function OSBreadcrumb({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Every build, or only each major's releases (the default): one toggle,
|
||||
* "All builds", on or off; a link (?view=all), so it can be opened or
|
||||
* copied. Like the keys page's "Changed only". Very wide screens: the home
|
||||
* page is a timeline with every build either way, so it's hidden there.
|
||||
*/
|
||||
function AllBuildsToggle() {
|
||||
const searchParams = useSearchParams();
|
||||
const on = searchParams.get("view") === "all";
|
||||
return (
|
||||
<Link
|
||||
href={on ? "/" : "/?view=all"}
|
||||
// "/" after a directly loaded /?view=…: see goHome().
|
||||
onClick={
|
||||
on
|
||||
? (event) => {
|
||||
if (goHome()) event.preventDefault();
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
aria-current={on ? "page" : undefined}
|
||||
title={on ? "Showing every build" : "Show every build"}
|
||||
className={cn(
|
||||
"inline-flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-lg border px-3 text-sm transition-colors min-[1800px]:hidden",
|
||||
on
|
||||
? "border-primary/40 bg-primary/15 font-medium text-foreground"
|
||||
: "border-border text-muted-foreground hover:bg-accent/50 hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
<Layers className="h-3.5 w-3.5" />
|
||||
All builds
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
export function NavTop() {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
@@ -149,8 +113,9 @@ export function NavTop() {
|
||||
// which marks the edge; nearly opaque where blur isn't supported.
|
||||
<header className="sticky top-0 z-50 shrink-0 bg-background/95 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-xl supports-[backdrop-filter]:backdrop-saturate-150">
|
||||
{/*
|
||||
Four pieces: the logo, the page's controls (All builds and the
|
||||
platform; a release's version and Keys/Files), the filter, the icons.
|
||||
Four pieces: the logo, the page's controls (a release's version and
|
||||
Keys/Files; none on home, whose are in its toolbar), the filter, the
|
||||
icons.
|
||||
- Below lg: row 1 is the logo, the filter across, the icons (the
|
||||
theme toggle in the corner); row 2, the page's controls.
|
||||
- lg: one row, logo and page controls, the filter, the icons.
|
||||
@@ -169,14 +134,9 @@ export function NavTop() {
|
||||
entdb
|
||||
</Link>
|
||||
</h1>
|
||||
<div className="order-4 flex w-full min-w-0 items-center gap-2 lg:order-none lg:w-auto">
|
||||
{isHome && <AllBuildsToggle />}
|
||||
{isHome && (
|
||||
<div
|
||||
id={HEADER_PORTAL_LEFT_ID}
|
||||
className="flex shrink-0 items-center"
|
||||
/>
|
||||
)}
|
||||
{/* Hidden when the page has none (home: its controls are in its
|
||||
toolbar), so no empty row. */}
|
||||
<div className="order-4 flex w-full min-w-0 items-center gap-2 empty:hidden lg:order-none lg:w-auto">
|
||||
{isOSPage && os && (
|
||||
<OSBreadcrumb os={os} currentPage={currentPage} />
|
||||
)}
|
||||
|
||||
+104
-349
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { Search, X } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
|
||||
@@ -9,14 +8,14 @@ import { useQueryFilter } from "@/hooks/use-query-filter";
|
||||
import { arrowNavigate } from "@/lib/arrow-nav";
|
||||
import { dataURL } from "@/lib/env";
|
||||
import type { Group, OS } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { BetaBadge } from "./beta-badge";
|
||||
import { DirectoryTabs } from "./directory-tabs";
|
||||
import { GridView } from "./grid-view";
|
||||
import { HeaderPortal } from "./header-portal";
|
||||
import { HomeSkeleton } from "./home-skeleton";
|
||||
import { LatestReleases } from "./latest-releases";
|
||||
import { widestRow } from "./release-timeline";
|
||||
import { Button } from "./ui/button";
|
||||
import { Input } from "./ui/input";
|
||||
import { ViewToolbar, useRememberedView, viewOf } from "./view-toolbar";
|
||||
|
||||
function responseOK(r: Response) {
|
||||
if (!r.ok) {
|
||||
@@ -25,25 +24,6 @@ function responseOK(r: Response) {
|
||||
return r;
|
||||
}
|
||||
|
||||
function compareVersion(a: string, b: string) {
|
||||
const l1 = a.split(".").map(Number);
|
||||
const l2 = b.split(".").map(Number);
|
||||
const len = Math.max(l1.length, l2.length);
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
const v1 = l1[i] || 0;
|
||||
const v2 = l2[i] || 0;
|
||||
if (v1 !== v2) return v1 - v2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
interface MajorGroup {
|
||||
major: string;
|
||||
versions: OS[];
|
||||
}
|
||||
|
||||
const PLATFORM_NAMES: Record<string, string> = {
|
||||
iOS: "iOS",
|
||||
mac: "macOS",
|
||||
@@ -54,105 +34,16 @@ export function getPlatformName(key: string): string {
|
||||
return PLATFORM_NAMES[key] || key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the product name adds anything beyond the version: "macOS Tahoe"
|
||||
* does, "iOS 27.3" (shown right below as "27.3") doesn't.
|
||||
*/
|
||||
function hasCodename(os: OS) {
|
||||
return !os.name.endsWith(os.version);
|
||||
}
|
||||
|
||||
/**
|
||||
* The directory grid: two columns on phones up to four, never more: a row
|
||||
* is read left to right, newest first, and a long one isn't read at all.
|
||||
* Past that the page stops widening (below), so cards stay about as wide as
|
||||
* on a mid-size screen.
|
||||
*/
|
||||
const GRID = "grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4";
|
||||
|
||||
/** Section spacing: well clear of the grid above, close to its own. */
|
||||
const SECTION = "mt-10 first:mt-0";
|
||||
const SECTION_TITLE = "mb-3 flex items-baseline gap-2 text-xl font-semibold";
|
||||
|
||||
function groupByMajor(list: OS[]): MajorGroup[] {
|
||||
const bucket = new Map<string, OS[]>();
|
||||
|
||||
for (const os of list) {
|
||||
const major = os.version.split(".")[0];
|
||||
if (!bucket.has(major)) {
|
||||
bucket.set(major, []);
|
||||
}
|
||||
bucket.get(major)!.push(os);
|
||||
}
|
||||
|
||||
return Array.from(bucket.entries())
|
||||
.map(([major, versions]) => {
|
||||
versions.sort((a, b) => compareVersion(b.version, a.version));
|
||||
return { major, versions };
|
||||
})
|
||||
.sort((a, b) => Number(b.major) - Number(a.major));
|
||||
}
|
||||
|
||||
export default function OSList() {
|
||||
const searchParams = useSearchParams();
|
||||
const showAll = searchParams.get("view") === "all";
|
||||
|
||||
const params = useSearchParams();
|
||||
// The timeline (the default), or the grid (?view=grid; all builds,
|
||||
// ?view=all); opened without one, the one last chosen here.
|
||||
const view = viewOf(params.get("view"));
|
||||
useRememberedView();
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [groups, setGroups] = useState<Group[]>([]);
|
||||
const [highlights, setHighlights] = useState<Set<string>>(new Set());
|
||||
const [selectedPlatform, setSelectedPlatform] = useState<string | null>(null);
|
||||
const { keyword, setKeyword, debouncedKeyword } = useQueryFilter("q", 200);
|
||||
|
||||
useEffect(() => {
|
||||
const set: Set<string> = new Set();
|
||||
for (const group of groups) {
|
||||
group.list.sort((a, b) => compareVersion(b.version, a.version));
|
||||
|
||||
if (group.name === "osx") {
|
||||
for (const item of group.list) {
|
||||
set.add(item.build);
|
||||
}
|
||||
} else {
|
||||
const bucket: Map<string, OS[]> = new Map();
|
||||
for (const item of group.list) {
|
||||
const [major] = item.version.split(".", 1);
|
||||
const key = major.toString();
|
||||
if (!bucket.has(key)) {
|
||||
bucket.set(key, [item]);
|
||||
} else {
|
||||
bucket.get(key)!.push(item);
|
||||
}
|
||||
}
|
||||
const isIOSOrMac = group.name === "iOS" || group.name === "mac";
|
||||
let latestTwoMajors = new Set<string>();
|
||||
if (isIOSOrMac) {
|
||||
const sortedMajors = Array.from(bucket.keys())
|
||||
.map(Number)
|
||||
.sort((a, b) => b - a)
|
||||
.slice(0, 2)
|
||||
.map(String);
|
||||
latestTwoMajors = new Set(sortedMajors);
|
||||
}
|
||||
|
||||
for (const [major, items] of bucket) {
|
||||
items.sort((a, b) => compareVersion(b.version, a.version));
|
||||
|
||||
if (isIOSOrMac && latestTwoMajors.has(major)) {
|
||||
for (const item of items) {
|
||||
set.add(item.build);
|
||||
}
|
||||
} else {
|
||||
const [first] = items;
|
||||
if (first) {
|
||||
set.add(first.build);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setHighlights(set);
|
||||
}, [groups]);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
|
||||
@@ -181,14 +72,9 @@ export default function OSList() {
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
const togglePlatform = (name: string) => {
|
||||
setSelectedPlatform((prev) => (prev === name ? null : name));
|
||||
};
|
||||
|
||||
const filteredGroups = useMemo(() => {
|
||||
const kw = debouncedKeyword.toLowerCase();
|
||||
return groups
|
||||
.filter((g) => selectedPlatform === null || g.name === selectedPlatform)
|
||||
.map((g) => {
|
||||
if (!kw) return g;
|
||||
// Filter OS entries by product name, version or build
|
||||
@@ -201,7 +87,7 @@ export default function OSList() {
|
||||
return { ...g, list: filteredList };
|
||||
})
|
||||
.filter((g) => g.list.length > 0);
|
||||
}, [groups, selectedPlatform, debouncedKeyword]);
|
||||
}, [groups, debouncedKeyword]);
|
||||
|
||||
const totalCount = useMemo(() => {
|
||||
return groups.reduce((sum, g) => sum + g.list.length, 0);
|
||||
@@ -211,55 +97,27 @@ export default function OSList() {
|
||||
return filteredGroups.reduce((sum, g) => sum + g.list.length, 0);
|
||||
}, [filteredGroups]);
|
||||
|
||||
const isFiltering = debouncedKeyword.length > 0 || selectedPlatform !== null;
|
||||
const isFiltering = debouncedKeyword.length > 0;
|
||||
|
||||
// Very wide screens: one timeline per line of releases. OS X and macOS
|
||||
// are one line (a new name, not a new platform): macOS, then OS X.
|
||||
const lines = useMemo(() => {
|
||||
const byName = new Map(filteredGroups.map((g) => [g.name, g]));
|
||||
const result: {
|
||||
id: string;
|
||||
title: string;
|
||||
sources: { group: string; list: OS[] }[];
|
||||
}[] = [];
|
||||
const ios = byName.get("iOS");
|
||||
if (ios)
|
||||
result.push({
|
||||
id: "iOS",
|
||||
title: "iOS",
|
||||
sources: [{ group: "iOS", list: ios.list }],
|
||||
});
|
||||
const mac = ["mac", "osx"]
|
||||
.map((name) => byName.get(name))
|
||||
.filter((g): g is Group => Boolean(g))
|
||||
.map((g) => ({ group: g.name, list: g.list }));
|
||||
if (mac.length)
|
||||
result.push({
|
||||
id: "mac",
|
||||
// macOS: the successor's name for the whole line.
|
||||
title: getPlatformName(mac[0].group),
|
||||
sources: mac,
|
||||
});
|
||||
// Any other platform, on its own line.
|
||||
for (const g of filteredGroups)
|
||||
if (!["iOS", "mac", "osx"].includes(g.name))
|
||||
result.push({
|
||||
id: g.name,
|
||||
title: getPlatformName(g.name),
|
||||
sources: [{ group: g.name, list: g.list }],
|
||||
});
|
||||
return result;
|
||||
}, [filteredGroups]);
|
||||
// One timeline per line of releases. OS X and macOS are one line (a new
|
||||
// name, not a new platform): macOS, then OS X.
|
||||
const lines = useMemo(() => linesOf(filteredGroups), [filteredGroups]);
|
||||
// The frame both views share (AGENTS.md: the view switch stays put): the
|
||||
// timeline's width, its widest row of all builds (unfiltered, so typing
|
||||
// doesn't resize it), plus the panel on very wide screens.
|
||||
const widest = useMemo(
|
||||
() => widestRow(linesOf(groups).map((l) => l.sources)),
|
||||
[groups],
|
||||
);
|
||||
|
||||
// While filtering, how many builds match; under the toolbar.
|
||||
const status = isFiltering
|
||||
? `${filteredCount} of ${totalCount} builds`
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
// Arrow keys move between the build cards by position (a grid).
|
||||
<div
|
||||
// Centred, at most four cards across (GRID): wider screens get
|
||||
// margins, not longer rows. Very wide screens: a timeline, as wide as
|
||||
// the screen (and its header and footer).
|
||||
className="mx-auto max-w-[80rem] min-[1800px]:max-w-none"
|
||||
onKeyDown={(event) => arrowNavigate(event, "[data-nav-item]", "grid")}
|
||||
>
|
||||
// Arrow keys move between builds by position (the timeline's rows).
|
||||
<div onKeyDown={(event) => arrowNavigate(event, "[data-nav-item]", "grid")}>
|
||||
{/* The filter is usable before the list loads (no header shift). */}
|
||||
<HeaderPortal>
|
||||
<div className="relative min-w-0 flex-1 2xl:w-80 2xl:flex-none">
|
||||
@@ -294,11 +152,10 @@ export default function OSList() {
|
||||
|
||||
{loading && (
|
||||
// Shaped like whichever layout the page becomes.
|
||||
<HomeSkeleton
|
||||
grid={GRID}
|
||||
section={SECTION}
|
||||
sectionTitle={SECTION_TITLE}
|
||||
/>
|
||||
// In the frame, sized for the longest row iOS has had (9 builds).
|
||||
<Frame widest={9}>
|
||||
<HomeSkeleton grid={view !== "timeline"} />
|
||||
</Frame>
|
||||
)}
|
||||
|
||||
{!loading && groups.length === 0 && (
|
||||
@@ -308,194 +165,92 @@ export default function OSList() {
|
||||
)}
|
||||
|
||||
{!loading && groups.length > 0 && (
|
||||
<>
|
||||
{/* Platform filter: in the header beside the filter (a segmented
|
||||
control, like its neighbours), at every width. Very wide
|
||||
screens: the directory's tabs choose instead. */}
|
||||
<HeaderPortal position="left">
|
||||
<PlatformFilter
|
||||
className="min-[1800px]:hidden"
|
||||
groups={groups}
|
||||
selected={selectedPlatform}
|
||||
onToggle={togglePlatform}
|
||||
<Frame widest={widest}>
|
||||
{view === "timeline" ? (
|
||||
// One timeline at a time, under tabs (iOS; the Mac, OS X
|
||||
// running on into macOS); very wide screens add a panel with
|
||||
// the latest release. The toolbar heads it.
|
||||
<DirectoryTabs
|
||||
lines={lines}
|
||||
toolbar={(tabs) => (
|
||||
<ViewToolbar view="timeline" lead={tabs} status={status} />
|
||||
)}
|
||||
/>
|
||||
</HeaderPortal>
|
||||
|
||||
{isFiltering ? (
|
||||
<div className="mb-3 text-sm text-muted-foreground">
|
||||
{filteredCount} of {totalCount} builds
|
||||
</div>
|
||||
) : (
|
||||
// Each platform's latest release (where most visits go) and
|
||||
// the Time Machine.
|
||||
// (Very wide screens: under the directory's tabs instead.)
|
||||
<div className="min-[1800px]:hidden">
|
||||
<LatestReleases />
|
||||
</div>
|
||||
// The earlier home page's grid, for whoever prefers it.
|
||||
<>
|
||||
<ViewToolbar view={view} status={status} />
|
||||
<GridView groups={filteredGroups} all={view === "all"} />
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Very wide screens: one timeline at a time, under tabs (with
|
||||
its latest release); iOS, and the Mac (OS X running on into
|
||||
macOS). */}
|
||||
<div className="hidden min-[1800px]:block">
|
||||
<DirectoryTabs lines={lines} />
|
||||
</div>
|
||||
|
||||
{/* Smaller screens: a grid per platform. */}
|
||||
<div className="min-[1800px]:hidden">
|
||||
{filteredGroups.map((group) => {
|
||||
const majorGroups = groupByMajor(group.list);
|
||||
|
||||
return (
|
||||
<section
|
||||
key={group.name}
|
||||
id={group.name}
|
||||
className={cn(SECTION, "scroll-mt-20")}
|
||||
>
|
||||
<h2 className={SECTION_TITLE}>
|
||||
{getPlatformName(group.name)}
|
||||
<span className="text-sm font-normal text-muted-foreground tabular-nums">
|
||||
{showAll
|
||||
? `${group.list.length} builds`
|
||||
: `${group.list.filter((os) => highlights.has(os.build)).length} releases`}
|
||||
</span>
|
||||
</h2>
|
||||
|
||||
{!showAll ? (
|
||||
<ul className={GRID}>
|
||||
{group.list
|
||||
.filter((os) => highlights.has(os.build))
|
||||
.map((os) => (
|
||||
<li
|
||||
key={`${group.name}-${os.version}-${os.build}`}
|
||||
className="list-none"
|
||||
>
|
||||
<Link
|
||||
data-nav-item
|
||||
href={`/os/keys?os=${group.name}/${os.version}_${os.build}`}
|
||||
className={cn(
|
||||
"block p-3 border rounded-lg transition-colors hover:bg-accent/50",
|
||||
os.beta
|
||||
? "border-amber-400/50 hover:border-amber-500/70 dark:border-amber-500/40"
|
||||
: "border-border hover:border-foreground/20",
|
||||
)}
|
||||
>
|
||||
{hasCodename(os) && (
|
||||
<div className="text-xs text-muted-foreground mb-1 truncate">
|
||||
{os.name}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="font-medium flex items-center gap-1.5">
|
||||
{os.version}
|
||||
{os.beta && <BetaBadge />}
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground font-mono">
|
||||
{os.build}
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{majorGroups.map((majorGroup) => (
|
||||
<div key={majorGroup.major}>
|
||||
<h3 className="text-xs font-medium text-muted-foreground mb-2">
|
||||
{getPlatformName(group.name)} {majorGroup.major}
|
||||
</h3>
|
||||
<ul className={GRID}>
|
||||
{majorGroup.versions.map((os) => (
|
||||
<li
|
||||
key={`${group.name}-${os.version}-${os.build}`}
|
||||
className="list-none"
|
||||
>
|
||||
<Link
|
||||
data-nav-item
|
||||
href={`/os/keys?os=${group.name}/${os.version}_${os.build}`}
|
||||
className={cn(
|
||||
"block p-3 border rounded-lg transition-colors hover:bg-accent/50",
|
||||
os.beta
|
||||
? "border-amber-400/50 hover:border-amber-500/70 dark:border-amber-500/40"
|
||||
: "border-border hover:border-foreground/20",
|
||||
)}
|
||||
>
|
||||
{hasCodename(os) && (
|
||||
<div className="text-xs text-muted-foreground mb-1 truncate">
|
||||
{os.name}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="font-medium flex items-center gap-1.5">
|
||||
{os.version}
|
||||
{os.beta && <BetaBadge />}
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground font-mono">
|
||||
{os.build}
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
</Frame>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
type Line = {
|
||||
id: string;
|
||||
title: string;
|
||||
sources: { group: string; list: OS[] }[];
|
||||
};
|
||||
|
||||
/** The lines of releases: iOS; the Mac (macOS, then OS X); any other. */
|
||||
function linesOf(groups: Group[]): Line[] {
|
||||
const byName = new Map(groups.map((g) => [g.name, g]));
|
||||
const result: Line[] = [];
|
||||
const ios = byName.get("iOS");
|
||||
if (ios)
|
||||
result.push({
|
||||
id: "iOS",
|
||||
title: "iOS",
|
||||
sources: [{ group: "iOS", list: ios.list }],
|
||||
});
|
||||
const mac = ["mac", "osx"]
|
||||
.map((name) => byName.get(name))
|
||||
.filter((g): g is Group => Boolean(g))
|
||||
.map((g) => ({ group: g.name, list: g.list }));
|
||||
if (mac.length)
|
||||
result.push({
|
||||
id: "mac",
|
||||
// macOS, the successor's name, for the whole line, whichever of its
|
||||
// groups a filter leaves (the tab's label doesn't change as you type).
|
||||
title: getPlatformName("mac"),
|
||||
sources: mac,
|
||||
});
|
||||
for (const g of groups)
|
||||
if (!["iOS", "mac", "osx"].includes(g.name))
|
||||
result.push({
|
||||
id: g.name,
|
||||
title: getPlatformName(g.name),
|
||||
sources: [{ group: g.name, list: g.list }],
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show one platform (or all: pressing the shown one again). A segmented
|
||||
* control styled like the header's others (Major Releases / All Builds,
|
||||
* Keys / Files), so they line up: same track, padding and height.
|
||||
* The frame both views sit in, centred: the timeline's width (its widest
|
||||
* row: a build 6.5rem + 0.25rem gap; the axis 6.5rem + 1.5rem gap; a size
|
||||
* up from 2400px), plus, on very wide screens, the panel and its gap; at
|
||||
* most the window. Its variables are the timeline's too (--tw).
|
||||
*/
|
||||
function PlatformFilter({
|
||||
groups,
|
||||
selected,
|
||||
onToggle,
|
||||
className,
|
||||
export function Frame({
|
||||
widest,
|
||||
children,
|
||||
}: {
|
||||
groups: Group[];
|
||||
selected: string | null;
|
||||
onToggle: (name: string) => void;
|
||||
className?: string;
|
||||
widest: number;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<fieldset
|
||||
className={cn(
|
||||
"m-0 min-w-0 inline-flex h-9 shrink-0 items-stretch rounded-lg border border-border bg-muted/30 p-[3px]",
|
||||
className,
|
||||
)}
|
||||
<div
|
||||
className="mx-auto w-[var(--frame)] max-w-full [--axis:8rem] [--frame:var(--tw)] [--leaf:6.75rem] min-[1800px]:[--frame:calc(var(--tw)+28.5rem)] min-[2400px]:[--axis:9.5rem] min-[2400px]:[--frame:calc(var(--tw)+44rem)] min-[2400px]:[--leaf:8.875rem]"
|
||||
style={
|
||||
{
|
||||
"--tw": `calc(${widest} * var(--leaf) + var(--axis))`,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<legend className="sr-only">Platform</legend>
|
||||
{groups.map((group) => {
|
||||
const active = selected === group.name;
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
key={group.name}
|
||||
onClick={() => onToggle(group.name)}
|
||||
aria-pressed={active}
|
||||
className={cn(
|
||||
"flex items-center rounded-md px-2.5 text-sm transition-colors sm:px-3",
|
||||
active
|
||||
? "bg-background font-medium text-foreground shadow-sm"
|
||||
: "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{getPlatformName(group.name)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</fieldset>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -160,13 +160,14 @@ export function ReleaseTimeline({
|
||||
"a[data-nav-item]",
|
||||
),
|
||||
];
|
||||
// Rows run oldest to newest, newest version first: the latest is
|
||||
// the first row's last; the oldest, the last row's first.
|
||||
// Each row lists its builds newest first (laid right to left),
|
||||
// newest version first: the latest is the first row's first; the
|
||||
// oldest, the last row's last.
|
||||
const rows = [...event.currentTarget.querySelectorAll("ul")];
|
||||
const target =
|
||||
event.key === "Home"
|
||||
? rows[0]?.querySelector<HTMLElement>("li:last-child a")
|
||||
: rows.at(-1)?.querySelector<HTMLElement>("li:first-child a");
|
||||
? rows[0]?.querySelector<HTMLElement>("li:first-child a")
|
||||
: rows.at(-1)?.querySelector<HTMLElement>("li:last-child a");
|
||||
if (!target || items.length === 0) return;
|
||||
event.preventDefault();
|
||||
target.focus();
|
||||
@@ -211,12 +212,20 @@ export function ReleaseTimeline({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<ul className="col-start-1 row-start-1 flex flex-wrap justify-end gap-1 min-[2400px]:gap-1.5">
|
||||
{stop.builds.map((os, j) => {
|
||||
// The newest build of each version stands out, last in its
|
||||
// row, flush right: down the line, the eye runs along them
|
||||
// (the releases most visits want).
|
||||
const latest = j === stop.builds.length - 1;
|
||||
<ul
|
||||
// Filled from the newest end: newest first, laid right to left
|
||||
// (row-reverse), lines stacking upwards (wrap-reverse). So the
|
||||
// whole version reads like text, oldest to newest, left to right
|
||||
// and top to bottom, ending with the newest, bottom right; every
|
||||
// line is full but the first, whose gap is at the oldest end
|
||||
// (top left).
|
||||
className="col-start-1 row-start-1 flex flex-row-reverse flex-wrap-reverse gap-1 min-[2400px]:gap-1.5"
|
||||
>
|
||||
{[...stop.builds].reverse().map((os, j) => {
|
||||
// The newest build of each version stands out, first (bottom
|
||||
// right): down the line, the eye runs along them (the releases
|
||||
// most visits want).
|
||||
const latest = j === 0;
|
||||
const key = buildKey(stop.group, os);
|
||||
const card = open?.key === key && renderCard;
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* Above the directory: how to see it (Timeline | Grid; in the grid, All
|
||||
* builds), and the way into the Time Machine. Links, keeping the rest of
|
||||
* the query (the filter), so a view can be opened anew or shared.
|
||||
*
|
||||
* The view is in the URL: none, the timeline; ?view=grid, the grid of major
|
||||
* releases; ?view=all, the grid of every build (the address the earlier
|
||||
* home page used for it). The last choice is remembered (useRememberedView).
|
||||
*/
|
||||
|
||||
import {
|
||||
ArrowRight,
|
||||
GitCommitVertical,
|
||||
History,
|
||||
Layers,
|
||||
LayoutGrid,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { basePath } from "@/lib/env";
|
||||
import { navigate } from "@/lib/navigate";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export type HomeView = "timeline" | "grid" | "all";
|
||||
|
||||
const STORAGE_KEY = "entdb:home-view";
|
||||
|
||||
export function viewOf(param: string | null): HomeView {
|
||||
return param === "grid" || param === "all" ? param : "timeline";
|
||||
}
|
||||
|
||||
function remember(view: HomeView) {
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, view);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** The home page's address with `view` (and the rest of the query). */
|
||||
function useViewHref() {
|
||||
const params = useSearchParams();
|
||||
return (view: HomeView) => {
|
||||
const next = new URLSearchParams(params.toString());
|
||||
if (view === "timeline") next.delete("view");
|
||||
else next.set("view", view);
|
||||
const query = next.toString();
|
||||
return query ? `/?${query}` : "/";
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Opened without a view, open the one last chosen here (someone who went
|
||||
* back to the grid finds it again), replacing the address.
|
||||
*/
|
||||
export function useRememberedView() {
|
||||
const params = useSearchParams();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const hasView = params.has("view");
|
||||
useEffect(() => {
|
||||
if (hasView) return;
|
||||
let stored: string | null = null;
|
||||
try {
|
||||
stored = localStorage.getItem(STORAGE_KEY);
|
||||
} catch {}
|
||||
if (stored !== "grid" && stored !== "all") return;
|
||||
const next = new URLSearchParams(window.location.search);
|
||||
next.set("view", stored);
|
||||
const path =
|
||||
basePath && pathname.startsWith(basePath)
|
||||
? pathname.slice(basePath.length)
|
||||
: pathname;
|
||||
navigate(router, `${path}?${next.toString()}`, {
|
||||
replace: true,
|
||||
scroll: false,
|
||||
});
|
||||
}, [hasView, pathname, router]);
|
||||
}
|
||||
|
||||
/** Equal, fixed widths: the group never resizes with its state (AGENTS.md). */
|
||||
const SEGMENT =
|
||||
"flex w-9 items-center justify-center gap-1.5 rounded-md text-sm transition-colors sm:w-[6.5rem]";
|
||||
|
||||
export function ViewToolbar({
|
||||
view,
|
||||
lead,
|
||||
status,
|
||||
}: {
|
||||
view: HomeView;
|
||||
/** After the view switch: the timeline's platform tabs. */
|
||||
lead?: React.ReactNode;
|
||||
/** A line under the toolbar (while filtering, the count). */
|
||||
status?: React.ReactNode;
|
||||
}) {
|
||||
const href = useViewHref();
|
||||
const grid = view !== "timeline";
|
||||
return (
|
||||
// One centred group, under the header's centred filter: the view
|
||||
// switch, the view's own control, the Time Machine. On a phone the switch
|
||||
// is icons (named on hover) and the Time Machine loses its arrow; it
|
||||
// wraps (centred) rather than overflow. Set apart from the list below
|
||||
// (more on tall screens; the list is nearly always taller than the
|
||||
// screen, so centring it vertically wouldn't apply).
|
||||
<div className="relative col-span-full mb-10 flex flex-wrap items-center justify-center gap-2 [@media(min-height:900px)]:mb-14">
|
||||
<nav
|
||||
aria-label="View"
|
||||
className="inline-flex h-9 shrink-0 items-stretch rounded-lg border border-border bg-muted/30 p-[3px]"
|
||||
>
|
||||
{(
|
||||
[
|
||||
["timeline", "Timeline", GitCommitVertical],
|
||||
["grid", "Grid", LayoutGrid],
|
||||
] as const
|
||||
).map(([id, label, Icon]) => {
|
||||
const active = id === "timeline" ? !grid : grid;
|
||||
return (
|
||||
<Link
|
||||
key={id}
|
||||
href={href(id)}
|
||||
onClick={() => remember(id)}
|
||||
aria-current={active ? "page" : undefined}
|
||||
aria-label={label}
|
||||
title={label}
|
||||
className={cn(
|
||||
SEGMENT,
|
||||
active
|
||||
? "bg-background font-medium text-foreground shadow-sm"
|
||||
: "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
<Icon className="h-3.5 w-3.5" />
|
||||
<span className="hidden sm:inline">{label}</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* After the view switch: what only this view has, in a slot of one
|
||||
width in every view (the tabs' width), so the centred group never
|
||||
recentres and the switch stays put (AGENTS.md). */}
|
||||
<div className="flex w-[9.5rem] shrink-0 justify-center">
|
||||
{lead}
|
||||
{grid && (
|
||||
// The grid's one option: every build, or only the major releases.
|
||||
<Link
|
||||
href={href(view === "all" ? "grid" : "all")}
|
||||
onClick={() => remember(view === "all" ? "grid" : "all")}
|
||||
aria-current={view === "all" ? "page" : undefined}
|
||||
title={view === "all" ? "Showing every build" : "Show every build"}
|
||||
className={cn(
|
||||
"inline-flex h-9 w-full items-center justify-center gap-1.5 whitespace-nowrap rounded-lg border text-sm transition-colors",
|
||||
view === "all"
|
||||
? "border-primary/40 bg-primary/15 font-medium text-foreground"
|
||||
: "border-border text-muted-foreground hover:bg-accent/50 hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
<Layers className="h-3.5 w-3.5" />
|
||||
All builds
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Link
|
||||
href="/time-machine"
|
||||
className="depth-banner group relative inline-flex h-9 shrink-0 items-center gap-2 overflow-hidden rounded-lg border px-3 text-sm font-medium transition-colors hover:border-primary/50"
|
||||
>
|
||||
<span className="depth-stars" aria-hidden="true" />
|
||||
<History className="relative h-4 w-4 text-primary" />
|
||||
<span className="relative">Time Machine</span>
|
||||
<ArrowRight className="relative hidden h-4 w-4 text-muted-foreground transition-transform group-hover:translate-x-0.5 sm:block" />
|
||||
</Link>
|
||||
{/* In the space under the toolbar, out of the flow: showing or
|
||||
hiding it moves nothing (AGENTS.md). */}
|
||||
{status && (
|
||||
<output
|
||||
data-toolbar-status
|
||||
className="absolute inset-x-0 top-full mt-2 block text-center text-sm text-muted-foreground tabular-nums"
|
||||
>
|
||||
{status}
|
||||
</output>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user