From 48896d1958a0a71967c33d7d679ccceafa4da7c9 Mon Sep 17 00:00:00 2001 From: ngqile Date: Thu, 3 Dec 2026 19:45:34 +0800 Subject: [PATCH] fix(pages): top-align the hero text beside a long form and clear the editor's image button Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs --- .../changes/add-hero-signup-form/tasks.md | 31 +++++++++++++++---- .../app/components/pages/CmsBlocks.tsx | 3 +- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/openspec/changes/add-hero-signup-form/tasks.md b/openspec/changes/add-hero-signup-form/tasks.md index 762fe2f..fc69956 100644 --- a/openspec/changes/add-hero-signup-form/tasks.md +++ b/openspec/changes/add-hero-signup-form/tasks.md @@ -2,18 +2,37 @@ ## 1. Server -- [ ] 1.1 services-counter `CmsBlockValidator`: a HERO's optional `eventUuid` must be an event of the page's company, refused at `blocks[n].eventUuid` with `PagesBadEvent`. Verify: new validator tests (own event saves, other company's event refused, no event saves) fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`. -- [ ] 1.2 mobile-api `PublicPageService`: `page()` attaches `form`/`closed` to every block with an event that is FORM or HERO; `submit()` accepts a HERO with an event and refuses a HERO without one as not found. Verify: new service tests fail first, then pass; `mvn -T 1C -pl solvway-mobile-api verify`. +- [x] 1.1 services-counter `CmsBlockValidator`: a HERO's optional `eventUuid` must be an event of the page's company, refused at `blocks[n].eventUuid` with `PagesBadEvent`. Verify: new validator tests (own event saves, other company's event refused, no event saves) fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`. +- [x] 1.2 mobile-api `PublicPageService`: `page()` attaches `form`/`closed` to every block with an event that is FORM or HERO; `submit()` accepts a HERO with an event and refuses a HERO without one as not found. Verify: new service tests fail first, then pass; `mvn -T 1C -pl solvway-mobile-api verify`. ## 2. Portal -- [ ] 2.1 `CmsBlocks.tsx` HERO: with `form` or `closed`, two columns from `md` (text left, form card right; stacked on phones), image and shade kept; the card is `LandingForm` with the hero's block index. Verify: render tests for with/without event, closed, and the edit canvas; vitest exit 0. -- [ ] 2.2 `BlockFields.tsx`: the Hero gets the event picker ("No form" default, same hint and unavailable-event option as FORM; `eventUuid` shown inline); `usePageDraft` clears a HERO's event on company switch like a FORM's; labels `PagesHeroForm` and `PagesNoForm` in `defaultMessages.ts`, `zh_CN.seed.json` and an SQL label file in this change folder. Verify: editor tests fail first, then pass; tsc and lint clean. +- [x] 2.1 `CmsBlocks.tsx` HERO: with `form` or `closed`, two columns from `md` (text left, form card right; stacked on phones), image and shade kept; the card is `LandingForm` with the hero's block index. Verify: render tests for with/without event, closed, and the edit canvas; vitest exit 0. +- [x] 2.2 `BlockFields.tsx`: the Hero gets the event picker ("No form" default, same hint and unavailable-event option as FORM; `eventUuid` shown inline); `usePageDraft` clears a HERO's event on company switch like a FORM's; labels `PagesHeroForm` and `PagesNoForm` in `defaultMessages.ts`, `zh_CN.seed.json` and an SQL label file in this change folder. Verify: editor tests fail first, then pass; tsc and lint clean. ## 3. Verification -- [ ] 3.1 Rebuild services-counter and mobile-api locally; Playwright on port 3001: give a page's hero an event, see the card beside the text at 1280 px and below it at 390 px, submit as a visitor on the published page and see the lead under Event leads with source Web page; pick another company's event is impossible in the picker, and an ended event shows "closed". Use a disposable test page and the existing "LP Enquiries" test event; delete the test page after. -- [ ] 3.2 Full portal vitest (exit 0), tsc, lint, both Maven modules, `openspec validate add-hero-signup-form --strict`. +- [x] 3.1 Rebuild services-counter and mobile-api locally; Playwright on port 3001: give a page's hero an event, see the card beside the text at 1280 px and below it at 390 px, submit as a visitor on the published page and see the lead under Event leads with source Web page; pick another company's event is impossible in the picker, and an ended event shows "closed". Use a disposable test page and the existing "LP Enquiries" test event; delete the test page after. +- [x] 3.2 Full portal vitest (exit 0), tsc, lint, both Maven modules, `openspec validate add-hero-signup-form --strict`. + +## Notes (2026-12-03) + +- **Red first:** each new test failed before its code existed. The validator test failed on the foreign event; the service tests found no form on the hero; the render tests, the editor picker test and the company-switch test failed too. +- **Existing editor test:** one query was scoped to the FORM block's picker, because "Website enquiries" is now an option in two pickers. Its assertions are unchanged. +- **Live check** (port 3001, rebuilt counter and mobile-api), on the throwaway page "Live check hero form": + - the hero picker defaults to "No form"; + - the canvas shows the card beside the text; + - published at 1280 px, the form sits beside the text, and at 390 px below it; + - the visitor "Hero Check Visitor" registered from the hero and appears under INS website enquiries with "Web page: /p/INS/live-check-hero-form"; + - the page was deleted afterwards. The test lead stays in the local database. +- **Fixes from the live check:** + - the hero text is top-aligned, because a long form left it below the fold; + - the top padding is larger, so the editor's image button clears the heading; + - the shade is a gradient, because the design-token test refuses flat `bg-black/*`. +- **Not checked live:** + - the closed state, which the picker cannot reach because it offers no ended events (covered by the service and render tests); + - the other-company refusal, which the picker cannot reach either (covered by the validator test). +- **Results:** Maven verify passed for services-counter and mobile-api; vitest 1985 passed (exit 0); tsc clean; lint 0 errors. ## Workflow follow-up diff --git a/solvway-admin-portal/app/components/pages/CmsBlocks.tsx b/solvway-admin-portal/app/components/pages/CmsBlocks.tsx index cdaa0a0..3cb2056 100644 --- a/solvway-admin-portal/app/components/pages/CmsBlocks.tsx +++ b/solvway-admin-portal/app/components/pages/CmsBlocks.tsx @@ -56,7 +56,8 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl ); // add-hero-signup-form: with an event, the sign-up form sits in a card beside the text (below it on phones). if (block.eventUuid) { - const grid = "grid items-center gap-6 p-6 md:grid-cols-[minmax(0,1fr)_minmax(0,26rem)] md:p-10"; + // Top padding leaves room for the editor's image button in the corner. + const grid = "grid items-start gap-6 px-6 pt-16 pb-6 md:grid-cols-[minmax(0,1fr)_minmax(0,26rem)] md:px-10 md:pb-10"; return (