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:
Aidan Dona 2026-10-17 00:43:59 -05:00
parent ab8dcdd608
commit a10ff6d75f
30 changed files with 411 additions and 37 deletions

View file

@ -164,6 +164,10 @@ export const blocksChild = (ownerKind) => ({
text("cite"),
// Video blocks only (066): an uploaded video's WebVTT file.
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.
text("team_id"),
],

View file

@ -84,6 +84,10 @@ const sectionsChild = {
text("video_captions"),
text("video_still"),
text("event_id"),
// Its rotating words (084).
enumeration("word_motion", ["slide", "flip", "fade", "type", "mirror"]),
enumeration("word_direction", ["top", "bottom"]),
int("word_seconds"),
],
},
{

View file

@ -1,5 +1,5 @@
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) ──────────────────────
A singleton of overrides for what site.json says: name,
@ -36,6 +36,10 @@ export const siteSettings = {
text("access_group_admin"),
enumeration("report_daily", ["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: [

View 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);

View file

@ -100,6 +100,8 @@ export function siteFor(db) {
...base.robots,
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
// text, so safe inside <style>.
themeCss: themeCss(db),
@ -114,6 +116,7 @@ const forBrowser = (site, nav) => ({
title: site.title,
pages: site.pages,
requestFiles: driveReady(),
words: site.words,
nav,
});
@ -138,6 +141,8 @@ export function plainText(text) {
const flat = String(text)
.slice(0, 2000)
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
// Rotating words ({Next|Now}, 084): the first.
.replace(/\{([^{}|\n]+)(?:\|[^{}|\n]+)+\}/g, "$1")
.replace(/\*\*(.+?)\*\*/g, "$1")
.replace(/\*(.+?)\*/g, "$1")
.replace(/\s+/g, " ")

View file

@ -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 }
: null,
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 },
};
}

View file

@ -70,7 +70,8 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const blockRows = db
.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
WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)})
ORDER BY owner_id, sort_order`,
@ -91,6 +92,10 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
cite: row.cite,
captions: row.captions,
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: [],
};
byId.set(row.id, block);