docs: OpenSpec change add-page-sections

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-03 10:30:11 +08:00
1 parent 1b5d62403d
commit 2ff117e41d
5 files changed
+180

No files matched your search

@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-03
@@ -0,0 +1,28 @@
## Context
Design: `docs/superpowers/specs/2026-12-03-page-builder-design.md`, change 1. Blocks are one JSON list per page, validated by `CmsBlockValidator`, passed through mobile-api as maps, rendered by `LandingPage`/`Block` in `CmsBlocks.tsx`, and edited by `BlockFields.tsx`.
## Goals / Non-Goals
**Goals:** four new section types, a look per section, an optional hero image, form-editor support.
**Non-Goals:** the on-page editor and templates (changes 2 and 3); per-element colours or fonts.
## Decisions
1. **One `cards` list** for FEATURES, STEPS and TRUST: items `{icon, title, text}`. FEATURES uses all three (icon required, from a fixed list); STEPS uses title and text (numbered by position); TRUST uses title only. Fields a type does not use are refused, so stored JSON stays clean. Limits: 2 to 6 cards, title 80, text 300.
2. **Icons** are a fixed list of Lucide names: `wifi, phone, tv, monitor, lock, shield-check, cloud, wrench, headset, users, calendar, star`. The server checks the name; the portal maps names to components, so no icon markup is stored.
3. **CTA** is heading (required), text (optional) and a button (required: a CTA without one has no purpose). Same link rule as other buttons.
4. **Look** is an optional block field `look`: `DEFAULT` (or absent), `MUTED`, `DARK`, `ACCENT`. Any block type may carry it. Non-default looks render the block as a full-width band (background across the window, content in the usual width, vertical padding); `ACCENT` uses the company accent with `contrastText` for the text, falling back to the default primary colour. `DEFAULT` renders as today, so existing pages are unchanged.
5. **Hero image optional.** A hero without an image already renders as plain text in the renderer; only the validator's requirement goes. A given image must still be the company's.
6. **Editor.** Each new type gets an "Add …" button, its fields, and a card list with add/remove/move like FAQ items. The look picker is a select on every block.
## Risks / Trade-offs
- A Dark or Accent band right after another band of the same look merges visually → acceptable; staff see it in the preview.
- `HTML` blocks with a look: the band surrounds the frame; harmless.
- Rollback: pages saved with new types must be edited before the previous release saves them; their new sections render as nothing under it.
## Migration Plan
Deploy services-counter and the portal; run `sql/01-section-labels.sql`. Rollback: previous images and `sql/99-rollback.sql`.
@@ -0,0 +1,28 @@
## Why
Marketing staff will build a landing page for every event and are not technical. Today's blocks (hero, text, image with text, FAQ, form, custom HTML) cannot produce a page like the INS design without pasting HTML, which only a developer can maintain. This is change 1 of the page builder: `docs/superpowers/specs/2026-12-03-page-builder-design.md`.
## What Changes
- New section types: FEATURES (icon cards), STEPS (numbered steps), TRUST (a strip of short items) and CTA (a call-to-action band).
- Every section gets a look: Default, Muted, Dark or Accent (the company colour), drawn as a full-width band with readable text. Default keeps today's appearance, so existing pages do not change.
- A HERO image becomes optional.
- The form editor gains the new types, their fields and the look picker; labels in English and Chinese.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: new section types, section looks, optional hero image.
## Impact
- services-counter: `CmsBlock` gains `look` and `cards`; `CmsBlockValidator` rules for the new types. No DDL (blocks are JSON).
- mobile-api: none (blocks pass through).
- Portal: `cmsPages.ts`, `CmsBlocks.tsx`, `BlockFields.tsx`, `PageEditor.tsx` (add buttons), labels.
- SQL: `sql/01-section-labels.sql`, `sql/99-rollback.sql` (labels only).
- Rollback: the previous release refuses the new types and fields when such a page is saved, and renders unknown types as nothing.
@@ -0,0 +1,103 @@
## MODIFIED Requirements
### Requirement: A Page Is An Ordered List Of Typed Blocks
A page SHALL belong to one company and have a slug, a title, an optional meta description, a status (Draft or Published), a "hide header" flag that defaults to off, and an ordered list of zero to 30 blocks. The block types SHALL be HERO, RICH_TEXT, IMAGE_TEXT, FAQ, FORM, HTML, FEATURES, STEPS, TRUST and CTA. Blocks SHALL be returned in the order they were saved, and a valid save SHALL replace all of a page's blocks.
#### Scenario: Blocks read back in order
- **WHEN** staff save page `hotel-technology` with blocks HERO, RICH_TEXT, FORM
- **THEN** reading the page returns those three blocks in that order with their fields
#### Scenario: A save replaces the blocks
- **GIVEN** a page whose blocks are HERO and FAQ
- **WHEN** it is saved with only a RICH_TEXT block
- **THEN** the page has only that RICH_TEXT block
#### Scenario: An HTML block and the header flag read back
- **WHEN** staff save a page with "hide header" on and blocks HTML, FORM
- **THEN** reading the page returns "hide header" on and the HTML block with its HTML unchanged
#### Scenario: New section types read back
- **WHEN** staff save a page with blocks FEATURES, STEPS, TRUST and CTA
- **THEN** reading the page returns those four blocks in that order with their cards and fields
## ADDED Requirements
### Requirement: Card Sections
A FEATURES, STEPS or TRUST block SHALL have 2 to 6 cards, with titles of at most 80 characters and texts of at most 300. FEATURES SHALL have a heading, an optional intro and cards with an icon from the fixed list, a title and a text. STEPS SHALL have a heading and numbered cards with a title and a text. TRUST SHALL have only card titles. A save breaking these rules, or using a card field its type lacks, SHALL be refused on that field.
#### Scenario: Feature cards show their icons
- **GIVEN** a published page with a FEATURES block of three cards with icons `wifi`, `tv` and `lock`
- **WHEN** a visitor opens it
- **THEN** the page shows the heading and three cards, each with its icon, title and text
#### Scenario: Unknown icon
- **WHEN** a page is saved with a FEATURES card whose icon is `rocket-launcher`
- **THEN** the save is refused on field `blocks[0].cards[0].icon`
#### Scenario: Too few cards
- **WHEN** a page is saved with a STEPS block of one card
- **THEN** the save is refused on field `blocks[0].cards`
#### Scenario: Steps are numbered
- **GIVEN** a published page with a STEPS block of three steps
- **WHEN** a visitor opens it
- **THEN** the steps show the numbers 1, 2 and 3 in order
### Requirement: Call-To-Action Band
A CTA block SHALL have a heading of at most 120 characters, an optional text of at most 300, and a button with both a label and a link following the button link rule. A save without the button SHALL be refused on the button field.
#### Scenario: A CTA needs its button
- **WHEN** a page is saved with a CTA block that has a heading and no button
- **THEN** the save is refused on field `blocks[0].buttonLabel`
### Requirement: Section Looks
Any block MAY carry a look: Default, Muted, Dark or Accent. Default, or no look, SHALL render as before. Muted, Dark and Accent SHALL render the block as a full-width band in that colour with text readable on it; Accent SHALL use the company's accent colour, or the default primary colour when the company has none. Any other look SHALL be refused on that block's look field.
#### Scenario: A dark band
- **GIVEN** a published page whose CTA block has the Dark look
- **WHEN** a visitor opens it
- **THEN** the CTA shows as a dark full-width band with light text
#### Scenario: Existing pages unchanged
- **GIVEN** a page saved before this change, whose blocks have no look
- **WHEN** a visitor opens it
- **THEN** it renders as it did before
#### Scenario: Unknown look
- **WHEN** a page is saved with a block whose look is `NEON`
- **THEN** the save is refused on field `blocks[0].look`
### Requirement: Hero Image Is Optional
A HERO block MAY have no image; it then shows its heading, text and button on its look's background. When it has an image, the image SHALL still belong to the page's company.
#### Scenario: Hero without an image
- **WHEN** a page is saved with a HERO block that has a heading and no image
- **THEN** the save succeeds
### Requirement: New Sections In The Editor
The page editor SHALL offer adding FEATURES, STEPS, TRUST and CTA blocks, editing their fields, adding, removing and reordering cards, and choosing any block's look. Refusals SHALL show at the field they name, including card fields.
#### Scenario: A refused card title shows at its field
- **GIVEN** staff editing a page with a FEATURES block
- **WHEN** the save is refused on field `blocks[0].cards[1].title`
- **THEN** the message shows under the second card's title field
@@ -0,0 +1,19 @@
# Tasks: add-page-sections
Design: `design.md` and `docs/superpowers/specs/2026-12-03-page-builder-design.md` (change 1). Every task is TDD. Work is serial in the main session, with a self-review per task.
## 1. services-counter
- [ ] 1.1 `CmsBlock.look` and `cards` (`CmsCard` record: icon, title, text); `CmsBlockValidator`: FEATURES, STEPS, TRUST, CTA rules, the icon list, the look values, HERO image optional.
- Verify: `mvn -T 1C -B -pl solvway-services-counter -am verify`
## 2. Portal
- [ ] 2.1 Model and renderer: types, `emptyBlock`, `BLOCK_LABELS`, icon map; `CmsBlocks` renders the four new types and the looks (full-width bands, readable text, Accent from the company colour); Default unchanged.
- [ ] 2.2 Editor: add buttons, fields and card lists (add, remove, move) for the new types, the look select on every block, inline card errors; labels in `defaultMessages.ts` and `zh_CN.seed.json`, `npm run i18n:sql`, `sql/01-section-labels.sql` and `sql/99-rollback.sql`.
- Verify (2.1 to 2.2): `cd solvway-admin-portal && npx vitest run; echo VITEST=$? && npx tsc --noEmit && npm run lint`
## 3. Release
- [ ] 3.1 `docs/deployment.md`: SQL row; landing-pages notes (new sections, looks, rebuilding the INS page as sections).
- [ ] 3.2 Live check (Playwright) on a local portal: build a disposable page with every new type and each look; refusals (unknown look is API-only, so check a too-few-cards and a missing CTA button); preview and public page at 1280 and 360 px.