@dloizides/marketing-astro-kit 1.9.3 → 1.11.0

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/CHANGELOG.md CHANGED
@@ -1,138 +1,154 @@
1
- # Changelog
2
-
3
- ## 1.9.1
4
-
5
- ### Fixed
6
-
7
- - `MeetingRequestForm`: every input, select and textarea shows a 2px `:focus-visible` ring, colour `--tmk-mr-focus` (default `currentColor`; also feeds the day field's `--tmk-df-focus`). MOONCUBE-SITE-1 "Moon Cube Technologies site: read and book", D-SITE-36.
8
-
9
- ## 1.9.0
10
-
11
- ### Added
12
-
13
- - `<MeetingRequestForm />` (`./MeetingRequestForm.astro`) + `./meetingRequest` helpers: preferred day, time of day, name, email, company, message; validation (past day, bad email), JSON POST with timeout, sent / rate-limited (429) / failed states, mailto assembled in the browser, honeypot `website`, Send loading state, optional Umami event. Labels and endpoint are options; no subject is sent. MOONCUBE-SITE-1 "Moon Cube Technologies site: read and book", AC-07, AC-08, AC-18, AC-20, AC-21, AC-22.
14
- - `<DateField />` (`./DateField.astro`) + `./dateField` helpers: the shared date input for Astro sites (DATE-INPUT-1 "Every date or date-time field uses the shared input"): native picker, label, min/max, error with `aria-invalid` + `aria-describedby`, 44 px control, themed by `--tmk-df-*`. `MeetingRequestForm` uses it for the day. MOONCUBE-SITE-1, D-SITE-17.
15
-
16
- ### Changed
17
-
18
- - `MeetingRequestForm`: the message is required, at least 10 characters (matches the `/contact` server validator); new error kind `too-short` in `labels.errors`.
19
-
20
- ## 1.8.0
21
-
22
- ### Added
23
-
24
- - `<BookingEmbed />` (`./BookingEmbed.astro`) + `./bookingEmbed` helpers: Cal.com inline embed set by options, contact fallback after 8 s or a load error, address assembled in the browser. Unit tests (vitest), lint and typecheck scripts. MOONCUBE-SITE-1 "Moon Cube Technologies site: read and book", AC-18.
25
-
26
- ## 1.7.0
27
-
28
- ### Added
29
-
30
- - `<BottomSheet />` (`./BottomSheet.astro`): slot-based phone bottom sheet opened by `:target`, inline at 1024 px and up. Sits above `--dlz-consent-inset`. BEAD-ONE-2 "One-host follow-ups".
31
-
32
- ## 1.6.1
33
-
34
- ### Fixed
35
-
36
- - `HairlineFigure` mount: a failed lazy-chunk load or figure mount no longer becomes an unhandled rejection. The host gets `data-hairline-failed="true"` and the page logs one `console.warn`. HAIRLINE-1 "Adopt hairline isometric line figures".
37
- - README: a sub-path host (kefi-landings) needs `build.assetsPrefix` set to an ABSOLUTE origin serving `dist/_astro/`; a relative prefix fails silently.
38
-
39
- ## 1.6.0
40
-
41
- ### Added
42
-
43
- - `<HairlineFigure />` (`./HairlineFigure.astro`) plus `HAIRLINE_FIGURES`, `TOUCH_SAFE_HAIRLINE_FIGURES` and `clampHairlineIntensity` (`./hairline`). Wraps `@lucasmarkes/hairline` 0.3.0 (exact pin): SSR 5:4 box, lazy mount near the viewport, destroy on page swap, `--hairline-*` mapped from the theming contract. HAIRLINE-1 "Adopt hairline isometric line figures".
44
-
45
- ## 1.5.2
46
-
47
- ### Fixed
48
-
49
- - `.dmk-disclaimer` (DemoFrame) and `.pmk-footnote` (PricingComparison) cap their measure at 65ch; at 1280 px they ran 102-113 characters per line. Mobile is unaffected.
50
-
51
- ## 1.3.0
52
-
53
- ### Added
54
-
55
- - `<HeroBackdrop />` plus the named hero-backdrop preset catalog (`./heroBackdrop`).
56
- Nine animated hero treatments -- three canvas, one SVG-filter, five pure-CSS --
57
- that until now existed ONLY in a disposable per-session scratchpad and had been
58
- rebuilt from scratch more than once. `HERO_BACKDROP_PRESETS` is the permanent
59
- record: preset name -> `{ variant, engine, palette, css, ember }`, using the
60
- design studio's own parameter names verbatim so a studio export pastes in with
61
- no translation step.
62
- - `csdf-ember-sparse` -- CSDF's shipped configuration. 40 particles, an eighth of
63
- the studio default, which is what makes a canvas backdrop affordable against a
64
- hard Lighthouse >= 80 budget.
65
- - Only the ember canvas engine ships as a RENDERER. The CSS/SVG entries are
66
- recorded PARAMETER SETS painted by the host stylesheet; the component renders
67
- nothing for those, leaving the host's own backdrop untouched.
68
-
69
- ### Notes
70
-
71
- - The component's script is `is:inline` deliberately -- a bundled Astro script
72
- emits a root-absolute `/_astro/*.js` reference, which 404s under kefi-landings'
73
- host-based per-tenant nginx roots.
74
- - Respects `prefers-reduced-motion` (one still frame, no loop) and stops the rAF
75
- loop on `visibilitychange` and when the canvas leaves the viewport.
76
-
77
- ## 1.2.1
78
-
79
- - **a11y fix (serious): the pricing comparison was SILENT to screen readers.**
80
- `PricingComparison.astro` marked each cell with `aria-label` on a bare
81
- `<span>`. `aria-label` is *prohibited* on a roleless generic element, so
82
- assistive tech ignored it — and the inner `<svg>` is `aria-hidden`. Net
83
- effect: a screen-reader user reached every included/not-included cell and
84
- heard **nothing**, so they could not tell which plan carried which feature,
85
- on a public pricing page. Fixed by giving the span `role="img"` alongside
86
- the existing label. Found by the `a11y-public` E2E axe scan against the live
87
- kefi landing: `aria-prohibited-attr`, 27 nodes. Swept the rest of the kit —
88
- no other instances of this shape.
89
-
90
- ## 1.2.0
91
-
92
- - New `DemoFrame.astro` — a themeable, **client-side "try it" demo** shell for
93
- static marketing sites (no backend): an eyebrow/title/intro, a row of clickable
94
- example chips, a per-example result panel (bespoke product body injected via a
95
- named slot `result-<example.id>`), a clearly-visible "sample data" disclaimer,
96
- and a primary CTA (reuses `PrimaryCta`). Tiny inline vanilla JS toggles which
97
- result shows on chip click (+ arrow-key roving tablist); the first example is
98
- visible without JS (progressive enhancement). New `DemoExample` / `DemoFrameData`
99
- types in `schema.ts`.
100
- - New `GuideCard.astro` — a themeable card for a **guides / SEO content-hub**
101
- listing, rendering one guide's tags, title, description and date. New
102
- `GuideCardData` type.
103
- - New `guideFrontmatterSchema` (Zod, built on `astro/zod`) + `GuideFrontmatter`
104
- type in `schema.ts` — plug straight into an Astro content collection
105
- (`defineCollection({ loader: glob(...), schema: guideFrontmatterSchema })`) so
106
- every product's guides validate the same shape (title, description, slug?,
107
- publishDate, updatedDate?, tags, ogImage?, canonical?, draft?). The article
108
- page + routes + JSON-LD stay product-owned.
109
- - `schema.ts` now imports `z` from `astro/zod` (Astro is already a peer dep) —
110
- the ONE runtime import; every other export stays plain types.
111
-
112
- ## 1.1.0
113
-
114
- - New `PrimaryCta.astro` — a themeable primary call-to-action (link OR spam-safe
115
- contact) with an optional secondary CTA and a `tone: 'light' | 'dark'` for
116
- dark bands. Renders a `MarketingCta` so link-vs-lead-capture + analytics wiring
117
- is no longer hand-coded per page.
118
- - New `buildPrimaryCta(opts)` helper + `PrimaryCtaOptions` in `schema.ts`: drive
119
- a primary CTA from ONE `SIGNUP_URL` constant — a real signup link when set,
120
- spam-safe lead-capture when `null` (flip at GA with no template change).
121
- - `ctaAttrs()` promoted from `PricingComparison.astro` into `schema.ts` and now
122
- shared by every CTA-rendering component (no duplication).
123
- - `TrustSection` gains three optional, guarded fields (existing sites
124
- unaffected): `foundingPartner` ("first N free during beta" panel),
125
- `founder` (honest one-line credibility) and `sampleDeliverable` (a "here's the
126
- actual report you get" showcase — image, or a `slot="sample-deliverable"` for
127
- bespoke mock markup while the section chrome stays shared).
128
-
129
- ## 1.0.0
130
-
131
- - Initial release. `PricingComparison.astro` (Free-vs-Pro comparison table with
132
- tier columns, grouped feature rows, optional footnote + one-time callout card)
133
- and `TrustSection.astro` (security cards with inline icons, customer-logo row
134
- with placeholders, testimonial placeholders, discreet built-by line).
135
- - Framework-agnostic data schema (`schema.ts`) + inline icon set (`icons.ts`).
136
- - Themed via host CSS custom properties with fallbacks; no image assets.
137
- - Extracted from `kefi-marketing` as the 2nd genuine use of the pricing/trust
138
- sections across the Astro marketing sites.
1
+ # Changelog
2
+
3
+ ## 1.11.0
4
+
5
+ ### Added
6
+
7
+ - `./scrollFade`: `createScrollFade({ belowLevel, switchShare })` returns the scroll-linked opacity curve of a page-wide background (full over the hero, falling to `belowLevel`) and `isBelow`, true once less than `switchShare` of the hero is on screen; `heroProgress(scrollY, heroHeight)` gives that share (MOONCUBE-SITE-4 "Faded background continues below the hero").
8
+
9
+ ## 1.10.0
10
+
11
+ ### Added
12
+
13
+ - `./motionController`: `createMotionController(options)` runs a frame loop only while the page is visible and the target is in view, and holds a still under `prefers-reduced-motion` (MOONCUBE-SITE-3 "Stunning background, DevOps experience and ISO 27001 controls"). Its source is self-contained, so an `is:inline` script can carry it.
14
+
15
+ ### Changed
16
+
17
+ - `HeroBackdrop` uses `createMotionController`; behaviour unchanged.
18
+
19
+ ## 1.9.1
20
+
21
+ ### Fixed
22
+
23
+ - `MeetingRequestForm`: every input, select and textarea shows a 2px `:focus-visible` ring, colour `--tmk-mr-focus` (default `currentColor`; also feeds the day field's `--tmk-df-focus`). MOONCUBE-SITE-1 "Moon Cube Technologies site: read and book", D-SITE-36.
24
+
25
+ ## 1.9.0
26
+
27
+ ### Added
28
+
29
+ - `<MeetingRequestForm />` (`./MeetingRequestForm.astro`) + `./meetingRequest` helpers: preferred day, time of day, name, email, company, message; validation (past day, bad email), JSON POST with timeout, sent / rate-limited (429) / failed states, mailto assembled in the browser, honeypot `website`, Send loading state, optional Umami event. Labels and endpoint are options; no subject is sent. MOONCUBE-SITE-1 "Moon Cube Technologies site: read and book", AC-07, AC-08, AC-18, AC-20, AC-21, AC-22.
30
+ - `<DateField />` (`./DateField.astro`) + `./dateField` helpers: the shared date input for Astro sites (DATE-INPUT-1 "Every date or date-time field uses the shared input"): native picker, label, min/max, error with `aria-invalid` + `aria-describedby`, 44 px control, themed by `--tmk-df-*`. `MeetingRequestForm` uses it for the day. MOONCUBE-SITE-1, D-SITE-17.
31
+
32
+ ### Changed
33
+
34
+ - `MeetingRequestForm`: the message is required, at least 10 characters (matches the `/contact` server validator); new error kind `too-short` in `labels.errors`.
35
+
36
+ ## 1.8.0
37
+
38
+ ### Added
39
+
40
+ - `<BookingEmbed />` (`./BookingEmbed.astro`) + `./bookingEmbed` helpers: Cal.com inline embed set by options, contact fallback after 8 s or a load error, address assembled in the browser. Unit tests (vitest), lint and typecheck scripts. MOONCUBE-SITE-1 "Moon Cube Technologies site: read and book", AC-18.
41
+
42
+ ## 1.7.0
43
+
44
+ ### Added
45
+
46
+ - `<BottomSheet />` (`./BottomSheet.astro`): slot-based phone bottom sheet opened by `:target`, inline at 1024 px and up. Sits above `--dlz-consent-inset`. BEAD-ONE-2 "One-host follow-ups".
47
+
48
+ ## 1.6.1
49
+
50
+ ### Fixed
51
+
52
+ - `HairlineFigure` mount: a failed lazy-chunk load or figure mount no longer becomes an unhandled rejection. The host gets `data-hairline-failed="true"` and the page logs one `console.warn`. HAIRLINE-1 "Adopt hairline isometric line figures".
53
+ - README: a sub-path host (kefi-landings) needs `build.assetsPrefix` set to an ABSOLUTE origin serving `dist/_astro/`; a relative prefix fails silently.
54
+
55
+ ## 1.6.0
56
+
57
+ ### Added
58
+
59
+ - `<HairlineFigure />` (`./HairlineFigure.astro`) plus `HAIRLINE_FIGURES`, `TOUCH_SAFE_HAIRLINE_FIGURES` and `clampHairlineIntensity` (`./hairline`). Wraps `@lucasmarkes/hairline` 0.3.0 (exact pin): SSR 5:4 box, lazy mount near the viewport, destroy on page swap, `--hairline-*` mapped from the theming contract. HAIRLINE-1 "Adopt hairline isometric line figures".
60
+
61
+ ## 1.5.2
62
+
63
+ ### Fixed
64
+
65
+ - `.dmk-disclaimer` (DemoFrame) and `.pmk-footnote` (PricingComparison) cap their measure at 65ch; at 1280 px they ran 102-113 characters per line. Mobile is unaffected.
66
+
67
+ ## 1.3.0
68
+
69
+ ### Added
70
+
71
+ - `<HeroBackdrop />` plus the named hero-backdrop preset catalog (`./heroBackdrop`).
72
+ Nine animated hero treatments -- three canvas, one SVG-filter, five pure-CSS --
73
+ that until now existed ONLY in a disposable per-session scratchpad and had been
74
+ rebuilt from scratch more than once. `HERO_BACKDROP_PRESETS` is the permanent
75
+ record: preset name -> `{ variant, engine, palette, css, ember }`, using the
76
+ design studio's own parameter names verbatim so a studio export pastes in with
77
+ no translation step.
78
+ - `csdf-ember-sparse` -- CSDF's shipped configuration. 40 particles, an eighth of
79
+ the studio default, which is what makes a canvas backdrop affordable against a
80
+ hard Lighthouse >= 80 budget.
81
+ - Only the ember canvas engine ships as a RENDERER. The CSS/SVG entries are
82
+ recorded PARAMETER SETS painted by the host stylesheet; the component renders
83
+ nothing for those, leaving the host's own backdrop untouched.
84
+
85
+ ### Notes
86
+
87
+ - The component's script is `is:inline` deliberately -- a bundled Astro script
88
+ emits a root-absolute `/_astro/*.js` reference, which 404s under kefi-landings'
89
+ host-based per-tenant nginx roots.
90
+ - Respects `prefers-reduced-motion` (one still frame, no loop) and stops the rAF
91
+ loop on `visibilitychange` and when the canvas leaves the viewport.
92
+
93
+ ## 1.2.1
94
+
95
+ - **a11y fix (serious): the pricing comparison was SILENT to screen readers.**
96
+ `PricingComparison.astro` marked each cell with `aria-label` on a bare
97
+ `<span>`. `aria-label` is *prohibited* on a roleless generic element, so
98
+ assistive tech ignored it — and the inner `<svg>` is `aria-hidden`. Net
99
+ effect: a screen-reader user reached every included/not-included cell and
100
+ heard **nothing**, so they could not tell which plan carried which feature,
101
+ on a public pricing page. Fixed by giving the span `role="img"` alongside
102
+ the existing label. Found by the `a11y-public` E2E axe scan against the live
103
+ kefi landing: `aria-prohibited-attr`, 27 nodes. Swept the rest of the kit —
104
+ no other instances of this shape.
105
+
106
+ ## 1.2.0
107
+
108
+ - New `DemoFrame.astro` — a themeable, **client-side "try it" demo** shell for
109
+ static marketing sites (no backend): an eyebrow/title/intro, a row of clickable
110
+ example chips, a per-example result panel (bespoke product body injected via a
111
+ named slot `result-<example.id>`), a clearly-visible "sample data" disclaimer,
112
+ and a primary CTA (reuses `PrimaryCta`). Tiny inline vanilla JS toggles which
113
+ result shows on chip click (+ arrow-key roving tablist); the first example is
114
+ visible without JS (progressive enhancement). New `DemoExample` / `DemoFrameData`
115
+ types in `schema.ts`.
116
+ - New `GuideCard.astro` — a themeable card for a **guides / SEO content-hub**
117
+ listing, rendering one guide's tags, title, description and date. New
118
+ `GuideCardData` type.
119
+ - New `guideFrontmatterSchema` (Zod, built on `astro/zod`) + `GuideFrontmatter`
120
+ type in `schema.ts` — plug straight into an Astro content collection
121
+ (`defineCollection({ loader: glob(...), schema: guideFrontmatterSchema })`) so
122
+ every product's guides validate the same shape (title, description, slug?,
123
+ publishDate, updatedDate?, tags, ogImage?, canonical?, draft?). The article
124
+ page + routes + JSON-LD stay product-owned.
125
+ - `schema.ts` now imports `z` from `astro/zod` (Astro is already a peer dep) —
126
+ the ONE runtime import; every other export stays plain types.
127
+
128
+ ## 1.1.0
129
+
130
+ - New `PrimaryCta.astro` — a themeable primary call-to-action (link OR spam-safe
131
+ contact) with an optional secondary CTA and a `tone: 'light' | 'dark'` for
132
+ dark bands. Renders a `MarketingCta` so link-vs-lead-capture + analytics wiring
133
+ is no longer hand-coded per page.
134
+ - New `buildPrimaryCta(opts)` helper + `PrimaryCtaOptions` in `schema.ts`: drive
135
+ a primary CTA from ONE `SIGNUP_URL` constant — a real signup link when set,
136
+ spam-safe lead-capture when `null` (flip at GA with no template change).
137
+ - `ctaAttrs()` promoted from `PricingComparison.astro` into `schema.ts` and now
138
+ shared by every CTA-rendering component (no duplication).
139
+ - `TrustSection` gains three optional, guarded fields (existing sites
140
+ unaffected): `foundingPartner` ("first N free during beta" panel),
141
+ `founder` (honest one-line credibility) and `sampleDeliverable` (a "here's the
142
+ actual report you get" showcase — image, or a `slot="sample-deliverable"` for
143
+ bespoke mock markup while the section chrome stays shared).
144
+
145
+ ## 1.0.0
146
+
147
+ - Initial release. `PricingComparison.astro` (Free-vs-Pro comparison table with
148
+ tier columns, grouped feature rows, optional footnote + one-time callout card)
149
+ and `TrustSection.astro` (security cards with inline icons, customer-logo row
150
+ with placeholders, testimonial placeholders, discreet built-by line).
151
+ - Framework-agnostic data schema (`schema.ts`) + inline icon set (`icons.ts`).
152
+ - Themed via host CSS custom properties with fallbacks; no image assets.
153
+ - Extracted from `kefi-marketing` as the 2nd genuine use of the pricing/trust
154
+ sections across the Astro marketing sites.
package/README.md CHANGED
@@ -10,7 +10,7 @@ credibility + conversion markers an executive scans for before they trust a SaaS
10
10
  | `PrimaryCta.astro` | A themeable **primary call-to-action** (link OR spam-safe contact) with an optional secondary CTA. Pair with `buildPrimaryCta` so ONE `SIGNUP_URL` constant drives whether it's a real signup link or lead-capture. |
11
11
  | `DemoFrame.astro` | A themeable, **client-side "try it" demo** shell for static sites (no backend): eyebrow/title/intro, a row of clickable example chips, a per-example result panel (bespoke product body via a named `result-<id>` slot), a "sample data" disclaimer, and a primary CTA. Tiny inline vanilla JS toggles which result shows; first example visible without JS. |
12
12
  | `GuideCard.astro` | A themeable **card for a guides / SEO content-hub** listing — one guide's tags, title, description and date. Pair with `guideFrontmatterSchema` on an Astro content collection. |
13
- | `BookingEmbed.astro` | A **Cal.com inline booking embed** set by options (link, theme, brand colours), loaded on its page only, with a spam-safe contact fallback after a timeout or load error. |
13
+ | `BookingEmbed.astro` | A **Cal.com inline booking embed** set by options (link, theme, brand colours), loaded on its page only, with a spam-safe contact fallback after a timeout or load error. |
14
14
  | `HairlineFigure.astro` | A **Hairline isometric line figure** (`@lucasmarkes/hairline`, pinned 0.3.0) for heroes and empty states: an empty 5:4 box server-side, drawn on the client once it nears the viewport, coloured from the host's tokens. |
15
15
 
16
16
  ## Config-driven primary CTA (`PrimaryCta` + `buildPrimaryCta`)
@@ -186,29 +186,29 @@ import HairlineFigure from '@dloizides/marketing-astro-kit/HairlineFigure.astro'
186
186
  - **Script bundling:** unlike `HeroBackdrop`, this script is a bundled Astro `<script>` (it imports an npm module), so it emits a root-absolute `/_astro/*.js` URL. On a host that serves a tenant from a sub-directory (kefi-landings: the nginx root is the tenant sub-directory), set Astro's `build.assetsPrefix` to an ABSOLUTE origin (`https://cdn.example.com`) that serves this build's `dist/_astro/`, both the entry script and the lazy Hairline chunk. A relative prefix fails silently: the chunk 404s and the box stays empty, marked `data-hairline-failed` with one `console.warn`.
187
187
  - **Vite-alias consumers** (the kit aliased to source, not installed) must have `@lucasmarkes/hairline@0.3.0` resolvable from the site.
188
188
 
189
- ## Booking embed (`BookingEmbed`)
190
-
191
- ```astro
192
- ---
193
- import BookingEmbed from "@dloizides/marketing-astro-kit/BookingEmbed.astro";
194
- import { BookingTheme, CalLayout } from "@dloizides/marketing-astro-kit/bookingEmbed";
195
- ---
196
- <BookingEmbed
197
- id="book"
198
- label="Book a call"
199
- options={{ calLink: "mooncube/intro", theme: BookingTheme.Dark, layout: CalLayout.Month,
200
- hideEventTypeDetails: true, cssVarsPerTheme: { dark: { "cal-bg": "#0F1B2D", "cal-brand": "#E8C36A" } } }}
201
- contact={{ local: "hello", domain: "example.com" }}
202
- >
203
- <p slot="fallback">Calendar unavailable. Email <a data-booking-contact></a></p>
204
- </BookingEmbed>
205
- ```
206
-
207
- - Options: `calLink` (required, Cal.com path), `theme` (default dark), `layout` (default month view), `hideEventTypeDetails`, `cssVarsPerTheme` (`cal-*` names, hex only, checked at build), `timeoutMs` (default 8000), `namespace` (`^[\w-]+$`, default the host `id`), `origin` (https URL with no path, default `https://app.cal.com`; the embed script loads from `<origin>/embed/embed.js`).
208
- - The Cal.com script is added by the component script only when a host is on the page.
209
- - The fallback slot shows after `timeoutMs` with no `linkReady`, on `linkFailed`, or when the script fails, for hosts mounted by any later call too. Each `[data-booking-contact]` link gets its `mailto:` filled in the browser from `data-local` + `data-domain`; the served HTML holds no address.
210
- - `data-booking-state` on the host is `loading`, `ready` or `fallback`. Set `--tmk-booking-min-height` (default 640px).
211
-
189
+ ## Booking embed (`BookingEmbed`)
190
+
191
+ ```astro
192
+ ---
193
+ import BookingEmbed from "@dloizides/marketing-astro-kit/BookingEmbed.astro";
194
+ import { BookingTheme, CalLayout } from "@dloizides/marketing-astro-kit/bookingEmbed";
195
+ ---
196
+ <BookingEmbed
197
+ id="book"
198
+ label="Book a call"
199
+ options={{ calLink: "mooncube/intro", theme: BookingTheme.Dark, layout: CalLayout.Month,
200
+ hideEventTypeDetails: true, cssVarsPerTheme: { dark: { "cal-bg": "#0F1B2D", "cal-brand": "#E8C36A" } } }}
201
+ contact={{ local: "hello", domain: "example.com" }}
202
+ >
203
+ <p slot="fallback">Calendar unavailable. Email <a data-booking-contact></a></p>
204
+ </BookingEmbed>
205
+ ```
206
+
207
+ - Options: `calLink` (required, Cal.com path), `theme` (default dark), `layout` (default month view), `hideEventTypeDetails`, `cssVarsPerTheme` (`cal-*` names, hex only, checked at build), `timeoutMs` (default 8000), `namespace` (`^[\w-]+$`, default the host `id`), `origin` (https URL with no path, default `https://app.cal.com`; the embed script loads from `<origin>/embed/embed.js`).
208
+ - The Cal.com script is added by the component script only when a host is on the page.
209
+ - The fallback slot shows after `timeoutMs` with no `linkReady`, on `linkFailed`, or when the script fails, for hosts mounted by any later call too. Each `[data-booking-contact]` link gets its `mailto:` filled in the browser from `data-local` + `data-domain`; the served HTML holds no address.
210
+ - `data-booking-state` on the host is `loading`, `ready` or `fallback`. Set `--tmk-booking-min-height` (default 640px).
211
+
212
212
  ## Bottom sheet (`BottomSheet`)
213
213
 
214
214
  Below 1024 px the default slot opens as a bottom sheet when the URL hash equals `id`; link to `#id` to open it. From 1024 px the slot renders inline and the head and foot are hidden. The `foot` slot holds the sticky action. Set `--tmk-sheet-bg` and `--tmk-sheet-edge` to theme it (fallbacks `--paper`, `--ink`). It stays above a consent card through `--dlz-consent-inset`. The close link carries `data-sheet-close`.
@@ -298,3 +298,9 @@ For in-editor types, mirror the alias in `tsconfig.json`:
298
298
 
299
299
  The Astro build (Rollup) only needs the Vite alias — types are not required for
300
300
  `astro build` to succeed.
301
+
302
+ ## Motion controller
303
+
304
+ `@dloizides/marketing-astro-kit/motionController` exports `createMotionController(options): { getState, sync }`. It runs `onFrame(deltaMs)` only while the page is visible and `target` is in view, and calls `onStill()` under `prefers-reduced-motion`. `forceStill` and `canRun` add host conditions; call `sync()` when they change. `watchReducedMotion: false` reads the preference once. The function references no module scope, so `HeroBackdrop` carries its source in an `is:inline` script.
305
+
306
+ `@dloizides/marketing-astro-kit/scrollFade` exports `createScrollFade({ belowLevel, switchShare }): { opacity, isBelow }` and `heroProgress(scrollY, heroHeight)`. `heroProgress` is 1 at the top of the page and 0 once the hero has scrolled away; `opacity(progress)` runs from 1 down to `belowLevel`; `isBelow(progress)` is true once less than `switchShare` of the hero is on screen.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dloizides/marketing-astro-kit",
3
- "version": "1.9.3",
3
+ "version": "1.11.0",
4
4
  "description": "Reusable, themeable Astro marketing sections for product sites — a Free-vs-Pro pricing comparison table, a trust / credibility section (security cards, customer-logo + testimonial placeholders, discreet built-by), a client-side \"try it\" demo shell, a meeting request form posting to a contact endpoint, and an SEO guides/content-hub card + frontmatter schema. Data-driven via a shared TypeScript schema; themed entirely through the host site's CSS custom properties.",
5
5
  "keywords": [
6
6
  "astro",
@@ -60,11 +60,13 @@
60
60
  "./MeetingRequestForm.astro": "./src/MeetingRequestForm.astro",
61
61
  "./meetingRequest": "./src/meetingRequest/index.ts",
62
62
  "./DateField.astro": "./src/DateField.astro",
63
- "./dateField": "./src/dateField/index.ts"
63
+ "./dateField": "./src/dateField/index.ts",
64
+ "./motionController": "./src/motionController/index.ts",
65
+ "./scrollFade": "./src/scrollFade/index.ts"
64
66
  },
65
67
  "scripts": {
66
68
  "test": "vitest run",
67
- "lint": "eslint src/bookingEmbed src/dateField src/meetingRequest --ext .ts",
69
+ "lint": "eslint src/bookingEmbed src/dateField src/meetingRequest src/motionController src/scrollFade --ext .ts",
68
70
  "typecheck": "tsc --noEmit -p ."
69
71
  },
70
72
  "dependencies": {
@@ -30,6 +30,7 @@
30
30
  // "clean this up" into a module import without changing how tenants are served.
31
31
  // ============================================================================
32
32
  import type { HeroBackdropPreset } from './heroBackdrop/types';
33
+ import { createMotionController } from './motionController';
33
34
 
34
35
  interface Props {
35
36
  /** A catalog entry — see `@dloizides/marketing-astro-kit/heroBackdrop`. */
@@ -59,6 +60,7 @@ const { preset, class: className = '', mountSelector = '' } = Astro.props;
59
60
  // left exactly as it was.
60
61
  const isEmberCanvas = preset.engine === 'canvas' && preset.variant === 'ember';
61
62
  const cfg = isEmberCanvas ? { palette: preset.palette, ember: preset.ember } : null;
63
+ const motionControllerScript = `window.dlzCreateMotionController = ${createMotionController.toString()};`;
62
64
  ---
63
65
 
64
66
  {
@@ -71,6 +73,8 @@ const cfg = isEmberCanvas ? { palette: preset.palette, ember: preset.ember } : n
71
73
  )
72
74
  }
73
75
 
76
+ {isEmberCanvas && <script is:inline set:html={motionControllerScript} />}
77
+
74
78
  {
75
79
  isEmberCanvas && (
76
80
  <script is:inline define:vars={{ heroBackdropCfg: cfg, heroBackdropMount: mountSelector }}>
@@ -92,7 +96,6 @@ const cfg = isEmberCanvas ? { palette: preset.palette, ember: preset.ember } : n
92
96
 
93
97
  var EP = cfg.ember;
94
98
  var ctx = cv.getContext('2d');
95
- var reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
96
99
 
97
100
  /* ---- palette: six hex stops -> rgb triples + soft radial sprites ---- */
98
101
  var STOPS = cfg.palette.map(function (h) {
@@ -257,71 +260,30 @@ const cfg = isEmberCanvas ? { palette: preset.palette, ember: preset.ember } : n
257
260
  draw();
258
261
  }
259
262
 
260
- /* ---- the loop, and the two conditions that stop it ---- */
261
- var rafId = 0;
262
- var running = false;
263
- var lastT = 0;
264
- var visible = !document.hidden;
265
- var onScreen = true;
266
- function loop(now) {
267
- if (!running) {
268
- rafId = 0;
269
- return;
270
- }
271
- var dt = lastT ? now - lastT : 16;
272
- lastT = now;
273
- if (dt > 100) dt = 100;
274
- ensure();
275
- step(dt);
276
- draw();
277
- rafId = window.requestAnimationFrame(loop);
278
- }
279
- function stopLoop() {
280
- running = false;
281
- if (rafId) {
282
- window.cancelAnimationFrame(rafId);
283
- rafId = 0;
284
- }
285
- lastT = 0;
286
- }
287
- function startLoop() {
288
- if (reduced || running || !visible || !onScreen) return;
289
- running = true;
290
- lastT = 0;
291
- rafId = window.requestAnimationFrame(loop);
292
- }
293
-
294
263
  resize();
295
264
  ensure();
296
265
 
297
- if (reduced) {
298
- /* One settled still frame: the composition, none of the motion. */
299
- for (var k = 0; k < 70; k++) step(16);
300
- draw();
301
- return;
302
- }
303
-
304
- document.addEventListener('visibilitychange', function () {
305
- visible = !document.hidden;
306
- if (visible) startLoop();
307
- else stopLoop();
266
+ var motion = window.dlzCreateMotionController({
267
+ target: cv,
268
+ threshold: 0.02,
269
+ watchReducedMotion: false,
270
+ onFrame: function (dt) {
271
+ ensure();
272
+ step(dt);
273
+ draw();
274
+ },
275
+ onStill: function () {
276
+ for (var k = 0; k < 70; k++) step(16);
277
+ draw();
278
+ },
308
279
  });
309
- if ('IntersectionObserver' in window) {
310
- new IntersectionObserver(
311
- function (entries) {
312
- for (var i = 0; i < entries.length; i++) onScreen = entries[i].isIntersecting;
313
- if (onScreen) startLoop();
314
- else stopLoop();
315
- },
316
- { threshold: 0.02 }
317
- ).observe(cv);
318
- }
280
+ if (motion.getState() === 'still') return;
281
+
319
282
  var rz = 0;
320
283
  window.addEventListener('resize', function () {
321
284
  window.clearTimeout(rz);
322
285
  rz = window.setTimeout(resize, 150);
323
286
  });
324
- startLoop();
325
287
  })();
326
288
  </script>
327
289
  )
@@ -0,0 +1,72 @@
1
+ export const enum MotionState {
2
+ Still = 'still',
3
+ Running = 'running',
4
+ Paused = 'paused',
5
+ }
6
+
7
+ export interface MotionControllerOptions {
8
+ target: Element;
9
+ onFrame: (deltaMs: number) => void;
10
+ onStill?: () => void;
11
+ onState?: (state: MotionState) => void;
12
+ threshold?: number;
13
+ watchReducedMotion?: boolean;
14
+ forceStill?: () => boolean;
15
+ canRun?: () => boolean;
16
+ }
17
+
18
+ export interface MotionController {
19
+ getState: () => MotionState;
20
+ sync: () => void;
21
+ }
22
+
23
+ /** Runs a frame loop only while the page is visible and the target in view, or holds a still under reduced motion. */
24
+ export function createMotionController(options: MotionControllerOptions): MotionController {
25
+ const STILL = 'still' as string as MotionState;
26
+ const RUNNING = 'running' as string as MotionState;
27
+ const PAUSED = 'paused' as string as MotionState;
28
+ const FIRST_FRAME_MS = 16;
29
+ const MAX_FRAME_MS = 100;
30
+ const { target, onFrame, onStill, onState, threshold = 0, watchReducedMotion = true, forceStill, canRun } = options;
31
+ const reducedQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
32
+ const reducedAtStart = reducedQuery.matches;
33
+ let inView = true;
34
+ let running = false;
35
+ let frame = 0;
36
+ let last = 0;
37
+ const isStill = (): boolean => (watchReducedMotion ? reducedQuery.matches : reducedAtStart) || forceStill?.() === true;
38
+ const getState = (): MotionState => {
39
+ if (isStill()) return STILL;
40
+ return document.hidden || !inView ? PAUSED : RUNNING;
41
+ };
42
+ const tick = (now: number): void => {
43
+ const deltaMs = last === 0 ? FIRST_FRAME_MS : Math.min(now - last, MAX_FRAME_MS);
44
+ last = now;
45
+ onFrame(deltaMs);
46
+ if (running) frame = window.requestAnimationFrame(tick);
47
+ };
48
+ const stop = (): void => {
49
+ running = false;
50
+ window.cancelAnimationFrame(frame);
51
+ last = 0;
52
+ };
53
+ const sync = (): void => {
54
+ const state = getState();
55
+ onState?.(state);
56
+ if (state === RUNNING && canRun?.() !== false) {
57
+ if (!running) { running = true; frame = window.requestAnimationFrame(tick); }
58
+ return;
59
+ }
60
+ stop();
61
+ if (state === STILL) onStill?.();
62
+ };
63
+ if (watchReducedMotion) reducedQuery.addEventListener('change', sync);
64
+ if (watchReducedMotion || !reducedAtStart) {
65
+ document.addEventListener('visibilitychange', sync);
66
+ if ('IntersectionObserver' in window) {
67
+ new IntersectionObserver((entries) => { entries.forEach((entry) => { inView = entry.isIntersecting; }); sync(); }, { threshold }).observe(target);
68
+ }
69
+ }
70
+ sync();
71
+ return { getState, sync };
72
+ }
@@ -0,0 +1 @@
1
+ export * from './createMotionController';
@@ -0,0 +1,24 @@
1
+ export interface ScrollFadeOptions {
2
+ belowLevel: number;
3
+ switchShare: number;
4
+ }
5
+
6
+ export interface ScrollFade {
7
+ opacity: (progress: number) => number;
8
+ isBelow: (progress: number) => boolean;
9
+ }
10
+
11
+ /** Share of the hero still on screen: 1 at the top of the page, 0 once it has scrolled away. */
12
+ export function heroProgress(scrollY: number, heroHeight: number): number {
13
+ if (heroHeight <= 0) return 0;
14
+ return Math.max(0, Math.min(1, 1 - scrollY / heroHeight));
15
+ }
16
+
17
+ /** Returns the opacity curve (full over the hero, falling to belowLevel) and the switch past switchShare of the hero. */
18
+ export function createScrollFade(options: ScrollFadeOptions): ScrollFade {
19
+ const { belowLevel, switchShare } = options;
20
+ return {
21
+ opacity: (progress) => belowLevel + (1 - belowLevel) * progress,
22
+ isBelow: (progress) => progress < switchShare,
23
+ };
24
+ }
@@ -0,0 +1 @@
1
+ export * from './createScrollFade';