Rotating words: {Next|Now} in titles and text cycles through its choices
Migration 084: site defaults for the motion (slide, flip, fade, type, mirror), direction and seconds per word in Site settings, and a hero's and a block's own. The hero's headline, section and band titles, headings, paragraphs, callouts and quotes rotate; menus, tab titles, search text and emails show the first word; less motion shows it still. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ab8dcdd608
commit
a10ff6d75f
30 changed files with 411 additions and 37 deletions
10
TODO.md
10
TODO.md
|
|
@ -42,12 +42,6 @@
|
||||||
- [ ] Linked from the footer next to the version, or only in the blog? Answer:
|
- [ ] Linked from the footer next to the version, or only in the blog? Answer:
|
||||||
|
|
||||||
## Sections
|
## Sections
|
||||||
- [ ] **Hero text that flips**: the headline's word changes (Next, Now, and other words for our generation), or mirrors.
|
|
||||||
- [ ] Which words, and are they edited in Front page (a list) or fixed? Answer: Next cycles through words with an animation, allow us to customize this and the list of words, this should be a text content component that can be used places. also direction from where the words slide in, top or bottom.
|
|
||||||
- [ ] What motion: a flip like a card, a fade, letters typing, a mirror? Answer: make all of these.
|
|
||||||
- [ ] Respect reduced motion by showing one word (the first)? [ ] yes
|
|
||||||
- [ ] "Next generation of New Thought": is that the line it plays on, or a second line under the headline? Answer: Unity should also be another one of these animated words that cycles through a list.
|
|
||||||
- Settled 2026-10-16: words are written inline, {Next|Now|Rising}, in the hero headline, section titles, headings and paragraphs; motion (slide, flip, fade, type, mirror), direction (from top or bottom) and seconds per word have site defaults in Site settings, overridden by the hero or a block.
|
|
||||||
|
|
||||||
## Page Features
|
## Page Features
|
||||||
- [ ] **Full profiles**: people get full profile pages. Profile accounts, claiming and visibility are done (Part 2, Accounts); what's left is the page itself.
|
- [ ] **Full profiles**: people get full profile pages. Profile accounts, claiming and visibility are done (Part 2, Accounts); what's left is the page itself.
|
||||||
|
|
@ -123,7 +117,9 @@
|
||||||
|
|
||||||
|
|
||||||
# Part 2: Done
|
# Part 2: Done
|
||||||
## Page management (branch `page-management`, on top of `page-features`, no PR yet; migrations 080 to 083, back up the database before deploying)
|
## Page management (branch `page-management`, on top of `page-features`, no PR yet; migrations 080 to 084, back up the database before deploying)
|
||||||
|
- [x] **Rotating words** (Sections, migration 084): text typed as `{Next|Now|Rising}` cycles through its choices, in the hero's headline, section titles (bands' too), headings, paragraphs, callouts and quotes, eg. `{Next|Now} Generation of {Unity|New Thought}`. Five motions (slide, flip like a card, fade, type letter by letter, mirror turning round), from the top or the bottom, a number of seconds per word: defaults in Site settings → Animated words, and a hero or a block can set its own. Each word's space is the longest's, so the line doesn't jump. Less motion (the system's setting, or reading mode) shows the first word, still, and screen readers always get the first; menus, tab titles, search descriptions and newsletters use the first word too (`src/components/RotatingWords.tsx`, `src/lib/words.ts`).
|
||||||
|
- [ ] Check in a browser: each motion and direction, a group in a section title and a paragraph, the space it keeps on a phone, reduced motion.
|
||||||
- [x] **Section types with their own settings, and the front page as sections** (migration 083): the front page is Home in Page management, a page of sections like the others: its hero first, then its bands in their old order (hidden ones stay hidden), each a section type that can go on any page with content of its own: Hero (words, buttons, photos, video, livestream or event), Event countdown, Event calendar, Numbers, Featured cards, Connect nav, and a Timeline shown as the rail of featured moments. The Community blog's slots, pinned posts and feeds moved into its section, so it can go on any page too. Any section can be Hidden. The Front page editor is gone (its fields are each section's), and so are its tables and the Community page's. On the front page the bands look as they did and any other section is a band in the same style; on other pages a band brings its own heading. The National Retreats band became an Events section with an All retreats button. The newsletter's "featured cards" come from the front page's featured card sections. Admin engine: a child collection can have its own side tables and gated nested collections.
|
- [x] **Section types with their own settings, and the front page as sections** (migration 083): the front page is Home in Page management, a page of sections like the others: its hero first, then its bands in their old order (hidden ones stay hidden), each a section type that can go on any page with content of its own: Hero (words, buttons, photos, video, livestream or event), Event countdown, Event calendar, Numbers, Featured cards, Connect nav, and a Timeline shown as the rail of featured moments. The Community blog's slots, pinned posts and feeds moved into its section, so it can go on any page too. Any section can be Hidden. The Front page editor is gone (its fields are each section's), and so are its tables and the Community page's. On the front page the bands look as they did and any other section is a band in the same style; on other pages a band brings its own heading. The National Retreats band became an Events section with an All retreats button. The newsletter's "featured cards" come from the front page's featured card sections. Admin engine: a child collection can have its own side tables and gated nested collections.
|
||||||
- [ ] Check in a browser: the front page (every band, the countdown overlapping the hero, reading mode, the menu's Home dropdown), editing the hero and a band in Page management, a Hero and a Numbers section put on another page, hiding a section, the Community blog (pinned posts, feeds), a draft preview of the front page, the newsletter's featured cards.
|
- [ ] Check in a browser: the front page (every band, the countdown overlapping the hero, reading mode, the menu's Home dropdown), editing the hero and a band in Page management, a Hero and a Numbers section put on another page, hiding a section, the Community blog (pinned posts, feeds), a draft preview of the front page, the newsletter's featured cards.
|
||||||
- [x] **Core pages as sections** (migrations 081, 082): Feedback, Request, QR codes, Give, Privacy and Terms are pages of sections now, edited in Page management like any other. Their forms and embeds are section types any page can use (Website feedback form, Request form, Data request form, Giving button, QR code maker); Give's words, and all of Privacy and Terms, are blocks (headings, paragraphs, lists), with "Last updated" in the section's blurb. The privacy contact email was written into the policy's text and its Site settings field is gone. These pages keep their address (the site's code links to them) and can't be deleted. The privacy notice's link now goes to #cookies-and-browser-storage.
|
- [x] **Core pages as sections** (migrations 081, 082): Feedback, Request, QR codes, Give, Privacy and Terms are pages of sections now, edited in Page management like any other. Their forms and embeds are section types any page can use (Website feedback form, Request form, Data request form, Giving button, QR code maker); Give's words, and all of Privacy and Terms, are blocks (headings, paragraphs, lists), with "Last updated" in the section's blurb. The privacy contact email was written into the policy's text and its Site settings field is gone. These pages keep their address (the site's code links to them) and can't be deleted. The privacy notice's link now goes to #cookies-and-browser-storage.
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,14 @@ A Numbers section's "Number Source" dropdown works the same way:
|
||||||
|
|
||||||
## Writing text in the editor
|
## Writing text in the editor
|
||||||
|
|
||||||
|
Rotating words: type the choices in braces, `{Next|Now|Rising}`, in a
|
||||||
|
hero headline, a section title, a heading, a paragraph, a callout or a
|
||||||
|
quote, and the word cycles through them. How it moves is Admin →
|
||||||
|
Panel → Site settings → Animated words, or the hero's or block's own
|
||||||
|
Rotating words fields. Menus, tab titles, search and emails show the
|
||||||
|
first choice. The component is `src/components/RotatingWords.tsx`; its
|
||||||
|
motions are CSS in `RotatingWords.css`.
|
||||||
|
|
||||||
Conventions for any label, help text or option added to the admin, so
|
Conventions for any label, help text or option added to the admin, so
|
||||||
the editor reads consistently:
|
the editor reads consistently:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,10 @@ export const blocksChild = (ownerKind) => ({
|
||||||
text("cite"),
|
text("cite"),
|
||||||
// Video blocks only (066): an uploaded video's WebVTT file.
|
// Video blocks only (066): an uploaded video's WebVTT file.
|
||||||
text("captions"),
|
text("captions"),
|
||||||
|
// Its rotating words (084): blank keeps the site's.
|
||||||
|
enumeration("word_motion", ["slide", "flip", "fade", "type", "mirror"]),
|
||||||
|
enumeration("word_direction", ["top", "bottom"]),
|
||||||
|
int("word_seconds"),
|
||||||
// People blocks only (054): whose team's tiles to show.
|
// People blocks only (054): whose team's tiles to show.
|
||||||
text("team_id"),
|
text("team_id"),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,10 @@ const sectionsChild = {
|
||||||
text("video_captions"),
|
text("video_captions"),
|
||||||
text("video_still"),
|
text("video_still"),
|
||||||
text("event_id"),
|
text("event_id"),
|
||||||
|
// Its rotating words (084).
|
||||||
|
enumeration("word_motion", ["slide", "flip", "fade", "type", "mirror"]),
|
||||||
|
enumeration("word_direction", ["top", "bottom"]),
|
||||||
|
int("word_seconds"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { THEME_TOKENS, checkTheme } from "../theme.js";
|
import { THEME_TOKENS, checkTheme } from "../theme.js";
|
||||||
import { text, enumeration } from "./columns.js";
|
import { text, int, enumeration } from "./columns.js";
|
||||||
|
|
||||||
/* ── Site settings (035_site_settings.sql) ──────────────────────
|
/* ── Site settings (035_site_settings.sql) ──────────────────────
|
||||||
A singleton of overrides for what site.json says: name,
|
A singleton of overrides for what site.json says: name,
|
||||||
|
|
@ -36,6 +36,10 @@ export const siteSettings = {
|
||||||
text("access_group_admin"),
|
text("access_group_admin"),
|
||||||
enumeration("report_daily", ["on", "off"]),
|
enumeration("report_daily", ["on", "off"]),
|
||||||
enumeration("report_weekly", ["on", "off"]),
|
enumeration("report_weekly", ["on", "off"]),
|
||||||
|
// Rotating words' defaults (084).
|
||||||
|
enumeration("word_motion", ["slide", "flip", "fade", "type", "mirror"]),
|
||||||
|
enumeration("word_direction", ["top", "bottom"]),
|
||||||
|
int("word_seconds"),
|
||||||
],
|
],
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
|
|
||||||
37
server/src/migrations/084_rotating_words.sql
Normal file
37
server/src/migrations/084_rotating_words.sql
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 084 ROTATING WORDS
|
||||||
|
--
|
||||||
|
-- A word typed as {Next|Now|Rising} in a title or text cycles
|
||||||
|
-- through its choices (src/components/RotatingWords.tsx). How it
|
||||||
|
-- moves:
|
||||||
|
--
|
||||||
|
-- word_motion slide, flip, fade, type or mirror
|
||||||
|
-- word_direction top or bottom: where a sliding or flipping word
|
||||||
|
-- comes from
|
||||||
|
-- word_seconds how long each word shows, 1 to 20
|
||||||
|
--
|
||||||
|
-- Site settings hold the defaults (null: slide, from the bottom, 3
|
||||||
|
-- seconds); a hero and a content block can each set their own, null
|
||||||
|
-- keeping the site's.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
ALTER TABLE site_settings ADD COLUMN word_motion TEXT
|
||||||
|
CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror'));
|
||||||
|
ALTER TABLE site_settings ADD COLUMN word_direction TEXT
|
||||||
|
CHECK (word_direction IN ('top', 'bottom'));
|
||||||
|
ALTER TABLE site_settings ADD COLUMN word_seconds INTEGER
|
||||||
|
CHECK (word_seconds BETWEEN 1 AND 20);
|
||||||
|
|
||||||
|
ALTER TABLE section_hero ADD COLUMN word_motion TEXT
|
||||||
|
CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror'));
|
||||||
|
ALTER TABLE section_hero ADD COLUMN word_direction TEXT
|
||||||
|
CHECK (word_direction IN ('top', 'bottom'));
|
||||||
|
ALTER TABLE section_hero ADD COLUMN word_seconds INTEGER
|
||||||
|
CHECK (word_seconds BETWEEN 1 AND 20);
|
||||||
|
|
||||||
|
ALTER TABLE content_blocks ADD COLUMN word_motion TEXT
|
||||||
|
CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror'));
|
||||||
|
ALTER TABLE content_blocks ADD COLUMN word_direction TEXT
|
||||||
|
CHECK (word_direction IN ('top', 'bottom'));
|
||||||
|
ALTER TABLE content_blocks ADD COLUMN word_seconds INTEGER
|
||||||
|
CHECK (word_seconds BETWEEN 1 AND 20);
|
||||||
|
|
@ -100,6 +100,8 @@ export function siteFor(db) {
|
||||||
...base.robots,
|
...base.robots,
|
||||||
index: row.indexing ? row.indexing === "on" : base.robots?.index !== false,
|
index: row.indexing ? row.indexing === "on" : base.robots?.index !== false,
|
||||||
},
|
},
|
||||||
|
// Rotating words' defaults (084): blank is the app's own.
|
||||||
|
words: { motion: row.word_motion ?? null, direction: row.word_direction ?? null, seconds: row.word_seconds ?? null },
|
||||||
// The admin's colors (theme.js): only #rrggbb values and fixed
|
// The admin's colors (theme.js): only #rrggbb values and fixed
|
||||||
// text, so safe inside <style>.
|
// text, so safe inside <style>.
|
||||||
themeCss: themeCss(db),
|
themeCss: themeCss(db),
|
||||||
|
|
@ -114,6 +116,7 @@ const forBrowser = (site, nav) => ({
|
||||||
title: site.title,
|
title: site.title,
|
||||||
pages: site.pages,
|
pages: site.pages,
|
||||||
requestFiles: driveReady(),
|
requestFiles: driveReady(),
|
||||||
|
words: site.words,
|
||||||
nav,
|
nav,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -138,6 +141,8 @@ export function plainText(text) {
|
||||||
const flat = String(text)
|
const flat = String(text)
|
||||||
.slice(0, 2000)
|
.slice(0, 2000)
|
||||||
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
|
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
|
||||||
|
// Rotating words ({Next|Now}, 084): the first.
|
||||||
|
.replace(/\{([^{}|\n]+)(?:\|[^{}|\n]+)+\}/g, "$1")
|
||||||
.replace(/\*\*(.+?)\*\*/g, "$1")
|
.replace(/\*\*(.+?)\*\*/g, "$1")
|
||||||
.replace(/\*(.+?)\*/g, "$1")
|
.replace(/\*(.+?)\*/g, "$1")
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,8 @@ function heroOf(db, section, pageCountdown) {
|
||||||
? { url: h.video_url, title: h.video_title, captions: h.video_captions, still: h.video_still }
|
? { url: h.video_url, title: h.video_title, captions: h.video_captions, still: h.video_still }
|
||||||
: null,
|
: null,
|
||||||
event: shapeHeroEvent(db, event),
|
event: shapeHeroEvent(db, event),
|
||||||
|
// Its rotating words' motion (084); null keeps the site's.
|
||||||
|
words: { motion: h.word_motion ?? null, direction: h.word_direction ?? null, seconds: h.word_seconds ?? null },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
||||||
|
|
||||||
const blockRows = db
|
const blockRows = db
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id
|
`SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id,
|
||||||
|
word_motion, word_direction, word_seconds
|
||||||
FROM content_blocks
|
FROM content_blocks
|
||||||
WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)})
|
WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)})
|
||||||
ORDER BY owner_id, sort_order`,
|
ORDER BY owner_id, sort_order`,
|
||||||
|
|
@ -91,6 +92,10 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
||||||
cite: row.cite,
|
cite: row.cite,
|
||||||
captions: row.captions,
|
captions: row.captions,
|
||||||
team_id: row.team_id,
|
team_id: row.team_id,
|
||||||
|
// Its rotating words' motion (084), when it has its own.
|
||||||
|
words: row.word_motion || row.word_direction || row.word_seconds
|
||||||
|
? { motion: row.word_motion, direction: row.word_direction, seconds: row.word_seconds }
|
||||||
|
: null,
|
||||||
items: [],
|
items: [],
|
||||||
};
|
};
|
||||||
byId.set(row.id, block);
|
byId.set(row.id, block);
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import { headingAnchors } from '../lib/contents.ts'
|
||||||
import { SITE_NAME } from '../lib/site.ts'
|
import { SITE_NAME } from '../lib/site.ts'
|
||||||
import { useSmallImage } from '../lib/useSmallImage.ts'
|
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||||
import { useReadingMode } from '../lib/readingMode.ts'
|
import { useReadingMode } from '../lib/readingMode.ts'
|
||||||
|
import { WordMotion, Words } from './RotatingWords.tsx'
|
||||||
|
|
||||||
const BODY = 'var(--color-muted)'
|
const BODY = 'var(--color-muted)'
|
||||||
|
|
||||||
|
|
@ -96,14 +97,15 @@ export default function ContentBlocks({
|
||||||
return (
|
return (
|
||||||
<div className={`space-y-6 ${className}`}>
|
<div className={`space-y-6 ${className}`}>
|
||||||
{blocks.map((block, index) => (
|
{blocks.map((block, index) => (
|
||||||
|
<WordMotion key={block.id ?? index} settings={block.words}>
|
||||||
<Block
|
<Block
|
||||||
key={block.id ?? index}
|
|
||||||
block={block}
|
block={block}
|
||||||
accent={accent}
|
accent={accent}
|
||||||
anchor={idAt.get(index)}
|
anchor={idAt.get(index)}
|
||||||
level={levels[index]}
|
level={levels[index]}
|
||||||
presentHref={presentHrefs[index]}
|
presentHref={presentHrefs[index]}
|
||||||
/>
|
/>
|
||||||
|
</WordMotion>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
@ -191,14 +193,14 @@ function Block({
|
||||||
case 'heading':
|
case 'heading':
|
||||||
return (
|
return (
|
||||||
<h3 id={anchor} className="text-2xl font-bold" style={{ color: accentText(accent) }}>
|
<h3 id={anchor} className="text-2xl font-bold" style={{ color: accentText(accent) }}>
|
||||||
{text}
|
<Words text={text} />
|
||||||
</h3>
|
</h3>
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'subheading':
|
case 'subheading':
|
||||||
return (
|
return (
|
||||||
<h4 id={anchor} className="text-lg font-normal" style={{ color: accentText(accent) }}>
|
<h4 id={anchor} className="text-lg font-normal" style={{ color: accentText(accent) }}>
|
||||||
{text}
|
<Words text={text} />
|
||||||
</h4>
|
</h4>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
The little formatting a content block's text may carry, typed in
|
The little formatting a content block's text may carry, typed in
|
||||||
the admin as plain characters:
|
the admin as plain characters:
|
||||||
|
|
||||||
**bold** *italic* [link text](url)
|
**bold** *italic* [link text](url) {Next|Now} (rotating words)
|
||||||
a line break keeps its place
|
a line break keeps its place
|
||||||
a blank line starts a new paragraph
|
a blank line starts a new paragraph
|
||||||
|
|
||||||
|
|
@ -21,8 +21,9 @@
|
||||||
import { Fragment, type CSSProperties, type ReactNode } from 'react'
|
import { Fragment, type CSSProperties, type ReactNode } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { accentText } from '../lib/color.ts'
|
import { accentText } from '../lib/color.ts'
|
||||||
|
import { RotatingWords } from './RotatingWords.tsx'
|
||||||
|
|
||||||
const TOKEN = /\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)\s]+)\)/g
|
const TOKEN = /\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)\s]+)\)|\{([^{}|\n]+(?:\|[^{}|\n]+)+)\}/g
|
||||||
const SAFE_URL = /^(\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i
|
const SAFE_URL = /^(\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i
|
||||||
|
|
||||||
/** External if it has a scheme or starts with //; otherwise it's
|
/** External if it has a scheme or starts with //; otherwise it's
|
||||||
|
|
@ -83,9 +84,10 @@ function line(text: string, accent: string, key: string): ReactNode[] {
|
||||||
for (const match of text.matchAll(TOKEN)) {
|
for (const match of text.matchAll(TOKEN)) {
|
||||||
const at = match.index ?? 0
|
const at = match.index ?? 0
|
||||||
if (at > last) out.push(text.slice(last, at))
|
if (at > last) out.push(text.slice(last, at))
|
||||||
const [whole, bold, italic, label, url] = match
|
const [whole, bold, italic, label, url, words] = match
|
||||||
const k = `${key}-${n++}`
|
const k = `${key}-${n++}`
|
||||||
if (bold != null) out.push(<strong key={k} className="font-semibold">{bold}</strong>)
|
if (words != null) out.push(<RotatingWords key={k} words={words.split('|').map((word) => word.trim())} />)
|
||||||
|
else if (bold != null) out.push(<strong key={k} className="font-semibold">{bold}</strong>)
|
||||||
else if (italic != null) out.push(<em key={k}>{italic}</em>)
|
else if (italic != null) out.push(<em key={k}>{italic}</em>)
|
||||||
else if (label != null && SAFE_URL.test(url)) {
|
else if (label != null && SAFE_URL.test(url)) {
|
||||||
out.push(
|
out.push(
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ import { documentTitle } from "../lib/site.ts";
|
||||||
import { accentText, ACCENTS, BRAND } from '../lib/color.ts'
|
import { accentText, ACCENTS, BRAND } from '../lib/color.ts'
|
||||||
import { SectionNav, useActiveSection } from "./admin/SectionNav.tsx";
|
import { SectionNav, useActiveSection } from "./admin/SectionNav.tsx";
|
||||||
import "./PageShell.css";
|
import "./PageShell.css";
|
||||||
|
import { Words } from "./RotatingWords.tsx"
|
||||||
|
import { firstWords } from "../lib/words.ts";
|
||||||
|
|
||||||
|
|
||||||
export type ShellSection = {
|
export type ShellSection = {
|
||||||
|
|
@ -97,7 +99,7 @@ export function Section({ section }: { section: ShellSection }) {
|
||||||
<div className="flex flex-wrap items-end justify-between gap-4">
|
<div className="flex flex-wrap items-end justify-between gap-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-3xl md:text-4xl font-bold" style={{ color: accentText(accent) }}>
|
<h2 className="text-3xl md:text-4xl font-bold" style={{ color: accentText(accent) }}>
|
||||||
{title}
|
<Words text={title} />
|
||||||
</h2>
|
</h2>
|
||||||
{blurb && <p className="mt-2 text-muted max-w-xl">{blurb}</p>}
|
{blurb && <p className="mt-2 text-muted max-w-xl">{blurb}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -188,7 +190,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
|
||||||
return () => ro.disconnect();
|
return () => ro.disconnect();
|
||||||
}, [sideNav]);
|
}, [sideNav]);
|
||||||
const navSections = sideNav
|
const navSections = sideNav
|
||||||
? sections.filter((s) => !s.unlisted).map((s) => ({ id: s.id, label: s.title, accent: s.accent }))
|
? sections.filter((s) => !s.unlisted).map((s) => ({ id: s.id, label: firstWords(s.title), accent: s.accent }))
|
||||||
: [];
|
: [];
|
||||||
const active = useActiveSection(navSections);
|
const active = useActiveSection(navSections);
|
||||||
const activeAccent = sections.find((s) => s.id === active)?.accent;
|
const activeAccent = sections.find((s) => s.id === active)?.accent;
|
||||||
|
|
@ -279,7 +281,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
|
||||||
// comes from the server (pageMeta.js), which also sets the page's
|
// comes from the server (pageMeta.js), which also sets the page's
|
||||||
// description and preview for search and link sharing.
|
// description and preview for search and link sharing.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof title === "string") document.title = documentTitle(title);
|
if (typeof title === "string") document.title = documentTitle(firstWords(title));
|
||||||
}, [title]);
|
}, [title]);
|
||||||
|
|
||||||
// The thin solid banner between sections, the page's full width
|
// The thin solid banner between sections, the page's full width
|
||||||
|
|
@ -299,7 +301,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
|
||||||
<div className="pt-24 pb-12 px-6">
|
<div className="pt-24 pb-12 px-6">
|
||||||
<div className="max-w-6xl mx-auto">
|
<div className="max-w-6xl mx-auto">
|
||||||
<h1 className="text-4xl sm:text-5xl md:text-6xl font-bold [overflow-wrap:anywhere] hyphens-auto" style={{ color: accentText(BRAND) }}>
|
<h1 className="text-4xl sm:text-5xl md:text-6xl font-bold [overflow-wrap:anywhere] hyphens-auto" style={{ color: accentText(BRAND) }}>
|
||||||
{title}
|
{typeof title === "string" ? <Words text={title} /> : title}
|
||||||
</h1>
|
</h1>
|
||||||
{intro && <p className="mt-3 text-lg text-muted max-w-2xl">{intro}</p>}
|
{intro && <p className="mt-3 text-lg text-muted max-w-2xl">{intro}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
94
src/components/RotatingWords.css
Normal file
94
src/components/RotatingWords.css
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
/* Rotating words (RotatingWords.tsx): every word in one grid cell,
|
||||||
|
so the space is the longest word's; the current one 'in', the one
|
||||||
|
it replaced 'out', the rest 'idle' (hidden). */
|
||||||
|
|
||||||
|
.rotating-words {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rotating-words-stack {
|
||||||
|
display: inline-grid;
|
||||||
|
/* Room for descenders, and clipped so a sliding word comes in from
|
||||||
|
behind the line, not over the one above. */
|
||||||
|
padding-bottom: 0.08em;
|
||||||
|
overflow: hidden;
|
||||||
|
perspective: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rotating-word {
|
||||||
|
grid-area: 1 / 1;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition:
|
||||||
|
transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1),
|
||||||
|
opacity 0.55s ease;
|
||||||
|
backface-visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rotating-word[data-state="idle"] {
|
||||||
|
opacity: 0;
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* slide */
|
||||||
|
.rotating-words[data-motion="slide"][data-direction="top"] .rotating-word[data-state="idle"] {
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
|
.rotating-words[data-motion="slide"][data-direction="top"] .rotating-word[data-state="out"] {
|
||||||
|
transform: translateY(100%);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
.rotating-words[data-motion="slide"][data-direction="bottom"] .rotating-word[data-state="idle"] {
|
||||||
|
transform: translateY(100%);
|
||||||
|
}
|
||||||
|
.rotating-words[data-motion="slide"][data-direction="bottom"] .rotating-word[data-state="out"] {
|
||||||
|
transform: translateY(-100%);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* flip: like a card turning over on its horizontal edge */
|
||||||
|
.rotating-words[data-motion="flip"][data-direction="top"] .rotating-word[data-state="idle"] {
|
||||||
|
transform: rotateX(90deg);
|
||||||
|
}
|
||||||
|
.rotating-words[data-motion="flip"][data-direction="top"] .rotating-word[data-state="out"] {
|
||||||
|
transform: rotateX(-90deg);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
.rotating-words[data-motion="flip"][data-direction="bottom"] .rotating-word[data-state="idle"] {
|
||||||
|
transform: rotateX(-90deg);
|
||||||
|
}
|
||||||
|
.rotating-words[data-motion="flip"][data-direction="bottom"] .rotating-word[data-state="out"] {
|
||||||
|
transform: rotateX(90deg);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* mirror: turning on its upright, the new word coming round from behind */
|
||||||
|
.rotating-words[data-motion="mirror"] .rotating-word[data-state="idle"] {
|
||||||
|
transform: rotateY(-180deg);
|
||||||
|
}
|
||||||
|
.rotating-words[data-motion="mirror"] .rotating-word[data-state="out"] {
|
||||||
|
transform: rotateY(180deg);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fade, and type (the letters appear; the old word fades) */
|
||||||
|
.rotating-words[data-motion="fade"] .rotating-word[data-state="out"],
|
||||||
|
.rotating-words[data-motion="type"] .rotating-word[data-state="out"] {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rotating-words-caret {
|
||||||
|
display: inline-block;
|
||||||
|
width: 0.08em;
|
||||||
|
height: 0.9em;
|
||||||
|
margin-left: 0.04em;
|
||||||
|
vertical-align: -0.08em;
|
||||||
|
background: currentColor;
|
||||||
|
animation: rotating-words-blink 1s steps(1) infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes rotating-words-blink {
|
||||||
|
50% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
117
src/components/RotatingWords.tsx
Normal file
117
src/components/RotatingWords.tsx
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
ROTATING WORDS
|
||||||
|
|
||||||
|
A word that cycles through choices in place, typed into any title
|
||||||
|
or text as {Next|Now|Rising}: the hero's headline, a section's
|
||||||
|
title, a heading or a paragraph (InlineText.tsx parses the braces).
|
||||||
|
|
||||||
|
How it moves comes from the nearest WordMotion (the hero's or a
|
||||||
|
block's own settings) over the site's defaults (Site settings →
|
||||||
|
Animated words, window.__SITE__.words):
|
||||||
|
|
||||||
|
motion slide, flip, fade, type or mirror
|
||||||
|
direction where a sliding or flipping word comes from: top
|
||||||
|
or bottom
|
||||||
|
seconds how long each word shows
|
||||||
|
|
||||||
|
The space it takes is the longest word's, every word stacked in
|
||||||
|
one grid cell, so the line never jumps. With less motion (the
|
||||||
|
system's setting, or reading mode) it's the first word, still;
|
||||||
|
screen readers always get the first word, not a changing one.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { createContext, useContext, useEffect, useState, type ReactNode } from 'react'
|
||||||
|
|
||||||
|
import { prefersLessMotion } from '../lib/motion.ts'
|
||||||
|
import { WORD_DEFAULTS, type WordSettings } from '../lib/site.ts'
|
||||||
|
import { WORD_GROUP } from '../lib/words.ts'
|
||||||
|
import './RotatingWords.css'
|
||||||
|
|
||||||
|
/* Settings for the words inside: a hero's or a block's (blank keeps
|
||||||
|
what's around it). */
|
||||||
|
const WordContext = createContext<WordSettings>(WORD_DEFAULTS)
|
||||||
|
|
||||||
|
/* Blank (null) keeps what's around it. */
|
||||||
|
type WordOverrides = { motion?: WordSettings['motion'] | null; direction?: WordSettings['direction'] | null; seconds?: number | null }
|
||||||
|
|
||||||
|
export function WordMotion({ settings, children }: { settings?: WordOverrides | null; children: ReactNode }) {
|
||||||
|
const around = useContext(WordContext)
|
||||||
|
const value = {
|
||||||
|
motion: settings?.motion || around.motion,
|
||||||
|
direction: settings?.direction || around.direction,
|
||||||
|
seconds: settings?.seconds || around.seconds,
|
||||||
|
}
|
||||||
|
return <WordContext.Provider value={value}>{children}</WordContext.Provider>
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A text with its groups as rotating words, the rest as it is. */
|
||||||
|
export function Words({ text }: { text?: string | null }) {
|
||||||
|
const parts: ReactNode[] = []
|
||||||
|
const source = text ?? ''
|
||||||
|
let last = 0
|
||||||
|
let n = 0
|
||||||
|
for (const match of source.matchAll(WORD_GROUP)) {
|
||||||
|
const at = match.index ?? 0
|
||||||
|
if (at > last) parts.push(source.slice(last, at))
|
||||||
|
parts.push(<RotatingWords key={n++} words={match[1].split('|').map((word) => word.trim())} />)
|
||||||
|
last = at + match[0].length
|
||||||
|
}
|
||||||
|
if (last < source.length) parts.push(source.slice(last))
|
||||||
|
return <>{parts}</>
|
||||||
|
}
|
||||||
|
|
||||||
|
const TYPE_STEP_MS = 70
|
||||||
|
|
||||||
|
export function RotatingWords({ words }: { words: string[] }) {
|
||||||
|
const { motion, direction, seconds } = useContext(WordContext)
|
||||||
|
const [index, setIndex] = useState(0)
|
||||||
|
const [still, setStill] = useState(true)
|
||||||
|
// For 'type': how many letters of the current word show.
|
||||||
|
const [typed, setTyped] = useState(words[0]?.length ?? 0)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (prefersLessMotion() || words.length < 2) return undefined
|
||||||
|
setStill(false)
|
||||||
|
const timer = window.setInterval(() => setIndex((i) => (i + 1) % words.length), Math.max(1, seconds) * 1000)
|
||||||
|
return () => window.clearInterval(timer)
|
||||||
|
}, [words.length, seconds])
|
||||||
|
|
||||||
|
// Typing: the word appears a letter at a time.
|
||||||
|
useEffect(() => {
|
||||||
|
if (still || motion !== 'type') return undefined
|
||||||
|
setTyped(0)
|
||||||
|
const word = words[index] ?? ''
|
||||||
|
let shown = 0
|
||||||
|
const timer = window.setInterval(() => {
|
||||||
|
shown += 1
|
||||||
|
setTyped(shown)
|
||||||
|
if (shown >= word.length) window.clearInterval(timer)
|
||||||
|
}, TYPE_STEP_MS)
|
||||||
|
return () => window.clearInterval(timer)
|
||||||
|
}, [index, motion, still, words])
|
||||||
|
|
||||||
|
if (still) return <>{words[0]}</>
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className="rotating-words" data-motion={motion} data-direction={direction}>
|
||||||
|
<span className="sr-only">{words[0]}</span>
|
||||||
|
<span className="rotating-words-stack" aria-hidden="true">
|
||||||
|
{words.map((word, i) => {
|
||||||
|
const state = i === index ? 'in' : i === (index + words.length - 1) % words.length ? 'out' : 'idle'
|
||||||
|
return (
|
||||||
|
<span key={i} className="rotating-word" data-state={state}>
|
||||||
|
{motion === 'type' && i === index ? (
|
||||||
|
<>
|
||||||
|
{word.slice(0, typed)}
|
||||||
|
<span className="rotating-words-caret" />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
word
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -346,6 +346,45 @@ export const HREF_HELP = {
|
||||||
video: "The video's page, eg. https://www.youtube.com/watch?v=…, or a video file",
|
video: "The video's page, eg. https://www.youtube.com/watch?v=…, or a video file",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Rotating words (084): text typed as {Next|Now|Rising} cycles
|
||||||
|
through its choices. These pick how, for a block or a hero; Site
|
||||||
|
settings → Animated words holds the defaults. */
|
||||||
|
export const WORD_MOTIONS = [
|
||||||
|
["slide", "Slide"],
|
||||||
|
["flip", "Flip, like a card"],
|
||||||
|
["fade", "Fade"],
|
||||||
|
["type", "Type, letter by letter"],
|
||||||
|
["mirror", "Mirror, turning round"],
|
||||||
|
];
|
||||||
|
export const WORD_DIRECTIONS = [
|
||||||
|
["bottom", "From the bottom"],
|
||||||
|
["top", "From the top"],
|
||||||
|
];
|
||||||
|
export const WORD_HELP = "Type choices in braces to rotate them, eg. {Next|Now|Rising} Generation of {Unity|New Thought}.";
|
||||||
|
|
||||||
|
/* The three fields, under `prefix` (eg. "hero."), shown `when`. */
|
||||||
|
export const wordFields = (prefix: string, label: string, when?: any) => [
|
||||||
|
{
|
||||||
|
path: `${prefix}word_motion`,
|
||||||
|
label: label ? `${label}rotating words` : "Rotating words",
|
||||||
|
widget: "select",
|
||||||
|
options: WORD_MOTIONS,
|
||||||
|
blankLabel: "Default: the site's (Site settings → Animated words)",
|
||||||
|
help: WORD_HELP,
|
||||||
|
when,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: `${prefix}word_direction`,
|
||||||
|
label: label ? `${label}words come in` : "Words come in",
|
||||||
|
widget: "select",
|
||||||
|
options: WORD_DIRECTIONS,
|
||||||
|
blankLabel: "Default: the site's",
|
||||||
|
help: "For Slide and Flip",
|
||||||
|
when,
|
||||||
|
},
|
||||||
|
{ path: `${prefix}word_seconds`, label: label ? `${label}seconds per word` : "Seconds per word", widget: "number", help: "1 to 20. Default: the site's", when },
|
||||||
|
];
|
||||||
|
|
||||||
export const blocksChild = {
|
export const blocksChild = {
|
||||||
key: "content_blocks",
|
key: "content_blocks",
|
||||||
label: "Content blocks",
|
label: "Content blocks",
|
||||||
|
|
@ -441,6 +480,7 @@ export const blocksChild = {
|
||||||
help: "Shows the team's members as tiles, its leads first. People added as items show after it.",
|
help: "Shows the team's members as tiles, its leads first. People added as items show after it.",
|
||||||
when: { path: "type", value: "people" },
|
when: { path: "type", value: "people" },
|
||||||
},
|
},
|
||||||
|
...wordFields("", "", { path: "type", value: ["heading", "subheading", "paragraph", "callout", "quote"] }),
|
||||||
],
|
],
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
every page offers them all. The Community blog's settings show on
|
every page offers them all. The Community blog's settings show on
|
||||||
the Community page only (its id), for now. */
|
the Community page only (its id), for now. */
|
||||||
|
|
||||||
import { FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
|
import { FEATURED_KINDS, featuredCardsChild, blocksChild, wordFields } from "./shared.ts";
|
||||||
import { mediaUrl } from "../media.ts";
|
import { mediaUrl } from "../media.ts";
|
||||||
import { PATH_ICONS } from "../../data/pathIcons.ts";
|
import { PATH_ICONS } from "../../data/pathIcons.ts";
|
||||||
|
|
||||||
|
|
@ -146,6 +146,7 @@ const BAND_FIELDS = [
|
||||||
help: "For the Featured event feature. A pinned event that's over falls back to the countdown's",
|
help: "For the Featured event feature. A pinned event that's over falls back to the countdown's",
|
||||||
when: IS("hero"),
|
when: IS("hero"),
|
||||||
},
|
},
|
||||||
|
...wordFields("hero.", "Hero: ", IS("hero")),
|
||||||
{
|
{
|
||||||
path: "countdown.event_id",
|
path: "countdown.event_id",
|
||||||
label: "Count down to",
|
label: "Count down to",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import siteConfiguration from "../../../site.json";
|
import siteConfiguration from "../../../site.json";
|
||||||
import { mediaUrl } from "../media.ts";
|
import { mediaUrl } from "../media.ts";
|
||||||
import { THEME_DEFAULTS } from "../../../server/src/themeDefaults.js";
|
import { THEME_DEFAULTS } from "../../../server/src/themeDefaults.js";
|
||||||
|
import { WORD_DIRECTIONS, WORD_HELP, WORD_MOTIONS } from "./shared.ts";
|
||||||
|
|
||||||
/* ── Site settings (035_site_settings.sql) ───────────────────────
|
/* ── Site settings (035_site_settings.sql) ───────────────────────
|
||||||
Overrides for site.json, superadmins only: every blank falls back
|
Overrides for site.json, superadmins only: every blank falls back
|
||||||
|
|
@ -158,6 +159,15 @@ export const siteSettings = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
legend: "Animated words",
|
||||||
|
note: WORD_HELP + " Works in the hero's headline, section titles, headings and paragraphs. These are the defaults; a hero or a block can set its own. Visitors who ask for less motion see the first word, still.",
|
||||||
|
fields: [
|
||||||
|
{ path: "word_motion", label: "Motion", widget: "select", options: WORD_MOTIONS, blankLabel: "Default: Slide" },
|
||||||
|
{ path: "word_direction", label: "Words come in", widget: "select", options: WORD_DIRECTIONS, blankLabel: "Default: from the bottom", help: "For Slide and Flip" },
|
||||||
|
{ path: "word_seconds", label: "Seconds per word", widget: "number", help: "1 to 20. Default: 3" },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
legend: "Notices",
|
legend: "Notices",
|
||||||
fields: [
|
fields: [
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { useCallback } from 'react'
|
||||||
|
|
||||||
import { useSitePageHeadings } from './useSitePages.ts'
|
import { useSitePageHeadings } from './useSitePages.ts'
|
||||||
import { UNLISTED_PRESETS } from '../pages/sections/Bands.tsx'
|
import { UNLISTED_PRESETS } from '../pages/sections/Bands.tsx'
|
||||||
|
import { firstWords } from '../lib/words.ts'
|
||||||
|
|
||||||
export type NavSection = { label: string; hash: string }
|
export type NavSection = { label: string; hash: string }
|
||||||
|
|
||||||
|
|
@ -23,7 +24,7 @@ export function useNavSections(): (path: string) => NavSection[] {
|
||||||
(path: string) =>
|
(path: string) =>
|
||||||
(sitePages?.[path] ?? [])
|
(sitePages?.[path] ?? [])
|
||||||
.filter((section) => !UNLISTED_PRESETS.includes(section.preset ?? ''))
|
.filter((section) => !UNLISTED_PRESETS.includes(section.preset ?? ''))
|
||||||
.map((section) => ({ label: section.title, hash: `#${section.anchor}` })),
|
.map((section) => ({ label: firstWords(section.title), hash: `#${section.anchor}` })),
|
||||||
[sitePages],
|
[sitePages],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
import { readableOn } from './color.ts'
|
import { readableOn } from './color.ts'
|
||||||
import { PLATFORMS } from './platforms.ts'
|
import { PLATFORMS } from './platforms.ts'
|
||||||
|
import { firstWords } from '../lib/words.ts'
|
||||||
|
|
||||||
export type NewsletterItem = {
|
export type NewsletterItem = {
|
||||||
title: string
|
title: string
|
||||||
|
|
@ -186,7 +187,8 @@ const imageTag = (src: string, alt: string) =>
|
||||||
`<img src="${escape(src)}" width="552" alt="${escape(alt)}" style="display:block;margin:0 auto;width:100%;max-width:552px;height:auto;border:0;">`
|
`<img src="${escape(src)}" width="552" alt="${escape(alt)}" style="display:block;margin:0 auto;width:100%;max-width:552px;height:auto;border:0;">`
|
||||||
|
|
||||||
function blockHtml(block: NewsletterPart, n: Newsletter): string {
|
function blockHtml(block: NewsletterPart, n: Newsletter): string {
|
||||||
const text = block.text?.trim() ?? ''
|
// An email can't animate: rotating words ({Next|Now}) are their first.
|
||||||
|
const text = firstWords(block.text).trim()
|
||||||
const href = block.href ? safeHref(block.href, n) : null
|
const href = block.href ? safeHref(block.href, n) : null
|
||||||
const items = block.items ?? []
|
const items = block.items ?? []
|
||||||
const align = alignOf(block)
|
const align = alignOf(block)
|
||||||
|
|
@ -412,7 +414,7 @@ export function newsletterHtml(n: Newsletter): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function blockText(block: NewsletterPart, n: Newsletter): string[] {
|
function blockText(block: NewsletterPart, n: Newsletter): string[] {
|
||||||
const text = block.text?.trim() ?? ''
|
const text = firstWords(block.text).trim()
|
||||||
const items = block.items ?? []
|
const items = block.items ?? []
|
||||||
const link = (url: string) => safeHref(url, n) ?? url
|
const link = (url: string) => safeHref(url, n) ?? url
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ export type Hero = {
|
||||||
video: { url: string; title?: string | null; captions?: string | null; still?: string | null } | null
|
video: { url: string; title?: string | null; captions?: string | null; still?: string | null } | null
|
||||||
/** With the 'event' feature: the pinned event, else the page's countdown's. */
|
/** With the 'event' feature: the pinned event, else the page's countdown's. */
|
||||||
event: HeroEvent | null
|
event: HeroEvent | null
|
||||||
|
/** Its rotating words' own motion (084), else the site's. */
|
||||||
|
words?: { motion?: any; direction?: any; seconds?: number | null } | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SectionStat = {
|
export type SectionStat = {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,10 @@
|
||||||
|
|
||||||
import siteConfiguration from '../../site.json'
|
import siteConfiguration from '../../site.json'
|
||||||
|
|
||||||
type SiteText = { title?: string; requestFiles?: boolean }
|
/** How rotating words move (RotatingWords.tsx, 084). */
|
||||||
|
export type WordSettings = { motion: 'slide' | 'flip' | 'fade' | 'type' | 'mirror'; direction: 'top' | 'bottom'; seconds: number }
|
||||||
|
|
||||||
|
type SiteText = { title?: string; requestFiles?: boolean; words?: Partial<WordSettings> | null }
|
||||||
|
|
||||||
/* What the server wrote into the page, if it did. */
|
/* What the server wrote into the page, if it did. */
|
||||||
const fromServer: SiteText =
|
const fromServer: SiteText =
|
||||||
|
|
@ -33,6 +36,14 @@ export const SITE_NAME: string = fromServer.title || siteConfiguration.title
|
||||||
|
|
||||||
export const SITE_ORIGIN: string = siteConfiguration.url
|
export const SITE_ORIGIN: string = siteConfiguration.url
|
||||||
|
|
||||||
|
/** Rotating words' defaults: Site settings → Animated words, else
|
||||||
|
* sliding up from the bottom, three seconds a word. */
|
||||||
|
export const WORD_DEFAULTS: WordSettings = {
|
||||||
|
motion: fromServer.words?.motion || 'slide',
|
||||||
|
direction: fromServer.words?.direction || 'bottom',
|
||||||
|
seconds: fromServer.words?.seconds || 3,
|
||||||
|
}
|
||||||
|
|
||||||
/** Whether the Request form takes files (Google Drive is set up on
|
/** Whether the Request form takes files (Google Drive is set up on
|
||||||
* the server). Unknown (the Vite dev server) offers them, and the
|
* the server). Unknown (the Vite dev server) offers them, and the
|
||||||
* server says so if it can't. */
|
* server says so if it can't. */
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ import type { EventSeries } from './eventSeries.ts'
|
||||||
export type ContentBlock = {
|
export type ContentBlock = {
|
||||||
id?: number | string
|
id?: number | string
|
||||||
slot?: 'card' | 'body'
|
slot?: 'card' | 'body'
|
||||||
|
/** Its rotating words' own motion (084), else the site's. */
|
||||||
|
words?: { motion?: any; direction?: any; seconds?: number | null } | null
|
||||||
type:
|
type:
|
||||||
| 'heading'
|
| 'heading'
|
||||||
| 'subheading'
|
| 'subheading'
|
||||||
|
|
|
||||||
10
src/lib/words.ts
Normal file
10
src/lib/words.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/* Rotating words as plain text (src/components/RotatingWords.tsx
|
||||||
|
draws them moving): a group typed as {Next|Now|Rising}. */
|
||||||
|
|
||||||
|
/** {A|B} groups in a text. */
|
||||||
|
export const WORD_GROUP = /\{([^{}|\n]+(?:\|[^{}|\n]+)+)\}/g
|
||||||
|
|
||||||
|
/** The text as plain words, each group its first choice: for menus,
|
||||||
|
* tab titles, emails and anywhere that can't move. */
|
||||||
|
export const firstWords = (text?: string | null): string =>
|
||||||
|
(text ?? '').replace(WORD_GROUP, (_, group: string) => group.split('|')[0].trim())
|
||||||
|
|
@ -44,6 +44,7 @@ import CommunityBlog from './sections/CommunityBlog.tsx'
|
||||||
import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
|
import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
|
||||||
import { DirectoryTabs, DIRECTORY_PREVIEW } from './sections/PeopleDirectory.tsx'
|
import { DirectoryTabs, DIRECTORY_PREVIEW } from './sections/PeopleDirectory.tsx'
|
||||||
import { DataRequestSection, FeedbackSection, GivingSection, QrSection, RequestSection } from './sections/FormSections.tsx'
|
import { DataRequestSection, FeedbackSection, GivingSection, QrSection, RequestSection } from './sections/FormSections.tsx'
|
||||||
|
import { Words } from '../components/RotatingWords.tsx'
|
||||||
|
|
||||||
/* Year the program starts: decades ending before it get the
|
/* Year the program starts: decades ending before it get the
|
||||||
pre-program look on the timeline. */
|
pre-program look on the timeline. */
|
||||||
|
|
@ -235,7 +236,9 @@ function PlainBand({ section }: { section: SitePageSection }) {
|
||||||
return (
|
return (
|
||||||
<section id={section.anchor} className="py-24">
|
<section id={section.anchor} className="py-24">
|
||||||
<div className="mx-auto mb-12 max-w-6xl px-6">
|
<div className="mx-auto mb-12 max-w-6xl px-6">
|
||||||
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">{section.title}</h2>
|
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">
|
||||||
|
<Words text={section.title} />
|
||||||
|
</h2>
|
||||||
{section.blurb && <p className="mt-3 max-w-xl text-lg text-muted">{section.blurb}</p>}
|
{section.blurb && <p className="mt-3 max-w-xl text-lg text-muted">{section.blurb}</p>}
|
||||||
</div>
|
</div>
|
||||||
<SectionBody
|
<SectionBody
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
import EventCalendar from '../EventCalendar.tsx'
|
import EventCalendar from '../EventCalendar.tsx'
|
||||||
import RequestLink from '../../../components/RequestLink.tsx'
|
import RequestLink from '../../../components/RequestLink.tsx'
|
||||||
|
import { Words } from '../../../components/RotatingWords.tsx'
|
||||||
|
|
||||||
type CalendarBandProps = { id: string; title: string; blurb?: string | null }
|
type CalendarBandProps = { id: string; title: string; blurb?: string | null }
|
||||||
|
|
||||||
|
|
@ -19,7 +20,7 @@ export default function CalendarBand({ id, title, blurb }: CalendarBandProps) {
|
||||||
<div className="mx-auto mb-10 flex max-w-6xl flex-wrap items-end justify-between gap-4 px-6">
|
<div className="mx-auto mb-10 flex max-w-6xl flex-wrap items-end justify-between gap-4 px-6">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">
|
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">
|
||||||
{title}
|
<Words text={title} />
|
||||||
</h2>
|
</h2>
|
||||||
{blurb && <p className="mt-3 max-w-xl text-lg text-muted">{blurb}</p>}
|
{blurb && <p className="mt-3 max-w-xl text-lg text-muted">{blurb}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
import FeaturedCards from '../../../components/FeaturedCards.tsx'
|
import FeaturedCards from '../../../components/FeaturedCards.tsx'
|
||||||
import type { FeaturedCard, FeaturedColumns } from '../../../lib/sectionTypes.ts'
|
import type { FeaturedCard, FeaturedColumns } from '../../../lib/sectionTypes.ts'
|
||||||
|
import { Words } from '../../../components/RotatingWords.tsx'
|
||||||
|
|
||||||
type FeaturedBandProps = {
|
type FeaturedBandProps = {
|
||||||
id: string
|
id: string
|
||||||
|
|
@ -22,7 +23,7 @@ export default function FeaturedBand({ id, title, blurb, cards, columns }: Featu
|
||||||
return (
|
return (
|
||||||
<section id={id} className="py-24">
|
<section id={id} className="py-24">
|
||||||
<div className="mx-auto max-w-6xl px-6">
|
<div className="mx-auto max-w-6xl px-6">
|
||||||
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">{title}</h2>
|
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl"><Words text={title} /></h2>
|
||||||
{blurb && <p className="mt-4 max-w-2xl text-lg text-muted">{blurb}</p>}
|
{blurb && <p className="mt-4 max-w-2xl text-lg text-muted">{blurb}</p>}
|
||||||
<div className="mt-12">
|
<div className="mt-12">
|
||||||
<FeaturedCards cards={cards} columns={columns ?? undefined} />
|
<FeaturedCards cards={cards} columns={columns ?? undefined} />
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import { MONTH_LABELS, type TimelineItem } from '../../../lib/timeline.ts'
|
||||||
import { accentText, BRAND } from '../../../lib/color.ts'
|
import { accentText, BRAND } from '../../../lib/color.ts'
|
||||||
import { scrollBehavior } from '../../../lib/motion.ts';
|
import { scrollBehavior } from '../../../lib/motion.ts';
|
||||||
import { useReadingMode } from '../../../lib/readingMode.ts'
|
import { useReadingMode } from '../../../lib/readingMode.ts'
|
||||||
|
import { Words } from '../../../components/RotatingWords.tsx'
|
||||||
|
|
||||||
const DRAG_SLOP = 6
|
const DRAG_SLOP = 6
|
||||||
|
|
||||||
|
|
@ -54,7 +55,7 @@ export default function FeaturedTimelineRail({ id, title, blurb }: RailProps) {
|
||||||
if (reading) {
|
if (reading) {
|
||||||
return (
|
return (
|
||||||
<section id={id}>
|
<section id={id}>
|
||||||
<h2>{title}</h2>
|
<h2><Words text={title} /></h2>
|
||||||
{blurb && <p>{blurb}</p>}
|
{blurb && <p>{blurb}</p>}
|
||||||
{error ? (
|
{error ? (
|
||||||
<p>Couldn’t load the timeline. {error}</p>
|
<p>Couldn’t load the timeline. {error}</p>
|
||||||
|
|
@ -104,7 +105,7 @@ export default function FeaturedTimelineRail({ id, title, blurb }: RailProps) {
|
||||||
<div className="mx-auto flex max-w-6xl flex-wrap items-end gap-6 px-6">
|
<div className="mx-auto flex max-w-6xl flex-wrap items-end gap-6 px-6">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">
|
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">
|
||||||
{title}
|
<Words text={title} />
|
||||||
</h2>
|
</h2>
|
||||||
{blurb && <p className="mt-3 max-w-xl text-lg text-muted">{blurb}</p>}
|
{blurb && <p className="mt-3 max-w-xl text-lg text-muted">{blurb}</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ import { useReadingMode } from '../../../lib/readingMode.ts'
|
||||||
import { eventHref } from '../../../lib/hrefs.ts'
|
import { eventHref } from '../../../lib/hrefs.ts'
|
||||||
import { seriesLabel } from '../../../lib/eventSeries.ts'
|
import { seriesLabel } from '../../../lib/eventSeries.ts'
|
||||||
import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/sectionTypes.ts'
|
import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/sectionTypes.ts'
|
||||||
|
import { WordMotion, Words as RotatingText } from '../../../components/RotatingWords.tsx'
|
||||||
|
import { firstWords } from '../../../lib/words.ts'
|
||||||
|
|
||||||
const DEEP = '#001011'
|
const DEEP = '#001011'
|
||||||
|
|
||||||
|
|
@ -187,7 +189,9 @@ function Words({ hero, feature }: { hero: Hero; feature: HeroFeature }) {
|
||||||
} [overflow-wrap:anywhere]`}
|
} [overflow-wrap:anywhere]`}
|
||||||
style={{ animationDelay: '60ms' }}
|
style={{ animationDelay: '60ms' }}
|
||||||
>
|
>
|
||||||
{hero.headline}
|
<WordMotion settings={hero.words}>
|
||||||
|
<RotatingText text={hero.headline} />
|
||||||
|
</WordMotion>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{hero.subhead && (
|
{hero.subhead && (
|
||||||
|
|
@ -226,7 +230,7 @@ function ReadingHero({ hero, feature, slides, video }: ReadingHeroProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{feature === 'none' && hero.eyebrow && <p>{hero.eyebrow}</p>}
|
{feature === 'none' && hero.eyebrow && <p>{hero.eyebrow}</p>}
|
||||||
<h1>{hero.headline}</h1>
|
<h1>{firstWords(hero.headline)}</h1>
|
||||||
{hero.subhead && <p>{hero.subhead}</p>}
|
{hero.subhead && <p>{hero.subhead}</p>}
|
||||||
{[hero.primary, hero.secondary].map(
|
{[hero.primary, hero.secondary].map(
|
||||||
(button) =>
|
(button) =>
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ import HomeLink, { isExternal } from './HomeLink.tsx'
|
||||||
import type { SectionPath } from '../../../lib/sectionTypes.ts'
|
import type { SectionPath } from '../../../lib/sectionTypes.ts'
|
||||||
import { ACCENTS, accentText, readableOn } from '../../../lib/color.ts'
|
import { ACCENTS, accentText, readableOn } from '../../../lib/color.ts'
|
||||||
import { useReadingMode } from '../../../lib/readingMode.ts'
|
import { useReadingMode } from '../../../lib/readingMode.ts'
|
||||||
|
import { Words } from '../../../components/RotatingWords.tsx'
|
||||||
|
import { firstWords } from '../../../lib/words.ts'
|
||||||
|
|
||||||
type PathfinderProps = {
|
type PathfinderProps = {
|
||||||
id: string
|
id: string
|
||||||
|
|
@ -80,7 +82,7 @@ export default function Pathfinder({ id, title, blurb, paths }: PathfinderProps)
|
||||||
if (reading) {
|
if (reading) {
|
||||||
return (
|
return (
|
||||||
<section id={id}>
|
<section id={id}>
|
||||||
<h2>{title}</h2>
|
<h2><Words text={title} /></h2>
|
||||||
{blurb && <p>{blurb}</p>}
|
{blurb && <p>{blurb}</p>}
|
||||||
{paths.map((option, index) => (
|
{paths.map((option, index) => (
|
||||||
<div key={`${option.label}-${index}`}>
|
<div key={`${option.label}-${index}`}>
|
||||||
|
|
@ -131,14 +133,14 @@ export default function Pathfinder({ id, title, blurb, paths }: PathfinderProps)
|
||||||
return (
|
return (
|
||||||
<section id={id} className="py-24">
|
<section id={id} className="py-24">
|
||||||
<div className="mx-auto max-w-6xl px-6">
|
<div className="mx-auto max-w-6xl px-6">
|
||||||
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl">{title}</h2>
|
<h2 className="font-display text-4xl font-bold text-ink md:text-5xl"><Words text={title} /></h2>
|
||||||
{blurb && <p className="mt-4 max-w-2xl text-lg text-muted">{blurb}</p>}
|
{blurb && <p className="mt-4 max-w-2xl text-lg text-muted">{blurb}</p>}
|
||||||
|
|
||||||
<div className="mt-12 overflow-hidden shadow-md">
|
<div className="mt-12 overflow-hidden shadow-md">
|
||||||
<div className="-mr-[4px] -mb-[4px]">
|
<div className="-mr-[4px] -mb-[4px]">
|
||||||
<div
|
<div
|
||||||
role="tablist"
|
role="tablist"
|
||||||
aria-label={title}
|
aria-label={firstWords(title)}
|
||||||
aria-orientation="horizontal"
|
aria-orientation="horizontal"
|
||||||
className="grid sm:grid-cols-2 lg:grid-cols-[repeat(var(--paths),minmax(0,1fr))]"
|
className="grid sm:grid-cols-2 lg:grid-cols-[repeat(var(--paths),minmax(0,1fr))]"
|
||||||
style={{ '--paths': Math.min(paths.length, 5) } as CSSProperties}
|
style={{ '--paths': Math.min(paths.length, 5) } as CSSProperties}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import { useEffect, useRef, useState } from 'react'
|
||||||
import type { SectionStat } from '../../../lib/sectionTypes.ts'
|
import type { SectionStat } from '../../../lib/sectionTypes.ts'
|
||||||
import { prefersLessMotion } from '../../../lib/motion.ts'
|
import { prefersLessMotion } from '../../../lib/motion.ts'
|
||||||
import { useReadingMode } from '../../../lib/readingMode.ts'
|
import { useReadingMode } from '../../../lib/readingMode.ts'
|
||||||
|
import { Words } from '../../../components/RotatingWords.tsx'
|
||||||
|
|
||||||
const COUNT_MS = 1400
|
const COUNT_MS = 1400
|
||||||
|
|
||||||
|
|
@ -50,7 +51,7 @@ export default function StatsBand({ id, title, blurb, stats }: StatsBandProps) {
|
||||||
if (useReadingMode()) {
|
if (useReadingMode()) {
|
||||||
return (
|
return (
|
||||||
<section id={id}>
|
<section id={id}>
|
||||||
<h2>{title}</h2>
|
<h2><Words text={title} /></h2>
|
||||||
{blurb && <p>{blurb}</p>}
|
{blurb && <p>{blurb}</p>}
|
||||||
<ul>
|
<ul>
|
||||||
{stats.map((stat, index) => (
|
{stats.map((stat, index) => (
|
||||||
|
|
@ -74,7 +75,7 @@ export default function StatsBand({ id, title, blurb, stats }: StatsBandProps) {
|
||||||
>
|
>
|
||||||
<div className="relative mx-auto max-w-6xl px-6">
|
<div className="relative mx-auto max-w-6xl px-6">
|
||||||
<h2 className="font-display text-3xl font-bold text-white md:text-4xl">
|
<h2 className="font-display text-3xl font-bold text-white md:text-4xl">
|
||||||
{title}
|
<Words text={title} />
|
||||||
</h2>
|
</h2>
|
||||||
{blurb && <p className="mt-3 max-w-2xl text-white/70">{blurb}</p>}
|
{blurb && <p className="mt-3 max-w-2xl text-white/70">{blurb}</p>}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue