From 72c47aeaf7d611672680f1bec6f4b89727f9087a Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 22:24:04 +0000 Subject: [PATCH] feat(features): rebuild /features as a photo-led page in the Sports/News language The Features page used the old three-column index: a boxed-in lead with no dek, two rails of small headlines, and three overlapping "more" lists. It now follows the Sports and News layout: - Cover story across the page, with the title box over the photo's foot (4:5 on phones, focal-point cropped) - A two-to-one row: a second story with a portrait photo, and The Lens, one photo a day from a set editors pick, with the photographer credited like an author - Two wide strips, a Photo Stories row, and From the Archive (the Sports carousel, now taking a heading and closing link) Every slot can be pinned in the layout editor and fills itself when empty. A pin more than six weeks older than the newest story gives way, and The Lens falls back to recent credited photos when its picks are empty or over two months old, so a quiet month leaves the page current. Photo Stories only auto-fill with photo-led stories, and editors can choose which photo a pinned one shows. The layout stays a JSON field (no migration). Old layouts are carried over by normalizeFeaturesLayout. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TTjZzRUF1shh4dw3Y211AA --- app/(frontend)/[section]/page.tsx | 109 +- .../features-layout-editor.css | 72 ++ .../Dashboard/FeaturesLayoutEditor/index.tsx | 539 ++++------ components/Features/FeaturesSectionPage.tsx | 968 ++++++------------ components/Sports/SportsFeatured.tsx | 31 +- docs/features-section.md | 68 ++ lib/featuresLayout.ts | 111 ++ lib/featuresPage.ts | 306 ++++++ scripts/seed-features.ts | 31 +- tests/lib/featuresPage.test.ts | 132 +++ 10 files changed, 1244 insertions(+), 1123 deletions(-) create mode 100644 docs/features-section.md create mode 100644 lib/featuresLayout.ts create mode 100644 lib/featuresPage.ts create mode 100644 tests/lib/featuresPage.test.ts diff --git a/app/(frontend)/[section]/page.tsx b/app/(frontend)/[section]/page.tsx index 47d6303..193b3e3 100644 --- a/app/(frontend)/[section]/page.tsx +++ b/app/(frontend)/[section]/page.tsx @@ -31,7 +31,8 @@ import { getNewsTopicArticles } from '@/lib/newsTopics'; import { NEWS_TOPICS, type NewsTopicKey } from '@/components/News/newsTopics'; import { getStoredTerms } from '@/lib/studentGovTerms'; import { ordinal, resolveTerms, termYearLabel, troyDayKey, updateTermHref } from '@/components/News/studentGovTerms'; -import FeaturesSectionPage, { type SpotlightPhoto } from '@/components/Features/FeaturesSectionPage'; +import FeaturesSectionPage from '@/components/Features/FeaturesSectionPage'; +import { loadFeaturesPage } from '@/lib/featuresPage'; import SportsSectionPage from '@/components/Sports/SportsSectionPage'; import { SPORTS_GAME_SELECT, loadSportsPage } from '@/lib/sportsPage'; import { Article as PayloadArticle, Media } from '@/payload-types'; @@ -517,93 +518,8 @@ export default async function SectionPageRoute({ params }: Args) { }); } - // Fetch features page layout — 3-column Row 1 + Row 2. Layouts saved before - // Upcoming Events and the Collar City Column were removed may still carry - // `events` / `collarCity*` keys; they're ignored. - let featuresPinnedOnCampus: ComponentArticle[] = []; - let featuresPinnedFeatured: ComponentArticle[] = []; - let featuresPinnedRight: ComponentArticle[] = []; - let featuresOnCampusImages: boolean[] = [false, false, false]; - let featuresRightImages: boolean[] = [false, false, false]; - // Row 2 - let featuresPinnedTheArts: ComponentArticle[] = []; - let featuresTheArtsImages: boolean[] = [false, false, false]; - let featuresPhotoSpotlight: SpotlightPhoto[] = []; - let featuresPinnedSpotlightSubs: ComponentArticle[] = []; - let featuresPinnedWide: ComponentArticle[] = []; - - if (section === 'features') { - type FeaturesLayoutShape = { - onCampus?: (number | null)[]; - onCampusImages?: boolean[]; - featured?: (number | null)[]; - rightArticles?: (number | null)[]; - rightImages?: boolean[]; - theArts?: (number | null)[]; - theArtsImages?: boolean[]; - photoSpotlight?: SpotlightPhoto[]; - spotlightSubs?: (number | null)[]; - wideArticle?: (number | null)[]; - }; - - try { - const layoutResponse = await payload.find({ - collection: 'features-page-layout', - limit: 1, - depth: 0, - select: { layout: true }, - }); - const doc = layoutResponse.docs[0] as Record | undefined; - const layoutJson = doc?.layout as FeaturesLayoutShape | undefined; - - if (layoutJson) { - if (layoutJson.onCampusImages) featuresOnCampusImages = layoutJson.onCampusImages; - if (layoutJson.rightImages) featuresRightImages = layoutJson.rightImages; - if (layoutJson.theArtsImages) featuresTheArtsImages = layoutJson.theArtsImages; - featuresPhotoSpotlight = layoutJson.photoSpotlight || []; - - // Collect all pinned IDs to fetch in one batch (Row 1 + Row 2) - const allPinnedIds = new Set(); - for (const col of [layoutJson.onCampus, layoutJson.featured, layoutJson.rightArticles, layoutJson.theArts, layoutJson.spotlightSubs, layoutJson.wideArticle]) { - if (col) for (const id of col) { if (id) allPinnedIds.add(id); } - } - - if (allPinnedIds.size > 0) { - const pinnedResponse = await payload.find({ - collection: 'articles', - where: { - and: [ - { id: { in: Array.from(allPinnedIds) } }, - { _status: { equals: 'published' } }, - ], - }, - limit: allPinnedIds.size, - depth: 1, - select: { - title: true, slug: true, subdeck: true, featuredImage: true, - section: true, kicker: true, publishedDate: true, createdAt: true, - authors: true, writeInAuthors: true, isFollytechnic: true, - }, - }); - const pinnedMap = new Map( - pinnedResponse.docs.map((a) => [a.id, formatArticle(a)]), - ); - - const resolveColumn = (ids: (number | null)[] | undefined): ComponentArticle[] => - (ids || []).map((id) => (id ? pinnedMap.get(id) ?? null : null)).filter((a): a is ComponentArticle => a !== null); - - featuresPinnedOnCampus = resolveColumn(layoutJson.onCampus); - featuresPinnedFeatured = resolveColumn(layoutJson.featured); - featuresPinnedRight = resolveColumn(layoutJson.rightArticles); - featuresPinnedTheArts = resolveColumn(layoutJson.theArts); - featuresPinnedSpotlightSubs = resolveColumn(layoutJson.spotlightSubs); - featuresPinnedWide = resolveColumn(layoutJson.wideArticle); - } - } - } catch { - // Table may not exist yet - } - } + // Features: the editors' layout resolved into stories, and The Lens + const featuresPage = section === 'features' ? await loadFeaturesPage(payload, formattedArticles) : null; // Sports: editors' layout and pins, standings, schedule and schools const sportsPage = section === 'sports' ? await loadSportsPage(payload) : null; @@ -631,21 +547,8 @@ export default async function SectionPageRoute({ params }: Args) { groupedArticles={groupedArticles} pinnedSpotlightAuthors={pinnedSpotlightAuthors} /> - ) : section === 'features' ? ( - + ) : featuresPage ? ( + ) : sportsPage ? ( ) : isNews ? ( diff --git a/components/Dashboard/FeaturesLayoutEditor/features-layout-editor.css b/components/Dashboard/FeaturesLayoutEditor/features-layout-editor.css index 0b045ab..2d8fd7a 100644 --- a/components/Dashboard/FeaturesLayoutEditor/features-layout-editor.css +++ b/components/Dashboard/FeaturesLayoutEditor/features-layout-editor.css @@ -834,3 +834,75 @@ .fle-spotlight-image-pick:not(.fle-spotlight-image-used):hover .fle-spotlight-add-badge { opacity: 1; } + +/* ---- Cover / two-up / Photo Stories layout ---- */ +.fle-full { + margin-bottom: 16px; +} +.fle-canvas-two { + grid-template-columns: 2fr 1fr; + margin-bottom: 16px; +} +.fle-photo-stories { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 10px; +} +.fle-note { + font-size: 0.72rem; + line-height: 1.45; + opacity: 0.6; + margin: 2px 0 10px; +} +.fle-note-top { + max-width: 70ch; + margin-bottom: 16px; +} + +/* ---- Photo Story photo picker ---- */ +.fle-photo-pick { + margin-top: 6px; +} +.fle-photo-pick-row { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + font-size: 0.7rem; +} +.fle-photo-pick-current { + display: inline-flex; + align-items: center; + gap: 6px; +} +.fle-photo-pick-current img { + width: 28px; + height: 20px; + object-fit: cover; + border-radius: 2px; +} +.fle-photo-pick-muted { + opacity: 0.5; +} +.fle-photo-pick-btn { + font-size: 0.7rem; + padding: 3px 8px; + border-radius: 4px; + border: 1px solid var(--theme-elevation-150, #333); + background: transparent; + color: inherit; + cursor: pointer; +} +.fle-photo-pick-btn:hover { + border-color: var(--theme-elevation-400, #666); +} +.fle-photo-pick-selected { + outline: 2px solid #3b82f6; + outline-offset: -2px; +} +.fle-photo-pick button.fle-spotlight-image-pick { + padding: 0; + border: 0; + background: none; + cursor: pointer; +} diff --git a/components/Dashboard/FeaturesLayoutEditor/index.tsx b/components/Dashboard/FeaturesLayoutEditor/index.tsx index fe7cfc3..4a7102b 100644 --- a/components/Dashboard/FeaturesLayoutEditor/index.tsx +++ b/components/Dashboard/FeaturesLayoutEditor/index.tsx @@ -16,6 +16,13 @@ import { pointerWithin, } from '@dnd-kit/core'; import './features-layout-editor.css'; +import { + EMPTY_FEATURES_LAYOUT, + normalizeFeaturesLayout, + type FeaturesLayout, + type FeaturesSlotKey, + type LensPhoto, +} from '@/lib/featuresLayout'; // --------------------------------------------------------------------------- // Types @@ -36,28 +43,8 @@ type ArticleData = { writeInAuthors?: Array<{ name: string }>; }; -type SpotlightPhoto = { - url: string; - caption?: string; - articleTitle?: string; - articleUrl?: string; - photographerName?: string; - photographerUrl?: string; -}; - -type FeaturesLayout = { - onCampus: (number | null)[]; - onCampusImages: boolean[]; - featured: (number | null)[]; - rightArticles: (number | null)[]; - rightImages: boolean[]; - // Row 2 - theArts: (number | null)[]; - theArtsImages: boolean[]; - photoSpotlight: SpotlightPhoto[]; - spotlightSubs: (number | null)[]; - wideArticle: (number | null)[]; -}; +// The Lens photos keep the Photo Spotlight's shape, plus when each was added +type SpotlightPhoto = LensPhoto; // --------------------------------------------------------------------------- // Constants @@ -69,49 +56,23 @@ const pointerThenCenter: CollisionDetection = (args) => { return closestCenter(args); }; -const EMPTY_LAYOUT: FeaturesLayout = { - onCampus: [null, null, null], - onCampusImages: [false, false, false], - featured: [null, null, null], - rightArticles: [null, null, null], - rightImages: [false, false, false], - theArts: [null, null, null], - theArtsImages: [false, false, false], - photoSpotlight: [], - spotlightSubs: [null, null], - wideArticle: [null], -}; +const STRIP_LABELS = ['Strip 1', 'Strip 2']; +const PHOTO_STORY_LABELS = ['Photo Story 1', 'Photo Story 2', 'Photo Story 3']; -const ON_CAMPUS_LABELS = [ - 'Article 1', - 'Article 2', - 'Article 3', -]; -const FEATURED_LABELS = [ - 'Hero (large image)', - 'Sub-feature Left (with image)', - 'Sub-feature Right (with image)', -]; -const RIGHT_LABELS = [ - 'Article 1', - 'Article 2', - 'Article 3', -]; -const THE_ARTS_LABELS = ['Article 1', 'Article 2', 'Article 3']; - -// Slot ID format: "oc-0", "feat-1", "right-2", "arts-0", "spotsub-1", "wide-0" -type ColumnKey = 'onCampus' | 'featured' | 'rightArticles' | 'theArts' | 'spotlightSubs' | 'wideArticle'; +// Slot ID format: "cover-0", "second-0", "strip-1", "photo-2" +type ColumnKey = FeaturesSlotKey; +const SLOT_COLUMNS: Record = { + cover: 'cover', + second: 'second', + strip: 'strips', + photo: 'photoStories', +}; const parseSlotId = (slotId: string): { column: ColumnKey; index: number } | null => { const [prefix, idxStr] = slotId.split('-'); + const column = SLOT_COLUMNS[prefix]; const index = Number(idxStr); - if (prefix === 'oc') return { column: 'onCampus', index }; - if (prefix === 'feat') return { column: 'featured', index }; - if (prefix === 'right') return { column: 'rightArticles', index }; - if (prefix === 'arts') return { column: 'theArts', index }; - if (prefix === 'spotsub') return { column: 'spotlightSubs', index }; - if (prefix === 'wide') return { column: 'wideArticle', index }; - return null; + return column && Number.isInteger(index) ? { column, index } : null; }; // --------------------------------------------------------------------------- @@ -145,7 +106,7 @@ const extractDocId = (): string | null => { const collectUsedIds = (layout: FeaturesLayout): Set => { const ids = new Set(); - for (const col of [layout.onCampus, layout.featured, layout.rightArticles, layout.theArts, layout.spotlightSubs, layout.wideArticle]) { + for (const col of [layout.cover, layout.second, layout.strips, layout.photoStories]) { for (const id of col) { if (id !== null) ids.add(id); } @@ -486,7 +447,7 @@ function SpotlightBrowser({ const res = await fetch(`/api/search?q=${encodeURIComponent(query.trim())}&pageSize=10`); const data = await res.json(); const articles: SpotlightArticleResult[] = (data.articles || []) - .filter((a: { section?: string }) => ['features', 'opinion', 'news'].includes(a.section || '')) + .filter((a: { section?: string }) => ['features', 'opinion', 'news', 'sports'].includes(a.section || '')) .slice(0, 10) .map((a: { id: string | number; title: string; section: string; slug: string; publishedDate?: string; image?: string | null }) => ({ id: typeof a.id === 'string' ? parseInt(a.id, 10) : a.id, @@ -541,7 +502,12 @@ function SpotlightBrowser({ return (
-
Photo Spotlight
+
The Lens
+

+ One of these shows each day, in turn, so a set of 6 to 10 lasts for weeks. Pick photos from any section. + If the list is empty, or every photo in it was added more than two months ago, the page shows recent + credited photos instead. +

{/* Selected photos — compact list */} {photos.length > 0 && ( @@ -623,13 +589,13 @@ function SpotlightBrowser({ const d = new Date(article.publishedDate); articleUrl = `/${article.section}/${d.getUTCFullYear()}/${String(d.getUTCMonth() + 1).padStart(2, '0')}/${article.slug}`; } - onAdd({ url: img.url, caption: img.alt, articleTitle: article.plainTitle, articleUrl, photographerName: img.photographerName, photographerUrl: img.photographerUrl }); + onAdd({ url: img.url, caption: img.alt, articleTitle: article.plainTitle, articleUrl, photographerName: img.photographerName, photographerUrl: img.photographerUrl, addedAt: new Date().toISOString() }); } }} > {img.alt {isUsed ? ( -
Already in spotlight
+
Already in The Lens
) : (
+ Add
)} @@ -651,12 +617,109 @@ function SpotlightBrowser({ ); } +// --------------------------------------------------------------------------- +// Photo Story photo picker +// --------------------------------------------------------------------------- + +/** + * Under a pinned Photo Story: choose which of the story's photos its card + * shows. Left alone, the card shows the story's lead photo. + */ +function PhotoStoryImagePicker({ + articleId, + selected, + onSelect, +}: { + articleId: number; + selected: string | null; + onSelect: (url: string | null) => void; +}) { + const [open, setOpen] = useState(false); + const [images, setImages] = useState(null); + const [loading, setLoading] = useState(false); + + const toggle = async () => { + const next = !open; + setOpen(next); + if (next && !images) { + setLoading(true); + try { + const res = await fetch(`/api/articles/${articleId}?depth=2`); + setImages(extractImagesFromArticle(await res.json())); + } catch (err) { + console.error('Failed to load article images', err); + setImages([]); + } finally { + setLoading(false); + } + } + }; + + return ( +
+
+ {selected ? ( + + Chosen photo + + ) : ( + Lead photo + )} + +
+ {open && ( +
+ {loading ? ( +
+
+ Loading images... +
+ ) : images && images.length > 0 ? ( + <> + {images.map((img) => ( + + ))} + {selected && ( + + )} + + ) : ( +
No images found in this article
+ )} +
+ )} +
+ ); +} + // --------------------------------------------------------------------------- // Main Editor // --------------------------------------------------------------------------- +const cloneEmpty = (): FeaturesLayout => ({ + ...EMPTY_FEATURES_LAYOUT, + cover: [...EMPTY_FEATURES_LAYOUT.cover], + second: [...EMPTY_FEATURES_LAYOUT.second], + strips: [...EMPTY_FEATURES_LAYOUT.strips], + photoStories: [...EMPTY_FEATURES_LAYOUT.photoStories], + photoStoryImages: [...EMPTY_FEATURES_LAYOUT.photoStoryImages], + lens: [], +}); + export function FeaturesLayoutEditor() { - const [layout, setLayout] = useState({ ...EMPTY_LAYOUT }); + const [layout, setLayout] = useState(cloneEmpty); const [articles, setArticles] = useState([]); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); @@ -715,29 +778,8 @@ export function FeaturesLayoutEditor() { } docIdRef.current = id; - if (layoutData) { - const savedLayout = layoutData.layout as FeaturesLayout | undefined; - if (savedLayout && typeof savedLayout === 'object') { - setLayout({ - onCampus: padArray(savedLayout.onCampus, 3), - onCampusImages: savedLayout.onCampusImages && savedLayout.onCampusImages.length >= 3 - ? savedLayout.onCampusImages.slice(0, 3) - : [false, false, false], - featured: padArray(savedLayout.featured, 3), - rightArticles: padArray(savedLayout.rightArticles, 3), - rightImages: savedLayout.rightImages && savedLayout.rightImages.length >= 3 - ? savedLayout.rightImages.slice(0, 3) - : [false, false, false], - theArts: padArray(savedLayout.theArts, 3), - theArtsImages: savedLayout.theArtsImages && savedLayout.theArtsImages.length >= 3 - ? savedLayout.theArtsImages.slice(0, 3) - : [false, false, false], - photoSpotlight: savedLayout.photoSpotlight || [], - spotlightSubs: padArray(savedLayout.spotlightSubs, 2), - wideArticle: padArray(savedLayout.wideArticle, 1), - }); - } - } + // Layouts from the old three-column editor are carried over + if (layoutData) setLayout(normalizeFeaturesLayout(layoutData.layout)); } catch (err) { setError('Failed to load data'); console.error(err); @@ -750,12 +792,21 @@ export function FeaturesLayoutEditor() { // ---- Mutations ---- const markDirty = useCallback(() => setSaved(false), []); + // A Photo Story's chosen photo belongs to its story, so it goes when the story does + const withSlot = (prev: FeaturesLayout, column: ColumnKey, index: number, articleId: number | null): FeaturesLayout => { + const col = [...prev[column]]; + col[index] = articleId; + const next = { ...prev, [column]: col }; + if (column === 'photoStories') { + const images = [...prev.photoStoryImages]; + images[index] = null; + next.photoStoryImages = images; + } + return next; + }; + const setSlot = useCallback((column: ColumnKey, index: number, articleId: number | null) => { - setLayout((prev) => { - const col = [...prev[column]]; - col[index] = articleId; - return { ...prev, [column]: col }; - }); + setLayout((prev) => withSlot(prev, column, index, articleId)); markDirty(); }, [markDirty]); @@ -765,49 +816,25 @@ export function FeaturesLayoutEditor() { setSlot(parsed.column, parsed.index, null); }, [setSlot]); - const toggleOnCampusImage = useCallback((index: number) => { + const setPhotoStoryImage = useCallback((index: number, url: string | null) => { setLayout((prev) => { - const imgs = [...prev.onCampusImages]; - const currentImageCount = imgs.filter(Boolean).length; - if (!imgs[index] && currentImageCount >= 3) return prev; - imgs[index] = !imgs[index]; - return { ...prev, onCampusImages: imgs }; + const images = [...prev.photoStoryImages]; + images[index] = url; + return { ...prev, photoStoryImages: images }; }); markDirty(); }, [markDirty]); - const toggleRightImage = useCallback((index: number) => { - setLayout((prev) => { - const imgs = [...prev.rightImages]; - const currentImageCount = imgs.filter(Boolean).length; - if (!imgs[index] && currentImageCount >= 2) return prev; - imgs[index] = !imgs[index]; - return { ...prev, rightImages: imgs }; - }); + const addLensPhoto = useCallback((photo: SpotlightPhoto) => { + setLayout((prev) => ({ ...prev, lens: [...prev.lens, photo] })); markDirty(); }, [markDirty]); - const toggleArtsImage = useCallback((index: number) => { + const removeLensPhoto = useCallback((index: number) => { setLayout((prev) => { - const imgs = [...prev.theArtsImages]; - const currentImageCount = imgs.filter(Boolean).length; - if (!imgs[index] && currentImageCount >= 2) return prev; - imgs[index] = !imgs[index]; - return { ...prev, theArtsImages: imgs }; - }); - markDirty(); - }, [markDirty]); - - const addSpotlightPhoto = useCallback((photo: SpotlightPhoto) => { - setLayout((prev) => ({ ...prev, photoSpotlight: [...prev.photoSpotlight, photo] })); - markDirty(); - }, [markDirty]); - - const removeSpotlightPhoto = useCallback((index: number) => { - setLayout((prev) => { - const photos = [...prev.photoSpotlight]; + const photos = [...prev.lens]; photos.splice(index, 1); - return { ...prev, photoSpotlight: photos }; + return { ...prev, lens: photos }; }); markDirty(); }, [markDirty]); @@ -838,37 +865,25 @@ export function FeaturesLayoutEditor() { } if (!overData?.slotId) return; - const targetSlotId = overData.slotId as string; - const targetParsed = parseSlotId(targetSlotId); - if (!targetParsed) return; + const target = parseSlotId(overData.slotId as string); + if (!target) return; - // If source was a slot, swap + // From a slot: swap the two if (activeData.source === 'slot' && typeof activeData.slotId === 'string') { - const sourceParsed = parseSlotId(activeData.slotId); - if (sourceParsed) { - const targetOldId = layout[targetParsed.column][targetParsed.index]; + const source = parseSlotId(activeData.slotId); + if (source) { setLayout((prev) => { - const sourceCol = [...prev[sourceParsed.column]]; - const targetCol = sourceParsed.column === targetParsed.column - ? sourceCol - : [...prev[targetParsed.column]]; - - sourceCol[sourceParsed.index] = targetOldId; - if (sourceParsed.column === targetParsed.column) { - sourceCol[targetParsed.index] = draggedArticle.id; - return { ...prev, [sourceParsed.column]: sourceCol }; - } else { - targetCol[targetParsed.index] = draggedArticle.id; - return { ...prev, [sourceParsed.column]: sourceCol, [targetParsed.column]: targetCol }; - } + const targetOldId = prev[target.column][target.index]; + const afterSource = withSlot(prev, source.column, source.index, targetOldId); + return withSlot(afterSource, target.column, target.index, draggedArticle.id); }); markDirty(); return; } } - // Drop from pool - setSlot(targetParsed.column, targetParsed.index, draggedArticle.id); + // From the pool + setSlot(target.column, target.index, draggedArticle.id); }; // ---- Save ---- @@ -907,9 +922,17 @@ export function FeaturesLayoutEditor() { return id ? articleMap.get(id) || null : null; }; - const imageCount = layout.onCampusImages.filter(Boolean).length; - const rightImageCount = layout.rightImages.filter(Boolean).length; - const artsImageCount = layout.theArtsImages.filter(Boolean).length; + const slot = (column: ColumnKey, prefix: string, index: number, label: string) => ( + clearSlot(`${prefix}-${index}`)} + isImageSlot + /> + ); return (
- {/* Left: canvas */}
-
- {/* On-Campus column (thin left) */} -
-
- On Campus - {imageCount}/3 imgs -
- {ON_CAMPUS_LABELS.map((label, i) => ( - clearSlot(`oc-${i}`)} - isImageSlot={layout.onCampusImages[i]} - imageToggle={ - imageCount >= 3 && !layout.onCampusImages[i] ? ( - - locked - - ) : ( - - ) - } - /> - ))} +

+ Every slot is optional. An empty slot shows the newest story that isn't already on the page. + A pinned story stays until you change it, unless it is more than six weeks older than the newest + Features story; then the newest story takes its place, so the page never sits on old news. +

+ + {/* Cover across the page */} +
+
+ Cover
+ {slot('cover', 'cover', 0, 'Cover story (full width)')} +
- {/* Featured column (big middle) */} + {/* Second story | The Lens */} +
- Featured + Second story
- {FEATURED_LABELS.map((label, i) => ( - clearSlot(`feat-${i}`)} - isImageSlot - /> - ))} - clearSlot('wide-0')} - isImageSlot - /> + {slot('second', 'second', 0, 'Second story (portrait photo)')} +
+ Strips +
+ {STRIP_LABELS.map((label, i) => slot('strips', 'strip', i, label))}
- - {/* Right column */}
-
- Latest - {rightImageCount}/2 imgs -
- - {RIGHT_LABELS.map((label, i) => ( - clearSlot(`right-${i}`)} - isImageSlot={layout.rightImages[i]} - imageToggle={ - rightImageCount >= 2 && !layout.rightImages[i] ? ( - - locked - - ) : ( - - ) - } - /> - ))} +
- {/* ── Row Divider ── */} -
- - {/* ── Row 2 Canvas ── */} -
- {/* The Arts column (thin left) */} -
-
- The Arts - {artsImageCount}/2 imgs -
- {THE_ARTS_LABELS.map((label, i) => ( - clearSlot(`arts-${i}`)} - isImageSlot={layout.theArtsImages[i]} - imageToggle={ - artsImageCount >= 2 && !layout.theArtsImages[i] ? ( - - locked - - ) : ( - - ) - } - /> - ))} + {/* Photo Stories */} +
+
+ Photo Stories
- - {/* Photo Spotlight (middle + right, as on the page) */} -
- -
- clearSlot('spotsub-0')} - isImageSlot - /> - clearSlot('spotsub-1')} - isImageSlot - /> -
+

+ Empty slots fill with the newest photo-led stories: “Photo” in the kicker, a photo + feature, or a gallery. For a pinned story you can choose which of its photos the card shows. +

+
+ {PHOTO_STORY_LABELS.map((label, i) => ( +
+ {slot('photoStories', 'photo', i, label)} + {layout.photoStories[i] !== null && ( + setPhotoStoryImage(i, url)} + /> + )} +
+ ))}
-
+ +

+ From the Archive, the row of photo cards at the foot of the page, shows the next newest stories on its own. +

{/* Right: Article pool */} @@ -1124,13 +1039,3 @@ export function FeaturesLayoutEditor() { ); } - -// --------------------------------------------------------------------------- -// Utility -// --------------------------------------------------------------------------- - -function padArray(arr: (number | null)[] | undefined, len: number): (number | null)[] { - const result = [...(arr || [])]; - while (result.length < len) result.push(null); - return result.slice(0, len); -} diff --git a/components/Features/FeaturesSectionPage.tsx b/components/Features/FeaturesSectionPage.tsx index 85da2cf..af186bf 100644 --- a/components/Features/FeaturesSectionPage.tsx +++ b/components/Features/FeaturesSectionPage.tsx @@ -1,744 +1,372 @@ -"use client"; - -import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import React from "react"; import Image from "next/image"; import TransitionLink from "@/components/TransitionLink"; import { getArticleUrl } from "@/utils/getArticleUrl"; -import type { Article as ComponentArticle } from "@/components/FrontPage/types"; -import { Byline } from "@/components/FrontPage/Byline"; -import { AnimatedLine } from "@/components/Opinion/RainbowDivider"; import SectionSearchPrompt from "@/components/SectionSearchPrompt"; +import SportsHeading from "@/components/Sports/SportsHeading"; +import SportsByline from "@/components/Sports/SportsByline"; +import SportsFeatured from "@/components/Sports/SportsFeatured"; +import { shortDate } from "@/components/Sports/sportsFormat"; +import type { FeaturesLens, FeaturesPageData, FeaturesStory } from "@/lib/featuresPage"; const FEATURES_CONTACT_MAILTO = "mailto:features@poly.rpi.edu,eic@poly.rpi.edu?subject=Features%20Request%2FComment%20or%20Story%20Tip"; -/* ── Types ── */ - -export type SpotlightPhoto = { - url: string; - caption?: string; - articleTitle?: string; - articleUrl?: string; - photographerName?: string; - photographerUrl?: string; -}; - /* - * One layout for every screen size. The DOM is in phone reading order; CSS - * grid areas place the same sections on tablet and desktop: - * - * phone tablet (≥768) desktop (≥1024) - * lead lead lead oncampus lead latest - * latest oncampus latest arts spot spot - * spot spot spot - * oncampus arts arts - * arts + * /features, in the language of /sports and /news: one cover story across the + * page, then a two-to-one row (a big second story, and The Lens beside it), + * two wide strips, a row of Photo Stories, and the archive as a carousel. + * Fewer stories than the other sections, each bigger, each with its dek. * - * Cards change shape per breakpoint with classes, not duplicate markup: on - * phones most stories are compact rows (headline, small thumbnail); from - * tablet up they're the stacked cards the editor's image toggles control. + * Phone order follows the DOM: cover, second story, The Lens, strips, Photo + * Stories, archive. */ -const COLUMN_GAP = "clamp(16px, 2vw, 24px)"; - -const GRID_CSS = ` -.features-grid { - display: grid; - grid-template-columns: minmax(0, 1fr); - grid-template-areas: "lead" "latest" "spot" "oncampus" "arts"; - row-gap: 48px; -} -@media (min-width: 768px) { - .features-grid { - grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); - grid-template-areas: "lead lead" "oncampus latest" "spot spot" "arts arts"; - column-gap: ${COLUMN_GAP}; - } -} -@media (min-width: 1024px) { - .features-grid { - grid-template-columns: 240px minmax(0, 1fr) 300px; - grid-template-areas: "oncampus lead latest" "arts spot spot"; - row-gap: 0; - } -} -@keyframes dividerWaveTravel { - from { transform: translateX(-600px); } - to { transform: translateX(0px); } -} -@keyframes dividerRainbowHue { - from { filter: hue-rotate(0deg); } - to { filter: hue-rotate(360deg); } -} -`; - -/* ── Labels and dates ── */ +/* ── Labels ── */ const normalize = (s: string) => s.toLowerCase().replace(/[^a-z]/g, ""); /** - * The kicker, unless it only repeats the section it sits in, says - * "Features", or opens the headline already ("Photo" over "Photo: …") + * The kicker, unless it only says "Features" or already opens the headline + * ("Photo" over "Photo: …") */ -function visibleKicker(article: ComponentArticle, sectionLabel?: string): string | null { +function visibleKicker(article: FeaturesStory): string | null { const kicker = article.kicker?.trim(); if (!kicker) return null; - const n = normalize(kicker); - if (n === "features") return null; - if (sectionLabel && n === normalize(sectionLabel)) return null; + if (normalize(kicker) === "features") return null; if (article.title?.toLowerCase().startsWith(`${kicker.toLowerCase()}:`)) return null; return kicker; } -/** Kickers that put a story in a topic section when it's auto-filled */ -const ON_CAMPUS_KICKERS = new Set(["oncampus", "campus", "campuslife"]); -const ARTS_KICKERS = new Set(["thearts", "arts", "art", "music", "theater", "theatre", "film", "dance"]); -const isOnCampus = (a: ComponentArticle) => ON_CAMPUS_KICKERS.has(normalize(a.kicker ?? "")); -const isArts = (a: ComponentArticle) => ARTS_KICKERS.has(normalize(a.kicker ?? "")); - -/** "Nov 14", in the paper's time zone so server and browser agree */ -const shortDate = (iso?: string | null): string | null => { - if (!iso) return null; - const d = new Date(iso); - if (Number.isNaN(d.getTime())) return null; - // Non-breaking space: the date never splits across lines ("Oct / 30") - return d - .toLocaleDateString("en-US", { month: "short", day: "numeric", timeZone: "America/New_York" }) - .replace(" ", " "); -}; - -/** More in Features columns by story count, so a short run never leaves a hole */ -const MORE_COLUMNS: Record = { - 1: "md:grid-cols-1 lg:grid-cols-1", - 2: "md:grid-cols-2 lg:grid-cols-2", - 3: "md:grid-cols-3 lg:grid-cols-3", - 4: "md:grid-cols-2 lg:grid-cols-4", - 5: "md:grid-cols-3 lg:grid-cols-5", -}; - -/** The slug at the end of an article path, for matching spotlight links to stories */ -const slugOf = (path: string | undefined): string | null => - path ? path.split(/[?#]/)[0].replace(/\/+$/, "").split("/").pop() || null : null; - -/* ── Story card ── */ - -/** Phone (<768px): a big photo on top, a thumbnail beside the headline, or no photo */ -type PhoneMedia = "stack" | "thumb" | "none"; -/** Tablet and up: photo on top, photo left of the text, photo right of it, or none */ -type WideMedia = "stack" | "row" | "row-end" | "none"; -type HeadlineSize = "lead" | "m" | "s" | "xs"; +/** "Nov 3", with the year once it isn't this year's */ +function storyDate(article: FeaturesStory): string { + const iso = article.publishedDate || article.createdAt; + const thisYear = iso ? new Date(iso).getFullYear() === new Date().getFullYear() : true; + return shortDate(article, !thisYear); +} -const ROOT_PHONE: Record = { - stack: "block", - thumb: "grid grid-cols-[minmax(0,1fr)_88px] items-start gap-x-3", - none: "block", -}; -const ROOT_WIDE: Record = { - stack: "md:block", - row: "md:grid md:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] md:items-start md:gap-x-4", - "row-end": "md:grid md:grid-cols-2 md:items-start md:gap-x-6", - none: "md:block", -}; -const MEDIA_PHONE: Record = { - stack: "-mx-4 mb-3 sm:mx-0", - thumb: "order-2 aspect-square w-[88px]", - none: "hidden", -}; -const MEDIA_WIDE: Record = { - stack: "md:order-none md:mx-0 md:mb-3 md:block md:w-full", - row: "md:order-1 md:mx-0 md:mb-0 md:block md:w-full md:aspect-[3/2]", - "row-end": "md:order-2 md:mx-0 md:mb-0 md:block md:w-full md:aspect-[3/2]", - none: "md:hidden", -}; -const BODY_PHONE: Record = { stack: "", thumb: "order-1", none: "" }; -const BODY_WIDE: Record = { - stack: "md:order-none", - row: "md:order-2", - "row-end": "md:order-1", - none: "md:order-none", -}; +/** Kicker in black, then the date: one quiet line above a headline */ +function Kicker({ article, className = "" }: { article: FeaturesStory; className?: string }) { + const kicker = visibleKicker(article); + const date = storyDate(article); + if (!kicker && !date) return null; + return ( +
+ {kicker && {kicker}} + {kicker && date && } + {date && {date}} +
+ ); +} -/** The type scale: lead 42/36/32, m 24, s 20, xs 18. Phone rows are always 18. */ -const HEADLINE_PHONE: Record = { - lead: "text-[32px] leading-[1.08]", - m: "text-[22px] leading-[1.12]", - s: "text-[20px] leading-[1.15]", - xs: "text-[18px] leading-[1.18]", -}; -const HEADLINE_PHONE_ROW = "text-[18px] leading-[1.18]"; -const HEADLINE_WIDE: Record = { - lead: "md:text-[36px] lg:text-[42px] md:leading-[1.08]", - m: "md:text-[24px] md:leading-[1.12]", - s: "md:text-[20px] md:leading-[1.15]", - xs: "md:text-[18px] md:leading-[1.18]", -}; +/** Authors in red (the card's one red), then what the reader is signing up for */ +function Byline({ + article, + extent = "read", + className = "", +}: { + article: FeaturesStory; + /** Which length to state: reading time, or the number of photos */ + extent?: "read" | "photos" | "none"; + className?: string; +}) { + const length = + extent === "read" && article.readMinutes + ? `${article.readMinutes} min read` + : extent === "photos" && article.photoCount && article.photoCount > 1 + ? `${article.photoCount} photos` + : null; + return ( +

+ + {length && ( + <> + + {length} + + )} +

+ ); +} -function StoryCard({ +/** A story's photo, filling its box from the photo's focal point */ +function StoryPhoto({ article, - phone = "thumb", - wide = "stack", - size = "s", - sectionLabel, - showDek = false, - date = null, + sizes, priority = false, - large = false, - wideSizes = "33vw", - className = "", + src, }: { - article: ComponentArticle; - phone?: PhoneMedia; - wide?: WideMedia; - size?: HeadlineSize; - /** The section the card sits in; a kicker that repeats it is hidden */ - sectionLabel?: string; - showDek?: boolean; - date?: string | null; + article: FeaturesStory; + sizes: string; priority?: boolean; - /** 16:9 photo instead of 3:2 (the lead) */ - large?: boolean; - /** `sizes` for tablet and up */ - wideSizes?: string; - className?: string; + src?: string | null; }) { - const hasImage = Boolean(article.image); - const phoneMedia: PhoneMedia = hasImage ? phone : "none"; - const wideMedia: WideMedia = hasImage ? wide : "none"; - const showMedia = phoneMedia !== "none" || wideMedia !== "none"; - const kicker = visibleKicker(article, sectionLabel); - const phoneSize = phoneMedia === "stack" ? "100vw" : "88px"; - const tabletSize = wideMedia === "none" ? "88px" : wideSizes; - const stackAspect = large ? "aspect-video" : "aspect-[3/2]"; - const wideStackAspect = large ? "md:aspect-video" : "md:aspect-[3/2]"; + const image = src || article.imageFull || article.image; + if (!image) return null; + return ( + {article.imageTitle + ); +} +/* ── Cover: the photo across the page, the title box over its foot ── */ + +function Cover({ article }: { article: FeaturesStory }) { + const href = getArticleUrl(article); + const hasPhoto = Boolean(article.imageFull || article.image); return ( - - {showMedia && ( -
+ {hasPhoto && ( + // Portrait on phones, so a photo-led story fills the first screen +
+ +
)} -
- {kicker && ( - - {kicker} - - )} -

- {article.richTitle || article.title} -

- - {showDek && article.excerpt && ( -

+

+ +

+ + {article.richTitle ?? article.title} + +

+ {article.excerpt && ( +

{article.excerpt}

)} +
- + ); } -/** - * A run of stories: hairline-divided rows on phones, spaced cards from - * tablet up. Pass grid classes to lay the cards out side by side. - */ -function StoryList({ children, className = "" }: { children: React.ReactNode; className?: string }) { +/* ── Second story: a portrait photo beside its text ── */ + +function SecondStory({ article }: { article: FeaturesStory }) { + const href = getArticleUrl(article); + const hasPhoto = Boolean(article.imageFull || article.image); return ( -
*]:py-4 [&>*:first-child]:pt-0 md:[&>*]:py-0 md:[&>*]:mb-6 ${className}`} - > - {children} -
+
+ {hasPhoto && ( +
+ +
+ )} +
+ +

+ {/* Stretched over the card so the whole card opens the story */} + + {article.richTitle ?? article.title} + +

+ {article.excerpt && ( +

{article.excerpt}

+ )} + +
+
); } -/* ── Section label: red rule over a small-caps heading ── */ - -function SectionLabel({ id, children }: { id: string; children: React.ReactNode }) { - return ( -
-

- {children} -

+/* ── The Lens: one photo, its photographer named like an author ── */ + +function Lens({ lens }: { lens: FeaturesLens }) { + const { photo } = lens; + const photoEl = ( +
+ {photo.caption
); -} - -/* ── Photo Spotlight: a swipeable rail with buttons ── */ - -function PhotoSpotlight({ photos }: { photos: SpotlightPhoto[] }) { - const railRef = useRef(null); - const [current, setCurrent] = useState(0); - - // Follow whichever slide is mostly in view (swipes, trackpads, buttons) - useEffect(() => { - const rail = railRef.current; - if (!rail || photos.length < 2) return; - const observer = new IntersectionObserver( - (entries) => { - for (const entry of entries) { - if (entry.isIntersecting) setCurrent(Number((entry.target as HTMLElement).dataset.index)); - } - }, - { root: rail, threshold: 0.6 }, - ); - rail.querySelectorAll("[data-index]").forEach((slide) => observer.observe(slide)); - return () => observer.disconnect(); - }, [photos.length]); - - const goTo = useCallback( - (index: number) => { - const rail = railRef.current; - if (!rail) return; - const i = (index + photos.length) % photos.length; - const slides = rail.querySelectorAll("[data-index]"); - const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches; - rail.scrollTo({ left: slides[i].offsetLeft - slides[0].offsetLeft, behavior: reduce ? "auto" : "smooth" }); - setCurrent(i); - }, - [photos.length], + return ( +
+ The Lens +
+ {photo.articleUrl ? ( + + ) : ( + photoEl + )} +
+ {photo.photographerName && ( +

+ + Photo by + + {photo.photographerUrl ? ( + + {photo.photographerName} + + ) : ( + photo.photographerName + )} +

+ )} + {photo.caption && ( +

{photo.caption}

+ )} + {photo.articleTitle && photo.articleUrl && ( +

+ From{" "} + + {photo.articleTitle} + +

+ )} +
+
+
); +} - if (photos.length === 0) return null; +/* ── Strips: headline and dek beside a photo, the width of the page ── */ +function Strip({ article }: { article: FeaturesStory }) { + const hasPhoto = Boolean(article.imageFull || article.image); return ( -
-
- {photos.map((photo, i) => { - const caption = photo.caption?.trim(); - return ( -
- {/* 3:2 on phones; 16:9 from tablet up, where it spans two columns */} -
- {caption -
- {/* Newspaper caption: what the photo shows, then credit and its story */} -
- {caption &&

{caption}

} - {(photo.photographerName || photo.articleTitle) && ( -

- {photo.photographerName && ( - <> - Photo by{" "} - {photo.photographerUrl ? ( - - {photo.photographerName} - - ) : ( - photo.photographerName - )} - - )} - {photo.photographerName && photo.articleTitle && ( - - )} - {photo.articleTitle && ( - <> - From{" "} - {photo.articleUrl ? ( - - {photo.articleTitle} - - ) : ( - {photo.articleTitle} - )} - - )} -

- )} -
-
- ); - })} -
- - {photos.length > 1 && ( - // Each control is a 44px target around a small visible mark -
- - {photos.map((_, i) => ( - - ))} - + {article.richTitle ?? article.title} + + + {article.excerpt && ( +

+ {article.excerpt} +

+ )} + +
+ {hasPhoto && ( +
+
)} -
+ ); } -/* ── Main Page ── */ - -export default function FeaturesSectionPage({ - title, - articles, - pinnedOnCampus, - pinnedFeatured, - pinnedRight, - onCampusImages, - rightImages, - pinnedTheArts, - theArtsImages, - photoSpotlight, - pinnedSpotlightSubs, - pinnedWide = [], -}: { - title: string; - articles: ComponentArticle[]; - pinnedOnCampus: ComponentArticle[]; - pinnedFeatured: ComponentArticle[]; - pinnedRight: ComponentArticle[]; - onCampusImages: boolean[]; - rightImages: boolean[]; - pinnedTheArts: ComponentArticle[]; - theArtsImages: boolean[]; - photoSpotlight: SpotlightPhoto[]; - pinnedSpotlightSubs: ComponentArticle[]; - pinnedWide?: ComponentArticle[]; -}) { - // Build set of pinned IDs to exclude from auto-fill - const pinnedIds = useMemo(() => { - const ids = new Set(); - for (const a of [...pinnedOnCampus, ...pinnedFeatured, ...pinnedRight, ...pinnedTheArts, ...pinnedSpotlightSubs, ...(pinnedWide || [])]) { - ids.add(String(a.id)); - } - return ids; - }, [pinnedOnCampus, pinnedFeatured, pinnedRight, pinnedTheArts, pinnedSpotlightSubs, pinnedWide]); +/* ── Photo Stories ── */ - // Stories the Photo Spotlight already links to; kept out of auto-fill so a - // story isn't shown twice (editor-pinned slots are left as chosen) - const spotlightSlugs = useMemo( - () => new Set(photoSpotlight.map((p) => slugOf(p.articleUrl)).filter((s): s is string => Boolean(s))), - [photoSpotlight], - ); - - // Auto-fill pool: articles not already pinned or in the spotlight - const autoFillPool = useMemo( - () => - articles.filter( - (a) => !pinnedIds.has(String(a.id)) && !spotlightSlugs.has(slugOf(getArticleUrl(a)) ?? ""), - ), - [articles, pinnedIds, spotlightSlugs], +function PhotoStoryCard({ article }: { article: FeaturesStory }) { + return ( +
+
+ +
+ {/* "Photo Short Story" would only repeat the row's heading */} +

+ + {article.richTitle ?? article.title} + +

+ +
); +} - // Fill each slot run: pinned first, then the newest unused pool stories. - // Topic sections (On Campus, The Arts) only auto-fill stories whose kicker - // matches, so a section label never sits over an unrelated story; they show - // fewer stories rather than mislabelled ones. - const used = new Set(); - const fill = ( - pinned: ComponentArticle[], - slotCount: number, - matches: (a: ComponentArticle) => boolean = () => true, - ): ComponentArticle[] => { - const result: ComponentArticle[] = [...pinned]; - for (const a of autoFillPool) { - if (result.length >= slotCount) break; - if (used.has(String(a.id)) || !matches(a)) continue; - used.add(String(a.id)); - result.push(a); - } - return result; - }; - - // Topic sections first, so their stories aren't used up elsewhere; the lead - // and Latest then get the newest of the rest. A topic section with no - // matching story at all falls back to general stories under an honest label - // rather than leaving a hole in the grid. - let onCampus = fill(pinnedOnCampus, 3, isOnCampus); - const onCampusLabel = onCampus.length > 0 ? "On Campus" : "More Stories"; - let theArts = fill(pinnedTheArts, 3, isArts); - const artsLabel = theArts.length > 0 ? "The Arts" : "More Stories"; - const featured = fill(pinnedFeatured, 3); - const right = fill(pinnedRight, 3); - if (onCampus.length === 0) onCampus = fill([], 3); - if (theArts.length === 0) theArts = fill([], 3); - const spotlightSubs = fill(pinnedSpotlightSubs, 2); - const wideArticle = fill(pinnedWide, 1); - // Headline-only extras so the desktop side columns run about as long as - // the lead column. Taken after every editor slot, so they never displace a pick. - const onCampusExtra = fill([], 3, onCampusLabel === "On Campus" ? isOnCampus : undefined); - const rightExtra = fill([], 3); - // When On Campus runs short of its six, the left column carries on with a - // separately labelled run of general stories instead of a blank stretch - const leftMore = fill([], Math.max(0, 6 - onCampus.length - onCampusExtra.length)); - const moreInFeatures = fill([], 5); - - const lead = featured[0]; - const leadFollowers = [featured[1], featured[2]].filter((a): a is ComponentArticle => Boolean(a)); - const wide = wideArticle[0]; - - /** A column of an editor's three slots plus extras (On Campus, Latest, The Arts) */ - const columnCards = ( - items: ComponentArticle[], - imageFlags: boolean[], - label: string, - wideSizes: string, - options: { dates?: boolean; extras?: ComponentArticle[] } = {}, - ) => [ - ...items.map((article, i) => { - const flagged = Boolean(imageFlags[i]); - return ( - - ); - }), - ...(options.extras ?? []).map((article) => ( - - )), - ]; - - // A column rule and gutter, only at the widths where the column has a - // neighbour to its right (literal classes so Tailwind can see them) - const RULE_FROM_MD = "md:border-r md:border-rule md:pr-[clamp(16px,2vw,24px)]"; - const RULE_FROM_LG = "lg:border-r lg:border-rule lg:pr-[clamp(16px,2vw,24px)]"; +/* ── Page ── */ +export default function FeaturesSectionPage({ + title, + cover, + second, + strips, + photoStories, + archive, + lens, +}: FeaturesPageData & { title: string }) { + const hasRow = Boolean(second || lens); return ( // Side padding matches the site header's, so the page lines up with the // rule under the logo at every width -
- - - {/* Title, as on News. On desktop the masthead already marks Features - (red, with a bar on the rule), so the title is for screen readers - only and the page starts right under the header. The mobile header - has no section links, so the title shows there, small. Archive and - Contact are at the foot of the page (SectionSearchPrompt). */} -

- {title} -

- -
- {/* ── Lead: hero, two followers, the wide story ── */} - {lead && ( -
- - {(leadFollowers.length > 0 || wide) && ( - - {leadFollowers.map((article) => ( - - ))} - {wide && ( - - )} - - )} -
- )} - - {/* ── Latest ── */} - {right.length > 0 && ( -
- Latest - - {columnCards(right, rightImages, "Latest", "(max-width: 1023px) 50vw, 300px", { - dates: true, - extras: rightExtra, - })} - -
- )} - - {/* ── Photo Spotlight and its two stories ── */} - {(photoSpotlight.length > 0 || spotlightSubs.length > 0) && ( -
- - {photoSpotlight.length > 0 ? "Photo Spotlight" : "Spotlight"} - - - {spotlightSubs.length > 0 && ( - - {spotlightSubs.map((article) => ( - - ))} - - )} -
- )} - - {/* ── On Campus ── */} - {(onCampus.length > 0 || onCampusExtra.length > 0) && ( -
- {onCampusLabel} - - {columnCards(onCampus, onCampusImages, onCampusLabel, "(max-width: 1023px) 50vw, 240px", { - extras: onCampusExtra, - })} - - {leftMore.length > 0 && ( -
- More Stories - - {leftMore.map((article) => ( - - ))} - -
- )} -
- )} +
+ {/* The masthead marks the section on desktop and News shows no title + on phones either, so the title is for screen readers and search */} +

{title}

+ + {cover && } + + {hasRow && ( +
+ {second && ( +
+ +
+ )} + {lens && ( +
+ +
+ )} +
+ )} - {/* ── The Arts ── */} - {theArts.length > 0 && ( -
- {artsLabel} - {/* Three across on tablets, where the section spans the page */} - - {columnCards(theArts, theArtsImages, artsLabel, "(max-width: 1023px) 33vw, 240px")} - -
- )} -
+ {strips.length > 0 && ( +
+ {strips.map((article) => ( + + ))} +
+ )} - {/* ── More in Features ── */} - {moreInFeatures.length > 0 && ( -
- -
-

- More in Features -

- - More → - -
- - {moreInFeatures.map((article) => ( - + {photoStories.length > 0 && ( +
+ Photo Stories +
+ {photoStories.map((article) => ( + ))} - +
)} + {archive.length > 0 && ( +
+ +
+ )} + {/* Search, archive and contact, where News has them */}
); @@ -144,7 +144,22 @@ function ArrowButton({ direction, hidden, onClick }: { direction: "prev" | "next * Featured photo cards scroll naturally by touch or trackpad, and can be * dragged with a mouse. Desktop arrows move a full set at a time. */ -export default function SportsFeatured({ articles, focus }: { articles: ComponentArticle[]; focus: FeaturedFocus }) { +export default function SportsFeatured({ + articles, + focus = {}, + heading = "More Headlines", + headingId = "sports-featured-heading", + allHref = "/sports/all", + allLabel = "View all in Sports", +}: { + articles: ComponentArticle[]; + focus?: FeaturedFocus; + /** The row's heading, its id, and where the closing card points (Features reuses the row) */ + heading?: string; + headingId?: string; + allHref?: string; + allLabel?: string; +}) { const viewportRef = useRef(null); const trackRef = useRef(null); const { handlers, stopMomentum } = useMomentumScroll(viewportRef, { mouseDrag: true }); @@ -187,8 +202,8 @@ export default function SportsFeatured({ articles, focus }: { articles: Componen }; return ( -
- More Headlines +
+ {heading} {/* Padding keeps card lift and shadows visible. The arrows stay outside the scrolling viewport so they remain fixed over the row. */} @@ -204,7 +219,7 @@ export default function SportsFeatured({ articles, focus }: { articles: Componen
))} - +