@dloizides/marketing-astro-kit 1.9.2 → 1.10.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,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0
4
+
5
+ ### Added
6
+
7
+ - `./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.
8
+
9
+ ### Changed
10
+
11
+ - `HeroBackdrop` uses `createMotionController`; behaviour unchanged.
12
+
3
13
  ## 1.9.1
4
14
 
5
15
  ### Fixed
package/README.md CHANGED
@@ -298,3 +298,7 @@ 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dloizides/marketing-astro-kit",
3
- "version": "1.9.2",
3
+ "version": "1.10.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,12 @@
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"
64
65
  },
65
66
  "scripts": {
66
67
  "test": "vitest run",
67
- "lint": "eslint src/bookingEmbed src/dateField src/meetingRequest --ext .ts",
68
+ "lint": "eslint src/bookingEmbed src/dateField src/meetingRequest src/motionController --ext .ts",
68
69
  "typecheck": "tsc --noEmit -p ."
69
70
  },
70
71
  "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
  )
@@ -1,434 +1,434 @@
1
- ---
2
- // Reusable "Free-vs-Pro" pricing comparison table for product marketing sites.
3
- // Data-driven (see schema.ts → PricingComparisonData); themed purely through
4
- // the host site's CSS custom properties. Drop-in for any Astro marketing site.
5
- //
6
- // <PricingComparison data={pricing} id="pricing" />
7
- //
8
- // The host page must provide the `[data-contact]` mailto-reveal handler for any
9
- // CTA with `kind: 'contact'` (the scaffold + kefi-marketing already do).
10
- //
11
- // `ctaAttrs` (link vs spam-safe contact + analytics wiring) is shared from
12
- // schema.ts so PrimaryCta.astro renders CTAs identically.
13
- import type { PricingComparisonData } from './schema';
14
- import './a11y.css';
15
- import { ctaAttrs } from './schema';
16
-
17
- interface Props {
18
- data: PricingComparisonData;
19
- id?: string;
20
- }
21
-
22
- const { data, id = 'pricing' } = Astro.props as Props;
23
-
24
- const { tiers, groups } = data;
25
- ---
26
-
27
- <section class={`pmk-pricing`} id={id} aria-labelledby={`${id}-title`}>
28
- <div class="pmk-container">
29
- <p class="pmk-eyebrow" data-reveal>{data.eyebrow}</p>
30
- <h2 class="pmk-title" id={`${id}-title`} data-reveal>{data.title}</h2>
31
- {data.subtitle && <p class="pmk-sub" data-reveal>{data.subtitle}</p>}
32
-
33
- <div class="pmk-tablewrap" data-reveal>
34
- <table class="pmk-table">
35
- <caption class="pmk-visually-hidden">Plan feature comparison</caption>
36
- <thead>
37
- <tr>
38
- <th scope="col" class="pmk-th-corner"><span class="pmk-visually-hidden">Feature</span></th>
39
- {tiers.map((t) => (
40
- <th scope="col" class={`pmk-th${t.featured ? ' is-featured' : ''}`}>
41
- {t.badge && <span class="pmk-ribbon">{t.badge}</span>}
42
- <span class="pmk-tier-name">{t.name}</span>
43
- <span class="pmk-tier-price">
44
- <b>{t.price}</b><i>{t.priceUnit}</i>
45
- </span>
46
- {t.tagline && <span class="pmk-tier-tag">{t.tagline}</span>}
47
- <a class={`pmk-cta${t.featured ? ' pmk-cta--brand' : ' pmk-cta--ink'}`} {...ctaAttrs(t.cta)}>
48
- {t.cta.label}
49
- </a>
50
- </th>
51
- ))}
52
- </tr>
53
- </thead>
54
- <tbody>
55
- {groups.map((group) => (
56
- <>
57
- {group.heading && (
58
- <tr class="pmk-grouprow">
59
- <th scope="colgroup" colspan={tiers.length + 1}>{group.heading}</th>
60
- </tr>
61
- )}
62
- {group.rows.map((row) => (
63
- <tr class="pmk-row">
64
- <th scope="row" class="pmk-rowlabel">
65
- <span class="pmk-rowlabel-t">{row.label}</span>
66
- {row.hint && <span class="pmk-rowlabel-h">{row.hint}</span>}
67
- </th>
68
- {row.cells.map((cell, ci) => (
69
- <td
70
- class={`pmk-cell${tiers[ci]?.featured ? ' is-featured' : ''}`}
71
- data-label={tiers[ci]?.name}
72
- >
73
- {typeof cell === 'boolean' ? (
74
- cell ? (
75
- <span class="pmk-yes" role="img" aria-label="Included">
76
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7" /></svg>
77
- </span>
78
- ) : (
79
- <span class="pmk-no" role="img" aria-label="Not included">
80
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17" /></svg>
81
- </span>
82
- )
83
- ) : (
84
- <span class="pmk-val">{cell}</span>
85
- )}
86
- </td>
87
- ))}
88
- </tr>
89
- ))}
90
- </>
91
- ))}
92
- </tbody>
93
- </table>
94
- </div>
95
-
96
- {data.footnote && <p class="pmk-footnote" data-reveal>{data.footnote}</p>}
97
-
98
- {data.callout && (
99
- <aside class="pmk-callout" data-reveal>
100
- <div class="pmk-callout-body">
101
- {data.callout.badge && <span class="pmk-callout-badge">{data.callout.badge}</span>}
102
- <h3 class="pmk-callout-name">{data.callout.name}</h3>
103
- <p class="pmk-callout-price"><b>{data.callout.price}</b> <i>{data.callout.priceUnit}</i></p>
104
- {data.callout.tagline && <p class="pmk-callout-tag">{data.callout.tagline}</p>}
105
- <ul class="pmk-callout-list">
106
- {data.callout.bullets.map((b) => <li>{b}</li>)}
107
- </ul>
108
- </div>
109
- <a class="pmk-cta pmk-cta--ink pmk-callout-cta" {...ctaAttrs(data.callout.cta)}>
110
- {data.callout.cta.label}
111
- </a>
112
- </aside>
113
- )}
114
- </div>
115
- </section>
116
-
117
- <style>
118
- /* Themed via host CSS vars (fallbacks keep it rendering standalone). */
119
- .pmk-pricing {
120
- --_brand: var(--brand, #d8332a);
121
- --_brand-deep: var(--brand-deep, #a8231c);
122
- --_accent: var(--accent, #f5a300);
123
- --_ink: var(--ink, #0a0a1f);
124
- --_paper: var(--paper, #fff);
125
- --_bg: var(--bg, #fbf9f4);
126
- --_bg-tint: var(--bg-tint, #f1ede1);
127
- --_muted: var(--muted, rgba(10, 10, 31, 0.62));
128
- --_hairline: var(--hairline, rgba(10, 10, 31, 0.1));
129
- --_r-lg: var(--radius-lg, 24px);
130
- --_r-md: var(--radius-md, 14px);
131
- --_shadow: var(--shadow, 0 30px 60px -30px rgba(10, 10, 31, 0.4));
132
- padding: 96px 0;
133
- }
134
- .pmk-container {
135
- width: min(1200px, 100% - 48px);
136
- margin-inline: auto;
137
- }
138
- .pmk-eyebrow {
139
- font-family: 'Oswald', sans-serif;
140
- font-size: 12px;
141
- font-weight: 600;
142
- letter-spacing: 0.22em;
143
- text-transform: uppercase;
144
- color: var(--_brand);
145
- margin: 0;
146
- }
147
- .pmk-title {
148
- font-family: 'Oswald', 'Inter', sans-serif;
149
- font-size: clamp(30px, 3.8vw, 46px);
150
- font-weight: 700;
151
- line-height: 1.5;
152
- letter-spacing: -0.01em;
153
- margin: 12px 0 14px;
154
- max-width: 22ch;
155
- color: var(--_ink);
156
- }
157
- .pmk-sub {
158
- color: var(--_muted);
159
- max-width: 60ch;
160
- margin: 0 0 40px;
161
- }
162
-
163
- /* Table --------------------------------------------------------------- */
164
- .pmk-tablewrap {
165
- overflow-x: auto;
166
- border-radius: var(--_r-lg);
167
- -webkit-overflow-scrolling: touch;
168
- }
169
- .pmk-table {
170
- width: 100%;
171
- min-width: 640px;
172
- border-collapse: separate;
173
- border-spacing: 0;
174
- table-layout: fixed;
175
- }
176
- .pmk-table caption { text-align: left; }
177
- .pmk-th-corner,
178
- .pmk-rowlabel {
179
- width: 34%;
180
- text-align: left;
181
- }
182
- .pmk-th {
183
- position: relative;
184
- vertical-align: bottom;
185
- padding: 22px 18px 20px;
186
- text-align: center;
187
- background: var(--_paper);
188
- border-top: 1px solid var(--_hairline);
189
- border-bottom: 2px solid var(--_hairline);
190
- }
191
- .pmk-th.is-featured {
192
- background: var(--_ink);
193
- border-radius: var(--_r-md) var(--_r-md) 0 0;
194
- border-color: var(--_ink);
195
- }
196
- .pmk-th-corner {
197
- background: transparent;
198
- border-bottom: 2px solid var(--_hairline);
199
- }
200
- .pmk-ribbon {
201
- position: absolute;
202
- top: -11px;
203
- left: 50%;
204
- transform: translateX(-50%);
205
- background: var(--_brand);
206
- color: var(--_paper);
207
- padding: 4px 12px;
208
- border-radius: 999px;
209
- font-family: 'Oswald', sans-serif;
210
- font-size: 10.5px;
211
- font-weight: 600;
212
- letter-spacing: 0.16em;
213
- text-transform: uppercase;
214
- white-space: nowrap;
215
- }
216
- .pmk-tier-name {
217
- display: block;
218
- font-family: 'Oswald', sans-serif;
219
- font-size: 16px;
220
- font-weight: 600;
221
- letter-spacing: 0.06em;
222
- text-transform: uppercase;
223
- color: var(--_ink);
224
- }
225
- .is-featured .pmk-tier-name { color: var(--_paper); }
226
- .pmk-tier-price {
227
- display: block;
228
- margin: 8px 0 2px;
229
- color: var(--_ink);
230
- }
231
- .pmk-tier-price b {
232
- font-family: 'Oswald', sans-serif;
233
- font-size: 34px;
234
- font-weight: 700;
235
- line-height: 1;
236
- }
237
- .pmk-tier-price i {
238
- font-style: normal;
239
- font-size: 13px;
240
- color: var(--_muted);
241
- margin-left: 4px;
242
- }
243
- .is-featured .pmk-tier-price,
244
- .is-featured .pmk-tier-price b { color: var(--_paper); }
245
- .is-featured .pmk-tier-price i { color: rgba(255, 255, 255, 0.7); }
246
- .pmk-tier-tag {
247
- display: block;
248
- font-size: 12.5px;
249
- color: var(--_muted);
250
- margin-bottom: 14px;
251
- min-height: 1.4em;
252
- }
253
- .is-featured .pmk-tier-tag { color: rgba(255, 255, 255, 0.72); }
254
-
255
- /* CTA (self-contained — does not depend on host .btn) ----------------- */
256
- .pmk-cta {
257
- box-sizing: border-box;
258
- min-height: var(--tmk-min-target);
259
- min-width: var(--tmk-min-target);
260
- display: inline-flex;
261
- align-items: center;
262
- justify-content: center;
263
- gap: 8px;
264
- padding: 11px 18px;
265
- border-radius: 999px;
266
- font-family: 'Inter', system-ui, sans-serif;
267
- font-weight: 600;
268
- font-size: 13.5px;
269
- letter-spacing: 0.02em;
270
- border: 1px solid transparent;
271
- cursor: pointer;
272
- transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
273
- text-decoration: none;
274
- }
275
- .pmk-cta:hover { transform: translateY(-1px); }
276
- .pmk-cta:focus-visible { outline: 2px solid var(--_brand); outline-offset: 3px; }
277
- .pmk-cta--ink { background: var(--_ink); color: var(--_paper); }
278
- .pmk-cta--ink:hover { background: var(--_brand); }
279
- .pmk-cta--brand { background: var(--_brand); color: var(--_paper); }
280
- .pmk-cta--brand:hover { background: var(--_brand-deep); }
281
- .is-featured .pmk-cta--brand { box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.5); }
282
-
283
- /* Group + rows -------------------------------------------------------- */
284
- .pmk-grouprow th {
285
- text-align: left;
286
- padding: 22px 18px 8px;
287
- font-family: 'Oswald', sans-serif;
288
- font-size: 11px;
289
- font-weight: 600;
290
- letter-spacing: 0.18em;
291
- text-transform: uppercase;
292
- color: var(--_brand);
293
- }
294
- .pmk-row:hover .pmk-rowlabel,
295
- .pmk-row:hover .pmk-cell:not(.is-featured) {
296
- background: var(--_bg-tint);
297
- }
298
- .pmk-rowlabel {
299
- padding: 15px 18px;
300
- vertical-align: middle;
301
- border-bottom: 1px solid var(--_hairline);
302
- font-weight: 500;
303
- }
304
- .pmk-rowlabel-t { display: block; color: var(--_ink); font-size: 15px; }
305
- .pmk-rowlabel-h { display: block; color: var(--_muted); font-size: 12.5px; margin-top: 2px; }
306
- .pmk-cell {
307
- padding: 15px 18px;
308
- text-align: center;
309
- vertical-align: middle;
310
- border-bottom: 1px solid var(--_hairline);
311
- color: var(--_ink);
312
- }
313
- .pmk-cell.is-featured {
314
- background: color-mix(in srgb, var(--_ink) 5%, transparent);
315
- border-left: 1px solid var(--_hairline);
316
- border-right: 1px solid var(--_hairline);
317
- }
318
- .pmk-val {
319
- font-family: 'Oswald', sans-serif;
320
- font-weight: 600;
321
- font-size: 14px;
322
- letter-spacing: 0.01em;
323
- }
324
- .pmk-yes,
325
- .pmk-no {
326
- display: inline-grid;
327
- place-items: center;
328
- width: 24px;
329
- height: 24px;
330
- border-radius: 50%;
331
- }
332
- .pmk-yes {
333
- background: color-mix(in srgb, var(--_accent) 20%, transparent);
334
- color: var(--_brand-deep);
335
- }
336
- .pmk-yes svg { width: 15px; height: 15px; }
337
- .pmk-no { color: var(--_muted); opacity: 0.5; }
338
- .pmk-no svg { width: 15px; height: 15px; }
339
- /* last row of the featured column gets a rounded bottom */
340
- .pmk-table tbody tr:last-child .pmk-cell.is-featured {
341
- border-radius: 0 0 var(--_r-md) var(--_r-md);
342
- }
343
-
344
- .pmk-footnote {
345
- color: var(--_muted);
346
- font-size: 13.5px;
347
- margin: 18px 2px 0;
348
- max-width: 65ch;
349
- }
350
-
351
- /* Concierge / one-time callout --------------------------------------- */
352
- .pmk-callout {
353
- margin-top: 26px;
354
- display: flex;
355
- align-items: center;
356
- justify-content: space-between;
357
- gap: 28px;
358
- flex-wrap: wrap;
359
- padding: 26px 30px;
360
- border-radius: var(--_r-lg);
361
- background: var(--_bg-tint);
362
- border: 1px solid var(--_hairline);
363
- }
364
- .pmk-callout-badge {
365
- display: inline-block;
366
- font-family: 'Oswald', sans-serif;
367
- font-size: 11px;
368
- font-weight: 600;
369
- letter-spacing: 0.16em;
370
- text-transform: uppercase;
371
- color: var(--_ink);
372
- background: var(--_accent);
373
- padding: 4px 10px;
374
- border-radius: 999px;
375
- margin-bottom: 12px;
376
- }
377
- .pmk-callout-name {
378
- font-family: 'Oswald', sans-serif;
379
- font-size: 22px;
380
- font-weight: 700;
381
- margin: 0;
382
- display: inline-block;
383
- }
384
- .pmk-callout-price {
385
- margin: 4px 0 8px;
386
- color: var(--_ink);
387
- }
388
- .pmk-callout-price b { font-family: 'Oswald', sans-serif; font-size: 26px; }
389
- .pmk-callout-price i { font-style: normal; font-size: 13px; color: var(--_muted); }
390
- .pmk-callout-tag { color: var(--_muted); margin: 0 0 10px; font-size: 14.5px; }
391
- .pmk-callout-list {
392
- list-style: none;
393
- padding: 0;
394
- margin: 0;
395
- display: flex;
396
- flex-wrap: wrap;
397
- gap: 6px 22px;
398
- max-width: 62ch;
399
- }
400
- .pmk-callout-list li {
401
- position: relative;
402
- padding-left: 18px;
403
- color: var(--_muted);
404
- font-size: 13.5px;
405
- }
406
- .pmk-callout-list li::before {
407
- content: '';
408
- position: absolute;
409
- left: 0;
410
- top: 8px;
411
- width: 7px;
412
- height: 7px;
413
- border-radius: 50%;
414
- background: var(--_brand);
415
- }
416
- .pmk-callout-cta { white-space: nowrap; flex-shrink: 0; }
417
-
418
- .pmk-visually-hidden {
419
- position: absolute;
420
- width: 1px;
421
- height: 1px;
422
- padding: 0;
423
- margin: -1px;
424
- overflow: hidden;
425
- clip: rect(0 0 0 0);
426
- white-space: nowrap;
427
- border: 0;
428
- }
429
-
430
- @media (max-width: 640px) {
431
- .pmk-pricing { padding: 64px 0; }
432
- .pmk-callout { flex-direction: column; align-items: flex-start; }
433
- }
434
- </style>
1
+ ---
2
+ // Reusable "Free-vs-Pro" pricing comparison table for product marketing sites.
3
+ // Data-driven (see schema.ts → PricingComparisonData); themed purely through
4
+ // the host site's CSS custom properties. Drop-in for any Astro marketing site.
5
+ //
6
+ // <PricingComparison data={pricing} id="pricing" />
7
+ //
8
+ // The host page must provide the `[data-contact]` mailto-reveal handler for any
9
+ // CTA with `kind: 'contact'` (the scaffold + kefi-marketing already do).
10
+ //
11
+ // `ctaAttrs` (link vs spam-safe contact + analytics wiring) is shared from
12
+ // schema.ts so PrimaryCta.astro renders CTAs identically.
13
+ import type { PricingComparisonData } from './schema';
14
+ import './a11y.css';
15
+ import { ctaAttrs } from './schema';
16
+
17
+ interface Props {
18
+ data: PricingComparisonData;
19
+ id?: string;
20
+ }
21
+
22
+ const { data, id = 'pricing' } = Astro.props as Props;
23
+
24
+ const { tiers, groups } = data;
25
+ ---
26
+
27
+ <section class={`pmk-pricing`} id={id} aria-labelledby={`${id}-title`}>
28
+ <div class="pmk-container">
29
+ <p class="pmk-eyebrow" data-reveal>{data.eyebrow}</p>
30
+ <h2 class="pmk-title" id={`${id}-title`} data-reveal>{data.title}</h2>
31
+ {data.subtitle && <p class="pmk-sub" data-reveal>{data.subtitle}</p>}
32
+
33
+ <div class="pmk-tablewrap" data-reveal>
34
+ <table class="pmk-table">
35
+ <caption class="pmk-visually-hidden">Plan feature comparison</caption>
36
+ <thead>
37
+ <tr>
38
+ <th scope="col" class="pmk-th-corner"><span class="pmk-visually-hidden">Feature</span></th>
39
+ {tiers.map((t) => (
40
+ <th scope="col" class={`pmk-th${t.featured ? ' is-featured' : ''}`}>
41
+ {t.badge && <span class="pmk-ribbon">{t.badge}</span>}
42
+ <span class="pmk-tier-name">{t.name}</span>
43
+ <span class="pmk-tier-price">
44
+ <b>{t.price}</b><i>{t.priceUnit}</i>
45
+ </span>
46
+ {t.tagline && <span class="pmk-tier-tag">{t.tagline}</span>}
47
+ <a class={`pmk-cta${t.featured ? ' pmk-cta--brand' : ' pmk-cta--ink'}`} {...ctaAttrs(t.cta)}>
48
+ {t.cta.label}
49
+ </a>
50
+ </th>
51
+ ))}
52
+ </tr>
53
+ </thead>
54
+ <tbody>
55
+ {groups.map((group) => (
56
+ <>
57
+ {group.heading && (
58
+ <tr class="pmk-grouprow">
59
+ <th scope="colgroup" colspan={tiers.length + 1}>{group.heading}</th>
60
+ </tr>
61
+ )}
62
+ {group.rows.map((row) => (
63
+ <tr class="pmk-row">
64
+ <th scope="row" class="pmk-rowlabel">
65
+ <span class="pmk-rowlabel-t">{row.label}</span>
66
+ {row.hint && <span class="pmk-rowlabel-h">{row.hint}</span>}
67
+ </th>
68
+ {row.cells.map((cell, ci) => (
69
+ <td
70
+ class={`pmk-cell${tiers[ci]?.featured ? ' is-featured' : ''}`}
71
+ data-label={tiers[ci]?.name}
72
+ >
73
+ {typeof cell === 'boolean' ? (
74
+ cell ? (
75
+ <span class="pmk-yes" role="img" aria-label="Included">
76
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7" /></svg>
77
+ </span>
78
+ ) : (
79
+ <span class="pmk-no" role="img" aria-label="Not included">
80
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17" /></svg>
81
+ </span>
82
+ )
83
+ ) : (
84
+ <span class="pmk-val">{cell}</span>
85
+ )}
86
+ </td>
87
+ ))}
88
+ </tr>
89
+ ))}
90
+ </>
91
+ ))}
92
+ </tbody>
93
+ </table>
94
+ </div>
95
+
96
+ {data.footnote && <p class="pmk-footnote" data-reveal>{data.footnote}</p>}
97
+
98
+ {data.callout && (
99
+ <aside class="pmk-callout" data-reveal>
100
+ <div class="pmk-callout-body">
101
+ {data.callout.badge && <span class="pmk-callout-badge">{data.callout.badge}</span>}
102
+ <h3 class="pmk-callout-name">{data.callout.name}</h3>
103
+ <p class="pmk-callout-price"><b>{data.callout.price}</b> <i>{data.callout.priceUnit}</i></p>
104
+ {data.callout.tagline && <p class="pmk-callout-tag">{data.callout.tagline}</p>}
105
+ <ul class="pmk-callout-list">
106
+ {data.callout.bullets.map((b) => <li>{b}</li>)}
107
+ </ul>
108
+ </div>
109
+ <a class="pmk-cta pmk-cta--ink pmk-callout-cta" {...ctaAttrs(data.callout.cta)}>
110
+ {data.callout.cta.label}
111
+ </a>
112
+ </aside>
113
+ )}
114
+ </div>
115
+ </section>
116
+
117
+ <style>
118
+ /* Themed via host CSS vars (fallbacks keep it rendering standalone). */
119
+ .pmk-pricing {
120
+ --_brand: var(--brand, #d8332a);
121
+ --_brand-deep: var(--brand-deep, #a8231c);
122
+ --_accent: var(--accent, #f5a300);
123
+ --_ink: var(--ink, #0a0a1f);
124
+ --_paper: var(--paper, #fff);
125
+ --_bg: var(--bg, #fbf9f4);
126
+ --_bg-tint: var(--bg-tint, #f1ede1);
127
+ --_muted: var(--muted, rgba(10, 10, 31, 0.62));
128
+ --_hairline: var(--hairline, rgba(10, 10, 31, 0.1));
129
+ --_r-lg: var(--radius-lg, 24px);
130
+ --_r-md: var(--radius-md, 14px);
131
+ --_shadow: var(--shadow, 0 30px 60px -30px rgba(10, 10, 31, 0.4));
132
+ padding: 96px 0;
133
+ }
134
+ .pmk-container {
135
+ width: min(1200px, 100% - 48px);
136
+ margin-inline: auto;
137
+ }
138
+ .pmk-eyebrow {
139
+ font-family: 'Oswald', sans-serif;
140
+ font-size: 12px;
141
+ font-weight: 600;
142
+ letter-spacing: 0.22em;
143
+ text-transform: uppercase;
144
+ color: var(--_brand);
145
+ margin: 0;
146
+ }
147
+ .pmk-title {
148
+ font-family: 'Oswald', 'Inter', sans-serif;
149
+ font-size: clamp(30px, 3.8vw, 46px);
150
+ font-weight: 700;
151
+ line-height: 1.5;
152
+ letter-spacing: -0.01em;
153
+ margin: 12px 0 14px;
154
+ max-width: 22ch;
155
+ color: var(--_ink);
156
+ }
157
+ .pmk-sub {
158
+ color: var(--_muted);
159
+ max-width: 60ch;
160
+ margin: 0 0 40px;
161
+ }
162
+
163
+ /* Table --------------------------------------------------------------- */
164
+ .pmk-tablewrap {
165
+ overflow-x: auto;
166
+ border-radius: var(--_r-lg);
167
+ -webkit-overflow-scrolling: touch;
168
+ }
169
+ .pmk-table {
170
+ width: 100%;
171
+ min-width: 640px;
172
+ border-collapse: separate;
173
+ border-spacing: 0;
174
+ table-layout: fixed;
175
+ }
176
+ .pmk-table caption { text-align: left; }
177
+ .pmk-th-corner,
178
+ .pmk-rowlabel {
179
+ width: 34%;
180
+ text-align: left;
181
+ }
182
+ .pmk-th {
183
+ position: relative;
184
+ vertical-align: bottom;
185
+ padding: 22px 18px 20px;
186
+ text-align: center;
187
+ background: var(--_paper);
188
+ border-top: 1px solid var(--_hairline);
189
+ border-bottom: 2px solid var(--_hairline);
190
+ }
191
+ .pmk-th.is-featured {
192
+ background: var(--_ink);
193
+ border-radius: var(--_r-md) var(--_r-md) 0 0;
194
+ border-color: var(--_ink);
195
+ }
196
+ .pmk-th-corner {
197
+ background: transparent;
198
+ border-bottom: 2px solid var(--_hairline);
199
+ }
200
+ .pmk-ribbon {
201
+ position: absolute;
202
+ top: -11px;
203
+ left: 50%;
204
+ transform: translateX(-50%);
205
+ background: var(--_brand);
206
+ color: var(--_paper);
207
+ padding: 4px 12px;
208
+ border-radius: 999px;
209
+ font-family: 'Oswald', sans-serif;
210
+ font-size: 10.5px;
211
+ font-weight: 600;
212
+ letter-spacing: 0.16em;
213
+ text-transform: uppercase;
214
+ white-space: nowrap;
215
+ }
216
+ .pmk-tier-name {
217
+ display: block;
218
+ font-family: 'Oswald', sans-serif;
219
+ font-size: 16px;
220
+ font-weight: 600;
221
+ letter-spacing: 0.06em;
222
+ text-transform: uppercase;
223
+ color: var(--_ink);
224
+ }
225
+ .is-featured .pmk-tier-name { color: var(--_paper); }
226
+ .pmk-tier-price {
227
+ display: block;
228
+ margin: 8px 0 2px;
229
+ color: var(--_ink);
230
+ }
231
+ .pmk-tier-price b {
232
+ font-family: 'Oswald', sans-serif;
233
+ font-size: 34px;
234
+ font-weight: 700;
235
+ line-height: 1.5;
236
+ }
237
+ .pmk-tier-price i {
238
+ font-style: normal;
239
+ font-size: 13px;
240
+ color: var(--_muted);
241
+ margin-left: 4px;
242
+ }
243
+ .is-featured .pmk-tier-price,
244
+ .is-featured .pmk-tier-price b { color: var(--_paper); }
245
+ .is-featured .pmk-tier-price i { color: rgba(255, 255, 255, 0.7); }
246
+ .pmk-tier-tag {
247
+ display: block;
248
+ font-size: 12.5px;
249
+ color: var(--_muted);
250
+ margin-bottom: 14px;
251
+ min-height: 1.4em;
252
+ }
253
+ .is-featured .pmk-tier-tag { color: rgba(255, 255, 255, 0.72); }
254
+
255
+ /* CTA (self-contained — does not depend on host .btn) ----------------- */
256
+ .pmk-cta {
257
+ box-sizing: border-box;
258
+ min-height: var(--tmk-min-target);
259
+ min-width: var(--tmk-min-target);
260
+ display: inline-flex;
261
+ align-items: center;
262
+ justify-content: center;
263
+ gap: 8px;
264
+ padding: 11px 18px;
265
+ border-radius: 999px;
266
+ font-family: 'Inter', system-ui, sans-serif;
267
+ font-weight: 600;
268
+ font-size: 13.5px;
269
+ letter-spacing: 0.02em;
270
+ border: 1px solid transparent;
271
+ cursor: pointer;
272
+ transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
273
+ text-decoration: none;
274
+ }
275
+ .pmk-cta:hover { transform: translateY(-1px); }
276
+ .pmk-cta:focus-visible { outline: 2px solid var(--_brand); outline-offset: 3px; }
277
+ .pmk-cta--ink { background: var(--_ink); color: var(--_paper); }
278
+ .pmk-cta--ink:hover { background: var(--_brand); }
279
+ .pmk-cta--brand { background: var(--_brand); color: var(--_paper); }
280
+ .pmk-cta--brand:hover { background: var(--_brand-deep); }
281
+ .is-featured .pmk-cta--brand { box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.5); }
282
+
283
+ /* Group + rows -------------------------------------------------------- */
284
+ .pmk-grouprow th {
285
+ text-align: left;
286
+ padding: 22px 18px 8px;
287
+ font-family: 'Oswald', sans-serif;
288
+ font-size: 11px;
289
+ font-weight: 600;
290
+ letter-spacing: 0.18em;
291
+ text-transform: uppercase;
292
+ color: var(--_brand);
293
+ }
294
+ .pmk-row:hover .pmk-rowlabel,
295
+ .pmk-row:hover .pmk-cell:not(.is-featured) {
296
+ background: var(--_bg-tint);
297
+ }
298
+ .pmk-rowlabel {
299
+ padding: 15px 18px;
300
+ vertical-align: middle;
301
+ border-bottom: 1px solid var(--_hairline);
302
+ font-weight: 500;
303
+ }
304
+ .pmk-rowlabel-t { display: block; color: var(--_ink); font-size: 15px; }
305
+ .pmk-rowlabel-h { display: block; color: var(--_muted); font-size: 12.5px; margin-top: 2px; }
306
+ .pmk-cell {
307
+ padding: 15px 18px;
308
+ text-align: center;
309
+ vertical-align: middle;
310
+ border-bottom: 1px solid var(--_hairline);
311
+ color: var(--_ink);
312
+ }
313
+ .pmk-cell.is-featured {
314
+ background: color-mix(in srgb, var(--_ink) 5%, transparent);
315
+ border-left: 1px solid var(--_hairline);
316
+ border-right: 1px solid var(--_hairline);
317
+ }
318
+ .pmk-val {
319
+ font-family: 'Oswald', sans-serif;
320
+ font-weight: 600;
321
+ font-size: 14px;
322
+ letter-spacing: 0.01em;
323
+ }
324
+ .pmk-yes,
325
+ .pmk-no {
326
+ display: inline-grid;
327
+ place-items: center;
328
+ width: 24px;
329
+ height: 24px;
330
+ border-radius: 50%;
331
+ }
332
+ .pmk-yes {
333
+ background: color-mix(in srgb, var(--_accent) 20%, transparent);
334
+ color: var(--_brand-deep);
335
+ }
336
+ .pmk-yes svg { width: 15px; height: 15px; }
337
+ .pmk-no { color: var(--_muted); opacity: 0.5; }
338
+ .pmk-no svg { width: 15px; height: 15px; }
339
+ /* last row of the featured column gets a rounded bottom */
340
+ .pmk-table tbody tr:last-child .pmk-cell.is-featured {
341
+ border-radius: 0 0 var(--_r-md) var(--_r-md);
342
+ }
343
+
344
+ .pmk-footnote {
345
+ color: var(--_muted);
346
+ font-size: 13.5px;
347
+ margin: 18px 2px 0;
348
+ max-width: 65ch;
349
+ }
350
+
351
+ /* Concierge / one-time callout --------------------------------------- */
352
+ .pmk-callout {
353
+ margin-top: 26px;
354
+ display: flex;
355
+ align-items: center;
356
+ justify-content: space-between;
357
+ gap: 28px;
358
+ flex-wrap: wrap;
359
+ padding: 26px 30px;
360
+ border-radius: var(--_r-lg);
361
+ background: var(--_bg-tint);
362
+ border: 1px solid var(--_hairline);
363
+ }
364
+ .pmk-callout-badge {
365
+ display: inline-block;
366
+ font-family: 'Oswald', sans-serif;
367
+ font-size: 11px;
368
+ font-weight: 600;
369
+ letter-spacing: 0.16em;
370
+ text-transform: uppercase;
371
+ color: var(--_ink);
372
+ background: var(--_accent);
373
+ padding: 4px 10px;
374
+ border-radius: 999px;
375
+ margin-bottom: 12px;
376
+ }
377
+ .pmk-callout-name {
378
+ font-family: 'Oswald', sans-serif;
379
+ font-size: 22px;
380
+ font-weight: 700;
381
+ margin: 0;
382
+ display: inline-block;
383
+ }
384
+ .pmk-callout-price {
385
+ margin: 4px 0 8px;
386
+ color: var(--_ink);
387
+ }
388
+ .pmk-callout-price b { font-family: 'Oswald', sans-serif; font-size: 26px; }
389
+ .pmk-callout-price i { font-style: normal; font-size: 13px; color: var(--_muted); }
390
+ .pmk-callout-tag { color: var(--_muted); margin: 0 0 10px; font-size: 14.5px; }
391
+ .pmk-callout-list {
392
+ list-style: none;
393
+ padding: 0;
394
+ margin: 0;
395
+ display: flex;
396
+ flex-wrap: wrap;
397
+ gap: 6px 22px;
398
+ max-width: 62ch;
399
+ }
400
+ .pmk-callout-list li {
401
+ position: relative;
402
+ padding-left: 18px;
403
+ color: var(--_muted);
404
+ font-size: 13.5px;
405
+ }
406
+ .pmk-callout-list li::before {
407
+ content: '';
408
+ position: absolute;
409
+ left: 0;
410
+ top: 8px;
411
+ width: 7px;
412
+ height: 7px;
413
+ border-radius: 50%;
414
+ background: var(--_brand);
415
+ }
416
+ .pmk-callout-cta { white-space: nowrap; flex-shrink: 0; }
417
+
418
+ .pmk-visually-hidden {
419
+ position: absolute;
420
+ width: 1px;
421
+ height: 1px;
422
+ padding: 0;
423
+ margin: -1px;
424
+ overflow: hidden;
425
+ clip: rect(0 0 0 0);
426
+ white-space: nowrap;
427
+ border: 0;
428
+ }
429
+
430
+ @media (max-width: 640px) {
431
+ .pmk-pricing { padding: 64px 0; }
432
+ .pmk-callout { flex-direction: column; align-items: flex-start; }
433
+ }
434
+ </style>
@@ -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';