docs: archive add-landing-thanks-and-footer

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-04 11:45:49 +08:00
1 parent 35e9b796f7
commit 92412cb300
7 files changed
+63

No files matched your search

@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-04
@@ -0,0 +1,30 @@
# Design
## Context
Landing blocks are JSON validated by `CmsBlockValidator` and rendered by `CmsBlocks.tsx`. Card blocks (FEATURES, STEPS, TRUST, HERO points) share `cards` and the editor's card list in `BlockFields.tsx`. Text is edited in place with `Text`, which renders plain text outside the editor. The landing form's done state is `VisitorState` with the `RegThanks` heading.
## Approaches
1. **A FOOTER block built on `cards` (chosen).** Columns are cards with a title and text, the legal line is the block's `text`. The DTO gains nothing for the footer, and the editor reuses the card list. Staff get a footer that looks right without formatting.
2. **Columns and link colours on the Rich Text block.** This keeps one block type, but staff would have to build columns and links by hand, and every rich text block would gain layout options.
3. **Keep the footer in Custom HTML.** This is what the original page does; the native page exists to avoid it.
For the thank-you text, a field on the form-bearing blocks is the only sensible way: the message belongs to the page, not to the event, because one event can have several pages.
## Decisions
- **Links are found, not typed.** One helper splits plain text into text and links:
- `+` followed by digits, spaces and dashes (at least 8 digits) becomes `tel:` with only `+` and digits;
- an email address becomes `mailto:`;
- `https://…` and `www.…` become `https://` links that open in a new tab with `rel="noopener noreferrer"`.
It builds React elements, never HTML, so text stays text. `Text` gains a `links` flag that uses it outside the editor; in the editor the text stays editable as now.
- **Footer validation.** 1 to 4 cards, each with a required title (80) and required text (300), no icon. `text` at most 300. No heading.
- **Footer look.** `emptyBlock("FOOTER")` sets `look: "DARK"`. Links use the existing link colour (`text-primary`), which is the company's accent colour, so INS's footer links are gold.
- **Thank-you text.** `thanksText` (200) on FORM, and on HERO only with an event, like `formHeading`. `LandingForm` takes it as `thanks` and passes it to `VisitorState`'s text, through the link helper. Choosing "No form" on a hero, or changing company, clears it along with the event.
- **Shade.** The design-token test refuses raw colours, so the shade stays black-based: `from-black/55 to-black/10 to-70%` from the `md` width, and an even `black/60` below it. White text keeps contrast because the text sits on the darker left.
## Risks
- **Phone detection.** Only numbers written with `+` become links. A local number like "03-7623 9807" stays plain text. This is deliberate, to avoid linking dates or prices.
- **Lighter shade over a bright photo.** The headline could lose contrast. The hero heading is large and bold, and INS uses the same shade; staff can pick a darker photo.
@@ -0,0 +1,48 @@
# Proposal
## Why
The INS Hotel technology page is being rebuilt in Co-Lite without Custom HTML, to match INS's standalone page (`~/Projects/ins-landing-page`). After add-compact-landing-form, the content matches, but three things still differ, and marketing staff cannot fix them from the editor:
- After signing up, INS shows "Thanks! Our team will contact you shortly. Prefer to talk now? Call +60 12-833 2775", with the number as a tap-to-call link. Our landing form shows the same generic thank-you on every page.
- INS's footer has up to three columns (company and address, "Talk to us" with phone and email, website). The phone, email and web address are gold links, and the © line sits under a thin divider. Ours is one stacked column of plain rich text.
- INS's hero shade is lighter, so more of the photo shows. Ours is near-black on the text side.
## What Changes
- **Thank-you text.** The FORM block and a HERO with an event MAY carry `thanksText` (at most 200 characters). After a visitor signs up, it shows under the "Thank you" heading. Phone numbers that start with `+`, email addresses, and `https://` or `www.` web addresses in it become links. Without it, the thank-you stays as it is now. The server refuses it on a HERO without an event.
- **Footer block.** A new block type, FOOTER:
- 1 to 4 columns, each a bold title (80 characters) and text (300 characters, line breaks kept);
- an optional legal line (`text`, 300 characters) under a thin divider;
- phone numbers, emails and web addresses in the column text become links in the link colour;
- a new footer starts with the dark look; staff may change the look as on any block.
- **Lighter full-width hero shade.** The full-width hero's shade runs from about half dark on the text side to almost clear at 70% of the width, like INS. On phones, where the text sits over the whole photo, the shade is an even dark layer.
- New editor labels in English and Chinese, with an SQL label file for real environments.
Not changing:
- QR and invitation sign-up thank-you screens.
- The Rich Text block. Existing footers built with it keep working.
- Heroes that are not full width.
## Capabilities
### New Capabilities
None.
### Modified Capabilities
- `landing-pages`: adds "Thank-You Text On Landing Forms" and "Footer Block".
## Impact
- services-counter: `CmsBlock` gains `thanksText`. `CmsBlockValidator` checks `thanksText` on FORM and HERO and validates the FOOTER type.
- mobile-api: none. Public blocks pass through as maps.
- Portal:
- `cmsPages.ts`: the FOOTER type, its empty block and label;
- a small link-finding helper used by the footer and the thank-you text;
- `CmsBlocks.tsx` renders the footer, passes the thank-you text and lightens the shade;
- `LandingForm.tsx` shows the thank-you text;
- `BlockFields.tsx` gets the footer's columns and legal line, and the thank-you field on FORM and HERO;
- labels in `defaultMessages.ts` and `zh_CN.seed.json`.
- Data: no schema change, because the blocks are JSON. The new labels need a SQL label file in this change folder.
@@ -0,0 +1,64 @@
## ADDED Requirements
### Requirement: Thank-You Text On Landing Forms
A FORM block, and a HERO block with an event, MAY carry a thank-you text of at most 200 characters. After a visitor signs up through that block's form, the page SHALL show the text, with contact links, under the thank-you heading. Without it, the thank-you SHALL look as before. The server SHALL refuse an over-long thank-you text, or one on a HERO without an event.
#### Scenario: Visitor sees the page's thank-you text with a call link
- **GIVEN** page `/p/INS/hotel-technology-native` whose hero form has the thank-you text "Prefer to talk now? Call +60 12-833 2775."
- **WHEN** a visitor signs up through the hero form
- **THEN** the page shows the thank-you heading and "Prefer to talk now? Call +60 12-833 2775."
- **AND** "+60 12-833 2775" is a link to `tel:+60128332775`
#### Scenario: No thank-you text keeps today's message
- **WHEN** a visitor signs up through a FORM block without a thank-you text
- **THEN** the page shows only the thank-you heading and the "register another" button, as before
#### Scenario: Thank-you text on a hero without a form is refused
- **WHEN** staff save a HERO block without an event but with a thank-you text
- **THEN** the save is refused with the reason naming the hero's thank-you field
#### Scenario: Set the thank-you text in the editor
- **GIVEN** staff editing a hero that has an event
- **WHEN** they type a thank-you text in the hero's settings and save
- **THEN** the page keeps the text
- **AND** choosing "No form" on the hero clears it
### Requirement: Footer Block
A page MAY hold FOOTER blocks: 1 to 4 columns, each a required title (80 characters) and text (300 characters), and an optional legal line (300 characters). The page SHALL show the columns side by side on wide screens and stacked on phones, keep line breaks, show contact links in the column text, and put the legal line under a thin divider. A new footer SHALL start with the dark look. The server SHALL refuse a footer that breaks these limits, or that has a heading or a column icon.
#### Scenario: Visitor sees a three-column footer with links
- **GIVEN** a published page whose footer has the columns "Infinity Networks Security Sdn Bhd", "Talk to us" with "+603-7623 9807" and "info@infinitynetworks.com.my", and "Website" with "www.infinitynetworks.com.my", and a legal line
- **WHEN** a visitor opens the page in a 1280 px window
- **THEN** the three columns sit side by side on a dark band
- **AND** the phone links to `tel:+60376239807`, the email to `mailto:info@infinitynetworks.com.my`, and the website to `https://www.infinitynetworks.com.my`
- **AND** the legal line sits under a divider
#### Scenario: Add a footer in the editor
- **GIVEN** staff editing a page
- **WHEN** they add a Footer section
- **THEN** the canvas shows a dark footer with two empty columns to type into
- **AND** they can add columns up to 4 and type the legal line
#### Scenario: Footer with five columns is refused
- **WHEN** a page is saved with a footer of 5 columns
- **THEN** the save is refused with the reason naming the footer's columns
### Requirement: Contact Links In Plain Text
Where this spec says text shows contact links, the page SHALL show phone numbers that start with `+` as `tel:` links holding only `+` and digits, email addresses as `mailto:` links, and `https://` or `www.` addresses as `https://` links that open in a new tab. Everything else SHALL stay plain text, never HTML.
#### Scenario: Text with markup stays text
- **GIVEN** a footer column text "<b>Call</b> +60 12-833 2775"
- **WHEN** a visitor opens the page
- **THEN** "<b>Call</b>" shows as written
- **AND** "+60 12-833 2775" links to `tel:+60128332775`
@@ -0,0 +1,13 @@
-- The labels added by add-landing-thanks-and-footer, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
SET NAMES utf8mb4;
USE `service-system`;
INSERT INTO message (code, content, area) SELECT 'PagesThanksText', JSON_OBJECT('en_US', 'Thank-you text', 'zh_CN', '感谢语'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感谢语') WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesBlockFooter', JSON_OBJECT('en_US', 'Footer', 'zh_CN', '页脚'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页脚') WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesColumnN', JSON_OBJECT('en_US', 'Column {number}', 'zh_CN', '第 {number} 栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '第 {number} 栏') WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesAddColumn', JSON_OBJECT('en_US', 'Add column', 'zh_CN', '添加栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加栏') WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A';
INSERT INTO message (code, content, area) SELECT 'PagesFooterLegal', JSON_OBJECT('en_US', 'Legal line', 'zh_CN', '版权声明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A');
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '版权声明') WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A';
@@ -0,0 +1,52 @@
# Tasks
## 1. Server
- [x] 1.1 services-counter `CmsBlock`: add `thanksText`. `CmsBlockValidator`:
- `thanksText` at most 200 on FORM and HERO; refused on a HERO without `eventUuid` and on every other type (`PagesUnusedField`);
- FOOTER: no heading; 1 to 4 cards, each with a required title (80) and required text (300) and no icon; `text` at most 300.
Verify: new validator tests fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
## 2. Portal
- [x] 2.1 Link helper and rendering:
- a helper that turns plain text into text and links (`+` phone numbers, emails, `https://` and `www.` addresses), building elements, never HTML;
- `Text` gains `links`;
- `CmsBlocks.tsx` renders FOOTER (columns, line breaks, legal line under a divider), passes `thanksText` to `LandingForm`, and lightens the full-width hero shade;
- `LandingForm.tsx` shows the thank-you text under the heading.
Verify: render tests fail first, then pass; vitest exit 0.
- [x] 2.2 Editor:
- `cmsPages.ts`: FOOTER type, label and empty block (dark look, two columns);
- `BlockFields.tsx`: the footer's columns (1 to 4) and legal line; the thank-you field on FORM, and on HERO when an event is picked; "No form" and company change clear it;
- labels in `defaultMessages.ts`, `zh_CN.seed.json`, `sql/01-thanks-footer-labels.sql`; regenerate `local/seed/04-zh-cn-messages.sql`.
Verify: editor tests fail first, then pass; tsc and lint clean.
## 3. Verification
- [x] 3.1 Rebuild services-counter. Use Playwright on port 3001 to edit `/p/INS/hotel-technology-native` through the editor:
- set the hero's thank-you text to "Prefer to talk now? Call +60 12-833 2775.";
- replace the rich text footer with a Footer section matching INS;
- publish.
Check the published page at 1280 px and 390 px. The thank-you screen needs a real sign-up, which writes a record: check it in the editor preview path only if it does not save, otherwise ask the owner first.
- [x] 3.2 Run the full portal vitest (exit 0), tsc, lint, Maven verify for services-counter, and `openspec validate add-landing-thanks-and-footer --strict`.
- [x] 3.3 Add a release note to `docs/deployment.md` (label SQL).
## Notes (2026-12-04)
- **Red first:**
- the validator tests failed on the thank-you text and the footer;
- the render tests failed on the thank-you text, the footer and the link helper (missing module);
- the editor tests failed on the Footer section, the hero's thank-you field and the company switch.
- **Changed existing tests:** none. Two of my own new editor tests were fixed before going green: column names shift after a removal, and the Form block has its own thank-you field, so the hero checks are scoped to block 1.
- **Design-token checks:** the phone shade uses an even black gradient (`bg-black/60` is refused), and the divider uses `border-muted-foreground/30` (`border-current/15` is not in Tailwind 3).
- **Live check** (port 3001, rebuilt counter), on `/p/INS/hotel-technology-native` through the editor:
- typed the hero's thank-you text "Prefer to talk now? Call +60 12-833 2775.";
- added a Footer section with three columns and the legal line, and removed the old Text footer;
- saved and published.
- **Published result:** at 1280 px the three columns sit side by side on the dark band with gold tel, mailto and https links, and the legal line sits under a divider; at 390 px they stack. The hero shade is lighter.
- **Not run live:** the thank-you screen itself, because it needs a real sign-up, which writes a record. The render tests cover it (thank-you text and the tel link after a mocked sign-up).
- **Not reachable in the UI, covered by the validator tests:** 5 footer columns (Add column stops at 4), and a thank-you text on a hero without a form (No form clears it).