@usgb/forms 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Shared lead and newsletter forms for the **PWA** (React) and **WordPress** (Web Component) hosts.
4
4
 
5
- You pick a predefined `formId`. The package owns fields, validation, consent copy, tracking keys, and layout. You own the submit endpoint, legal-document URLs, heading/CTA copy, and thank-you behavior.
5
+ You pick a predefined `formId`. The package owns fields, validation, consent copy, tracking keys, and layout. You own the submit endpoint, legal-document URLs, heading/subheading/CTA copy, and thank-you behavior.
6
6
 
7
7
  ## What you get
8
8
 
@@ -22,7 +22,7 @@ The Web Component script injects the same CSS once on load. React hosts must imp
22
22
  | `formId` | Fields, required/optional rules, consent bundle, tracking set, layout family (`kind`) |
23
23
  | `adapter.submit` | Where the payload goes (never an attribute or hardcoded URL) |
24
24
  | `legalUrls` / `*-url` | Hrefs for package-owned consent copy |
25
- | `heading`, `body`, `ctaLabel` | Marketing copy around the form |
25
+ | `heading`, `subheading`, `ctaLabel` | Marketing copy around the form |
26
26
  | `successMessage` or `successUrl` | Thank-you UX after accept |
27
27
 
28
28
  Hosts **must not** invent field lists, consent wording, or tracking keys. New forms are new catalog entries in this package, not host-built schemas.
@@ -36,7 +36,7 @@ Use `listFormDefinitions()` (or the manifest) when a CMS needs a picker of avail
36
36
  | `main-investors-kit` | `lead` | First name, last name, email (required); phone (optional) | TCPA checkbox (`lead-tcpa` v1) | `dense`, `large`, `sidebar`, plus optional `two-column` |
37
37
  | `newsletter` | `newsletter` | Email only | None | None — omit `variants` / `variant` |
38
38
 
39
- Appearances for both: `light` | `navy`.
39
+ Appearances for both: `on-light` | `on-dark`. Appearance only recolors the form for readability on a light or dark host background — it never sets a background, padding, or radius. The host container owns those.
40
40
 
41
41
  `kind` is the layout family (lead grid vs inline newsletter row). The root exposes `data-kind` for CSS. Several catalog forms can share one kind (e.g. another lead kit that reuses the lead layout).
42
42
 
@@ -80,10 +80,10 @@ import { UsgbForm, createStubAdapter, PWA_LEGAL_URLS } from '@usgb/forms'
80
80
  import '@usgb/forms/usgb-forms.css'
81
81
  ;<UsgbForm
82
82
  formId="main-investors-kit"
83
- appearance="navy"
83
+ appearance="on-dark"
84
84
  variants={['large', 'two-column']}
85
85
  heading="Get My Free Guide"
86
- body="Enter your details to receive the Main Investors Kit."
86
+ subheading="Enter your details to receive the Main Investors Kit."
87
87
  ctaLabel="GET MY FREE GUIDE"
88
88
  source="cms-home"
89
89
  campaign="spring-kit"
@@ -104,7 +104,7 @@ Newsletter (no consent, no variants):
104
104
  ```tsx
105
105
  <UsgbForm
106
106
  formId="newsletter"
107
- appearance="light"
107
+ appearance="on-light"
108
108
  heading="Subscribe"
109
109
  ctaLabel="SUBSCRIBE"
110
110
  adapter={yourHostAdapter}
@@ -117,10 +117,10 @@ Newsletter (no consent, no variants):
117
117
  | ------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------- |
118
118
  | `formId` | yes | Catalog key (`main-investors-kit`, `newsletter`, …) |
119
119
  | `adapter` | yes | `HostAdapter` with `host`, `getTrackingHints()`, `submit()` |
120
- | `appearance` | no | `light` (default) or `navy` |
120
+ | `appearance` | no | `on-light` (default) or `on-dark` |
121
121
  | `variants` | no | Lead only. Default `['dense']`. One of `dense` \| `large` \| `sidebar`, optionally add `two-column` |
122
- | `heading` / `body` | no | Title and supporting copy |
123
- | `ctaLabel` | no | Submit button label |
122
+ | `heading` / `subheading` | no | Title and supporting copy |
123
+ | `ctaLabel` | no | Submit button label. Falls back to the catalog `ctaLabel` for that `formId` |
124
124
  | `source` / `campaign` | no | Placement / campaign context in the payload |
125
125
  | `legalUrls` | when consent requires them | Host CMS paths for legal links in consent copy |
126
126
  | `successMessage` | no | Inline thank-you when `successUrl` is omitted |
@@ -138,9 +138,10 @@ Load one script. Styles are injected automatically.
138
138
  <usgb-form
139
139
  ```
140
140
  form-id="main-investors-kit"
141
- appearance="navy"
141
+ appearance="on-dark"
142
142
  variant="large two-column"
143
143
  heading="Get My Free Guide"
144
+ subheading="Enter your details to receive the Main Investors Kit."
144
145
  cta="GET MY FREE GUIDE"
145
146
  source="cms-home"
146
147
  client-agreement-url="/client-agreement/"
@@ -187,7 +188,7 @@ Submit is **not** an attribute. Markup alone uses a stub adapter. Assign a real
187
188
  | `form-id` | `formId` |
188
189
  | `appearance` | `appearance` |
189
190
  | `variant` | `variants` (space-separated) |
190
- | `heading` / `body` | `heading` / `body` |
191
+ | `heading` / `subheading` | `heading` / `subheading` |
191
192
  | `cta` | `ctaLabel` |
192
193
  | `source` / `campaign` | `source` / `campaign` |
193
194
  | `success-message` / `success-url` | `successMessage` / `successUrl` |
@@ -240,10 +241,10 @@ This package does **not** wait on a returned Promise, add a flush timeout, or ca
240
241
 
241
242
  What is reliable today:
242
243
 
243
- - Inline thank-you (`successMessage` only) — no navigation, so tags usually complete.
244
- - Same-document hash redirects (`#thank-you`) — no unload.
245
- - Host `analytics` that uses `navigator.sendBeacon` or `fetch(..., { keepalive: true })`.
246
- - Conversion measured on the thank-you page itself, not on this `success` event.
244
+ - Inline thank-you (`successMessage` only) — no navigation, so tags usually complete.
245
+ - Same-document hash redirects (`#thank-you`) — no unload.
246
+ - Host `analytics` that uses `navigator.sendBeacon` or `fetch(..., { keepalive: true })`.
247
+ - Conversion measured on the thank-you page itself, not on this `success` event.
247
248
 
248
249
  `submit_attempt` is safer than `success` because it fires before `adapter.submit` and has the round-trip to flush. Prefer the thank-you page (or a beacon) when `successUrl` is a full navigation.
249
250
 
@@ -264,16 +265,24 @@ Prefer **custom properties** on `.usgb-form` for color, type, and spacing:
264
265
  --usgb-field-border: #cccccc;
265
266
  }
266
267
 
267
- .usgb-form[data-appearance='navy'] {
268
+ .usgb-form[data-appearance='on-dark'] {
268
269
  --usgb-button-background: #f4e08e;
269
270
  }
270
271
  ```
271
272
 
272
273
  Use class selectors when a token does not exist (`.usgb-form .usgb-btn { border-radius: 0; }`).
273
274
 
274
- Stable hooks: `.usgb-form` (`data-appearance`, `data-variant`, `data-kind`), `.usgb-form-heading`, `.usgb-form-body`, `.usgb-form-grid`, `.usgb-form-inline`, `.usgb-field-control`, `.usgb-field-error`, `.usgb-consent-*`, `.usgb-btn`, `.usgb-form-status-*`.
275
+ Stable hooks: `.usgb-form` (`data-appearance`, `data-variant`, `data-kind`), `.usgb-form-heading`, `.usgb-form-subheading`, `.usgb-form-grid`, `.usgb-form-inline`, `.usgb-field-control`, `.usgb-field-error`, `.usgb-consent-*`, `.usgb-btn`, `.usgb-form-status-*`.
275
276
 
276
- Semantic tokens (`--usgb-form-surface`, `--usgb-field-*`, `--usgb-button-*`, `--usgb-newsletter-underline`, …) are the first place to retheme. Palette vars (`--usgb-blue-1`, …) are a PWA snapshot. Error and checkbox glyphs are inline SVGs that use `currentColor` — override `--usgb-alert-danger` or `--usgb-checkbox-mark` to recolor them.
277
+ Semantic tokens (`--usgb-field-*`, `--usgb-button-*`, `--usgb-newsletter-underline`, …) are the first place to retheme. Palette vars (`--usgb-blue-1`, …) are a PWA snapshot. Error and checkbox glyphs are inline SVGs that use `currentColor` — override `--usgb-alert-danger` or `--usgb-checkbox-mark` to recolor them.
278
+
279
+ Appearance never paints a card. Put the form on a dark host surface and pass `appearance="on-dark"` (or `on-light` on a light surface):
280
+
281
+ ```html
282
+ <div style="background: #001f3d; padding: 2rem; border-radius: 0.75rem">
283
+ <usgb-form form-id="main-investors-kit" appearance="on-dark" …></usgb-form>
284
+ </div>
285
+ ```
277
286
 
278
287
  Visual styles are a ported snapshot of the PWA form kit. When PWA form styles change, update this package and bump the version.
279
288
 
@@ -186,6 +186,7 @@
186
186
  "user_agent",
187
187
  "ip_address"
188
188
  ],
189
+ "ctaLabel": "GET MY FREE GUIDE",
189
190
  "consent": {
190
191
  "definitionId": "lead-tcpa",
191
192
  "definitionVersion": "1",
@@ -200,7 +201,7 @@
200
201
  "description": "Standard lead form: name, email, phone, TCPA consent. Use on full-width landing pages and PWA kit/sidebar placements.",
201
202
  "whenToUse": "Default kit request. Do not use for affiliate landers or IRA-specific leads.",
202
203
  "whenNotToUse": "Affiliate pages (separate definition). IRA kit (separate definition when added).",
203
- "supportedAppearances": ["light", "navy"],
204
+ "supportedAppearances": ["on-light", "on-dark"],
204
205
  "supportedVariants": ["dense", "large", "sidebar", "two-column"]
205
206
  }
206
207
  },
@@ -220,12 +221,13 @@
220
221
  "utm_term",
221
222
  "utm_content"
222
223
  ],
224
+ "ctaLabel": "SUBSCRIBE",
223
225
  "editor": {
224
226
  "label": "Newsletter",
225
227
  "description": "Email-only newsletter signup. No TCPA consent.",
226
228
  "whenToUse": "Footer or landing newsletter capture where only an email is required.",
227
229
  "whenNotToUse": "Lead kits that need name, phone, or TCPA consent.",
228
- "supportedAppearances": ["light", "navy"],
230
+ "supportedAppearances": ["on-light", "on-dark"],
229
231
  "supportedVariants": []
230
232
  }
231
233
  }