@atomic-ui/blocks 0.7.1 → 0.8.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/README.md +7 -7
- package/custom-elements.json +1375 -3
- package/dist/{chunk-XHFUTZGU.js → chunk-CC2U2L2H.js} +5 -3
- package/dist/{chunk-XHFUTZGU.js.map → chunk-CC2U2L2H.js.map} +1 -1
- package/dist/{chunk-MYTYMOH6.js → chunk-CPOCQURG.js} +26 -7
- package/dist/chunk-CPOCQURG.js.map +1 -0
- package/dist/{chunk-OTOFULMT.js → chunk-FLOKZ7O3.js} +72 -22
- package/dist/chunk-FLOKZ7O3.js.map +1 -0
- package/dist/{chunk-WHENVU5E.js → chunk-HNCJLMQB.js} +41 -15
- package/dist/chunk-HNCJLMQB.js.map +1 -0
- package/dist/{chunk-4JW2CHWS.js → chunk-NLHFBIGQ.js} +67 -21
- package/dist/chunk-NLHFBIGQ.js.map +1 -0
- package/dist/{chunk-AFN7IAG2.js → chunk-OR4U4UJQ.js} +70 -24
- package/dist/chunk-OR4U4UJQ.js.map +1 -0
- package/dist/{chunk-T7U4OPTW.js → chunk-PALYJCLC.js} +37 -12
- package/dist/chunk-PALYJCLC.js.map +1 -0
- package/dist/chunk-PTQDYIC5.js +447 -0
- package/dist/chunk-PTQDYIC5.js.map +1 -0
- package/dist/{chunk-XJMKAK2I.js → chunk-TT2PTEQO.js} +72 -26
- package/dist/chunk-TT2PTEQO.js.map +1 -0
- package/dist/{chunk-PORKVHAX.js → chunk-UVHQY3QJ.js} +1 -1
- package/dist/{chunk-PORKVHAX.js.map → chunk-UVHQY3QJ.js.map} +1 -1
- package/dist/{chunk-F4BTXUYP.js → chunk-YC6KXE6O.js} +12 -5
- package/dist/chunk-YC6KXE6O.js.map +1 -0
- package/dist/chunk-YMSFOS3H.js +142 -0
- package/dist/chunk-YMSFOS3H.js.map +1 -0
- package/dist/components/card-grid.js +1 -1
- package/dist/components/changelog.js +2 -2
- package/dist/components/estimator.js +1 -1
- package/dist/components/journey.d.ts +106 -0
- package/dist/components/journey.js +9 -0
- package/dist/components/journey.js.map +1 -0
- package/dist/components/marketing.js +1 -1
- package/dist/components/organisms.js +1 -1
- package/dist/components/property.js +1 -1
- package/dist/components/scene.js +1 -1
- package/dist/components/scrubber.js +1 -1
- package/dist/components/selling.js +1 -1
- package/dist/components/site.d.ts +11 -0
- package/dist/components/site.js +1 -1
- package/dist/components/studio.d.ts +430 -0
- package/dist/components/studio.js +19 -0
- package/dist/components/studio.js.map +1 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +34 -12
- package/dist/index.js.map +1 -1
- package/dist/standalone/atomic-ui-blocks.js +893 -677
- package/dist/standalone/atomic-ui-blocks.js.map +4 -4
- package/dist/standalone/index.html +85 -63
- package/package.json +3 -3
- package/scripts/copy-to-product.mjs +8 -7
- package/specimen/index.html +85 -63
- package/dist/chunk-4JW2CHWS.js.map +0 -1
- package/dist/chunk-AFN7IAG2.js.map +0 -1
- package/dist/chunk-F4BTXUYP.js.map +0 -1
- package/dist/chunk-MYTYMOH6.js.map +0 -1
- package/dist/chunk-OTOFULMT.js.map +0 -1
- package/dist/chunk-T7U4OPTW.js.map +0 -1
- package/dist/chunk-WHENVU5E.js.map +0 -1
- package/dist/chunk-XJMKAK2I.js.map +0 -1
|
@@ -40,7 +40,13 @@ var ImpaktPlanComparison = class extends ImpaktElement {
|
|
|
40
40
|
this.spaceBelow = "none";
|
|
41
41
|
}
|
|
42
42
|
static {
|
|
43
|
-
this.styles = [
|
|
43
|
+
this.styles = [
|
|
44
|
+
...ImpaktElement.styles,
|
|
45
|
+
focusRing,
|
|
46
|
+
targetSize,
|
|
47
|
+
spaceAround,
|
|
48
|
+
card,
|
|
49
|
+
css`
|
|
44
50
|
:host { display: block; container-type: inline-size; }
|
|
45
51
|
.h { margin-block-end: ${space(5)}; }
|
|
46
52
|
.grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: ${space(4)}; }
|
|
@@ -57,7 +63,8 @@ var ImpaktPlanComparison = class extends ImpaktElement {
|
|
|
57
63
|
.mark { flex-shrink: 0; inline-size: 1.25em; font-weight: ${fontWeight("bold")}; text-align: center; }
|
|
58
64
|
li[data-has='true'] .mark { color: ${t.successText}; }
|
|
59
65
|
@container (max-width: 40rem) { .grid { grid-template-columns: minmax(0, 1fr); gap: ${space(6)}; } }
|
|
60
|
-
`
|
|
66
|
+
`
|
|
67
|
+
];
|
|
61
68
|
}
|
|
62
69
|
has(plan, row) {
|
|
63
70
|
return plan.includes.split(",").map((s) => s.trim().toLowerCase()).includes(row.label.trim().toLowerCase());
|
|
@@ -70,17 +77,19 @@ var ImpaktPlanComparison = class extends ImpaktElement {
|
|
|
70
77
|
return html`
|
|
71
78
|
${this.heading ? html`<div class="h" role="heading" aria-level=${this.headingLevel}>${this.heading}</div>` : nothing}
|
|
72
79
|
<div class="grid" style=${`--cols: ${Math.max(1, this.plans.length)}`}>
|
|
73
|
-
${this.plans.map(
|
|
80
|
+
${this.plans.map(
|
|
81
|
+
(p) => html`<section class="card plan ${p.badge ? "top" : ""}" aria-labelledby=${this.id_(`n-${p.id}`)}>
|
|
74
82
|
${p.badge ? html`<span class="badge">${p.badge}</span>` : nothing}
|
|
75
83
|
<h3 class="name" id=${this.id_(`n-${p.id}`)}>${p.name}</h3>
|
|
76
84
|
<p class="price">${p.price}${p.period ? html` <span class="period">${p.period}</span>` : nothing}</p>
|
|
77
85
|
${p.note ? html`<p class="note">${p.note}</p>` : nothing}
|
|
78
86
|
<ul>${this.rows.map((r) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
const has = this.has(p, r);
|
|
88
|
+
return html`<li data-has=${String(has)}><span class="mark" aria-hidden="true">${has ? "\u2713" : "\u2013"}</span><span>${r.label}<span class="visually-hidden">: ${say(has ? "included" : "not included")}</span></span></li>`;
|
|
89
|
+
})}</ul>
|
|
82
90
|
${p.href ? html`<a class="btn ${p.badge ? "" : "quiet"}" href=${p.href} @click=${(e) => this.choose(p, e)}>${this.buttonText}<span class="visually-hidden"> ${p.name}</span></a>` : html`<button class="btn ${p.badge ? "" : "quiet"}" type="button" @click=${(e) => this.choose(p, e)}>${this.buttonText}<span class="visually-hidden"> ${p.name}</span></button>`}
|
|
83
|
-
</section>`
|
|
91
|
+
</section>`
|
|
92
|
+
)}
|
|
84
93
|
</div>`;
|
|
85
94
|
}
|
|
86
95
|
};
|
|
@@ -120,7 +129,12 @@ var ImpaktVideo = class extends ImpaktElement {
|
|
|
120
129
|
this.spaceBelow = "none";
|
|
121
130
|
}
|
|
122
131
|
static {
|
|
123
|
-
this.styles = [
|
|
132
|
+
this.styles = [
|
|
133
|
+
...ImpaktElement.styles,
|
|
134
|
+
focusRing,
|
|
135
|
+
spaceAround,
|
|
136
|
+
card,
|
|
137
|
+
css`
|
|
124
138
|
:host { display: block; }
|
|
125
139
|
.frame { position: relative; overflow: hidden; aspect-ratio: 16 / 9; border-radius: ${t.radiusXl}; background: #111; }
|
|
126
140
|
:host([ratio='4:3']) .frame { aspect-ratio: 4 / 3; }
|
|
@@ -134,21 +148,25 @@ var ImpaktVideo = class extends ImpaktElement {
|
|
|
134
148
|
.foot { margin: ${space(2)} 0 0; ${type("sm")} }
|
|
135
149
|
.foot a { color: ${t.link}; }
|
|
136
150
|
.empty { display: grid; place-items: center; block-size: 100%; color: #ccc; }
|
|
137
|
-
`
|
|
151
|
+
`
|
|
152
|
+
];
|
|
138
153
|
}
|
|
139
154
|
render() {
|
|
140
155
|
const embed = embedOf(this.videoSrc, pageLocale(this));
|
|
141
156
|
let player;
|
|
142
157
|
if (!this.videoSrc) player = html`<div class="empty">${say("Add a video address")}</div>`;
|
|
143
|
-
else if (embed && this.playing)
|
|
144
|
-
|
|
158
|
+
else if (embed && this.playing)
|
|
159
|
+
player = html`<iframe src=${embed} title=${this.label} allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowfullscreen></iframe>`;
|
|
160
|
+
else if (embed)
|
|
161
|
+
player = html`${this.posterSrc ? html`<img src=${this.posterSrc} alt="" />` : nothing}
|
|
145
162
|
<button class="play" type="button" @click=${() => {
|
|
146
|
-
|
|
147
|
-
|
|
163
|
+
this.playing = true;
|
|
164
|
+
}}>
|
|
148
165
|
<span class="disc" aria-hidden="true"><svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg></span>
|
|
149
166
|
<span class="label">${this.playText}<span class="visually-hidden">: ${this.label}</span></span>
|
|
150
167
|
</button>`;
|
|
151
|
-
else
|
|
168
|
+
else
|
|
169
|
+
player = html`<video controls preload="metadata" poster=${this.posterSrc || nothing} aria-label=${this.label}>
|
|
152
170
|
<source src=${this.videoSrc} />
|
|
153
171
|
${this.captionsSrc ? html`<track kind="captions" src=${this.captionsSrc} srclang="en" label="English" default />` : nothing}
|
|
154
172
|
</video>`;
|
|
@@ -158,7 +176,10 @@ var ImpaktVideo = class extends ImpaktElement {
|
|
|
158
176
|
};
|
|
159
177
|
var NOTICE_WORDS = {
|
|
160
178
|
mortgage: { heading: "Your home may be repossessed", text: "Your home may be repossessed if you do not keep up repayments on your mortgage." },
|
|
161
|
-
"secured-loan": {
|
|
179
|
+
"secured-loan": {
|
|
180
|
+
heading: "Think carefully before securing other debts against your home",
|
|
181
|
+
text: "Your home may be repossessed if you do not keep up repayments on a mortgage or any other debt secured on it."
|
|
182
|
+
},
|
|
162
183
|
investment: { heading: "Capital at risk", text: "The value of investments can go down as well as up, and you may get back less than you put in." },
|
|
163
184
|
insurance: { heading: "Important information", text: "Read the policy documents to check the cover suits your needs. Limits and exclusions apply." },
|
|
164
185
|
custom: { heading: "", text: "" }
|
|
@@ -184,7 +205,10 @@ var ImpaktRegulatoryNotice = class extends ImpaktElement {
|
|
|
184
205
|
this.spaceBelow = "none";
|
|
185
206
|
}
|
|
186
207
|
static {
|
|
187
|
-
this.styles = [
|
|
208
|
+
this.styles = [
|
|
209
|
+
...ImpaktElement.styles,
|
|
210
|
+
spaceAround,
|
|
211
|
+
css`
|
|
188
212
|
:host { display: block; }
|
|
189
213
|
.box { padding: ${space(5)}; border-inline-start: 6px solid ${t.warning}; border-radius: ${t.radiusLg}; background: ${t.warningSubtle}; }
|
|
190
214
|
:host([kind='insurance']) .box { border-color: ${t.info}; background: ${t.infoSubtle}; }
|
|
@@ -192,7 +216,8 @@ var ImpaktRegulatoryNotice = class extends ImpaktElement {
|
|
|
192
216
|
p { margin: 0; color: ${t.text}; }
|
|
193
217
|
/* Muted text is proved against the card colour, not the notice's, so the firm's line is in the text colour (1.4.3). */
|
|
194
218
|
.firm { margin-block-start: ${space(3)}; ${type("sm")} color: ${t.text}; }
|
|
195
|
-
`
|
|
219
|
+
`
|
|
220
|
+
];
|
|
196
221
|
}
|
|
197
222
|
render() {
|
|
198
223
|
const preset = NOTICE_WORDS[this.kind] ?? NOTICE_WORDS.custom;
|
|
@@ -206,8 +231,17 @@ var ImpaktRegulatoryNotice = class extends ImpaktElement {
|
|
|
206
231
|
}
|
|
207
232
|
};
|
|
208
233
|
var SDLT = {
|
|
209
|
-
standard: [
|
|
210
|
-
|
|
234
|
+
standard: [
|
|
235
|
+
{ from: 0, rate: 0 },
|
|
236
|
+
{ from: 125e3, rate: 2 },
|
|
237
|
+
{ from: 25e4, rate: 5 },
|
|
238
|
+
{ from: 925e3, rate: 10 },
|
|
239
|
+
{ from: 15e5, rate: 12 }
|
|
240
|
+
],
|
|
241
|
+
firstTime: [
|
|
242
|
+
{ from: 0, rate: 0 },
|
|
243
|
+
{ from: 3e5, rate: 5 }
|
|
244
|
+
],
|
|
211
245
|
firstTimeLimit: 5e5,
|
|
212
246
|
additionalSurcharge: 5
|
|
213
247
|
};
|
|
@@ -272,7 +306,11 @@ var ImpaktStampDutyCalculator = class extends ImpaktElement {
|
|
|
272
306
|
render() {
|
|
273
307
|
const duty = stampDuty(this.price, this.buyer);
|
|
274
308
|
const rate = this.price > 0 ? duty / this.price * 100 : 0;
|
|
275
|
-
const buyers = [
|
|
309
|
+
const buyers = [
|
|
310
|
+
["first-time", say("First home")],
|
|
311
|
+
["mover", say("Moving home")],
|
|
312
|
+
["additional", say("Second home")]
|
|
313
|
+
];
|
|
276
314
|
return html`<div class="card wrap" part="wrap">
|
|
277
315
|
<div class="inputs">
|
|
278
316
|
${this.heading ? html`<div class="h" role="heading" aria-level=${this.headingLevel}>${this.heading}</div>` : nothing}
|
|
@@ -281,9 +319,11 @@ var ImpaktStampDutyCalculator = class extends ImpaktElement {
|
|
|
281
319
|
this.price = Number(e.target.value) || 0;
|
|
282
320
|
}} /></div>
|
|
283
321
|
<fieldset><legend>${say("Are you buying")}</legend><div class="choices">
|
|
284
|
-
${buyers.map(
|
|
285
|
-
this.buyer
|
|
286
|
-
|
|
322
|
+
${buyers.map(
|
|
323
|
+
([value, label]) => html`<label><input type="radio" name=${this.id_("buyer")} .checked=${this.buyer === value} @change=${() => {
|
|
324
|
+
this.buyer = value;
|
|
325
|
+
}} />${label}</label>`
|
|
326
|
+
)}
|
|
287
327
|
</div></fieldset>
|
|
288
328
|
</div>
|
|
289
329
|
<div class="result" aria-live="polite">
|
|
@@ -380,7 +420,12 @@ var ImpaktContactBlock = class extends ImpaktElement {
|
|
|
380
420
|
this.spaceBelow = "none";
|
|
381
421
|
}
|
|
382
422
|
static {
|
|
383
|
-
this.styles = [
|
|
423
|
+
this.styles = [
|
|
424
|
+
...ImpaktElement.styles,
|
|
425
|
+
focusRing,
|
|
426
|
+
spaceAround,
|
|
427
|
+
card,
|
|
428
|
+
css`
|
|
384
429
|
:host { display: block; container-type: inline-size; }
|
|
385
430
|
.wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: ${space(6)}; padding: ${space(8)}; }
|
|
386
431
|
.phone { display: inline-block; margin: ${space(3)} 0; font-family: ${t.fontHeading}; ${type("3xl")} font-weight: ${fontWeight("bold")}; color: ${t.link}; text-decoration: none; }
|
|
@@ -392,7 +437,8 @@ var ImpaktContactBlock = class extends ImpaktElement {
|
|
|
392
437
|
input, select { box-sizing: border-box; inline-size: 100%; min-block-size: 44px; padding: ${space(2)} ${space(3)}; font: inherit; color: ${t.text}; background: ${t.surfaceCard}; border: ${t.borderThin} solid ${t.border}; border-radius: ${t.radiusLg}; }
|
|
393
438
|
.done { margin: 0; padding: ${space(5)}; border-radius: ${t.radiusLg}; background: ${t.successSubtle}; color: ${t.successText}; font-weight: ${fontWeight("semibold")}; }
|
|
394
439
|
@container (max-width: 40rem) { .wrap { grid-template-columns: minmax(0, 1fr); padding: ${space(5)}; } }
|
|
395
|
-
`
|
|
440
|
+
`
|
|
441
|
+
];
|
|
396
442
|
}
|
|
397
443
|
submit(event) {
|
|
398
444
|
event.preventDefault();
|
|
@@ -439,4 +485,4 @@ export {
|
|
|
439
485
|
ImpaktAffordabilityCalculator,
|
|
440
486
|
ImpaktContactBlock
|
|
441
487
|
};
|
|
442
|
-
//# sourceMappingURL=chunk-
|
|
488
|
+
//# sourceMappingURL=chunk-TT2PTEQO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/selling.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { say, pageLocale, ImpaktElement, focusRing, targetSize, visuallyHidden, fontWeight, space, spaceAround, t, type } from '@atomic-ui/ui';\n\ntype Space = 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n\nconst card = css`\n .card { background: ${t.surfaceCard}; border-radius: ${t.radiusXl}; box-shadow: ${t.shadowSm}, 0 0 0 1px ${t.hairline}; }\n .h { margin: 0; font-family: ${t.fontHeading}; ${type('2xl')} font-weight: ${fontWeight('bold')}; color: ${t.textHeading}; }\n .btn { display: inline-flex; justify-content: center; align-items: center; min-block-size: 44px; padding: ${space(2.5)} ${space(5)}; font: inherit; font-weight: ${fontWeight('semibold')}; color: ${t.onBrand}; text-decoration: none; background: ${t.brand}; border: 0; border-radius: ${t.radiusLg}; cursor: pointer; }\n .btn:hover { background: ${t.brandHover}; }\n .btn.quiet { color: ${t.link}; background: transparent; box-shadow: inset 0 0 0 ${t.borderThin} ${t.border}; }\n .small { margin: 0; ${type('xs')} color: ${t.textMuted}; }\n .visually-hidden { ${visuallyHidden} }\n`;\n\nconst money = (amount: number, currency = 'GBP', digits = 0) => {\n try {\n return new Intl.NumberFormat(pageLocale(), { style: 'currency', currency, maximumFractionDigits: digits, minimumFractionDigits: digits }).format(amount);\n } catch {\n return String(Math.round(amount));\n }\n};\n\n/** One plan in a comparison. */\nexport interface PlanItem {\n id: string;\n name: string;\n /** The price as shown, such as £12. */\n price: string;\n /** What the price is for, such as `a month`. */\n period?: string;\n note?: string;\n /** The rows this plan has, by their words, separated by commas. */\n includes: string;\n href?: string;\n /** A label such as `Most popular`, which also makes the plan stand out. */\n badge?: string;\n}\n\n/** One line a comparison checks every plan against. */\nexport interface PlanRow {\n id: string;\n label: string;\n}\n\n/**\n * Cover levels side by side, with a tick or a cross for each thing they\n * include and a button under each.\n *\n * A tick is never colour alone: each one says \"Included\" or \"Not included\" to\n * a screen reader. On a narrow screen the plans stack, each with its own list.\n *\n * @fires {CustomEvent<{ plan: PlanItem }>} impakt-select - When a plan is chosen. Cancel it to stay on the page.\n * @category content\n * @icon table\n */\nexport class ImpaktPlanComparison extends ImpaktElement {\n static properties = {\n heading: { type: String },\n plans: { type: Array },\n rows: { type: Array },\n buttonText: { type: String, attribute: 'button-text' },\n headingLevel: { type: Number, attribute: 'heading-level' },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n declare heading: string;\n declare plans: PlanItem[];\n declare rows: PlanRow[];\n declare buttonText: string;\n declare headingLevel: 2 | 3;\n declare spaceAbove: Space;\n declare spaceBelow: Space;\n\n constructor() {\n super();\n this.heading = 'Compare cover';\n this.plans = [];\n this.rows = [];\n this.buttonText = 'Choose';\n this.headingLevel = 2;\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n focusRing,\n targetSize,\n spaceAround,\n card,\n css`\n :host { display: block; container-type: inline-size; }\n .h { margin-block-end: ${space(5)}; }\n .grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: ${space(4)}; }\n .plan { position: relative; display: flex; flex-direction: column; gap: ${space(3)}; padding: ${space(6)}; }\n .plan.top { box-shadow: 0 0 0 2px ${t.brand}, ${t.shadowMd}; }\n .badge { position: absolute; inset-block-start: 0; inset-inline-start: 50%; transform: translate(-50%, -50%); padding: ${space(1)} ${space(3)}; border-radius: 999px; ${type('xs')} font-weight: ${fontWeight('bold')}; color: ${t.onBrand}; background: ${t.brand}; white-space: nowrap; }\n .name { margin: 0; ${type('lg')} font-weight: ${fontWeight('bold')}; color: ${t.text}; }\n .price { margin: 0; font-family: ${t.fontHeading}; ${type('3xl')} font-weight: ${fontWeight('bold')}; color: ${t.text}; }\n .period { ${type('sm')} font-weight: ${fontWeight('regular')}; color: ${t.textMuted}; }\n .note { margin: 0; ${type('sm')} color: ${t.textMuted}; }\n ul { flex: 1; margin: 0; padding: ${space(3)} 0 0; list-style: none; display: grid; gap: ${space(2)}; border-block-start: 1px solid ${t.rule}; align-content: start; }\n li { display: flex; gap: ${space(2)}; ${type('sm')} }\n li[data-has='false'] { color: ${t.textMuted}; }\n .mark { flex-shrink: 0; inline-size: 1.25em; font-weight: ${fontWeight('bold')}; text-align: center; }\n li[data-has='true'] .mark { color: ${t.successText}; }\n @container (max-width: 40rem) { .grid { grid-template-columns: minmax(0, 1fr); gap: ${space(6)}; } }\n `,\n ];\n\n private has(plan: PlanItem, row: PlanRow): boolean {\n return plan.includes\n .split(',')\n .map((s) => s.trim().toLowerCase())\n .includes(row.label.trim().toLowerCase());\n }\n\n private choose(plan: PlanItem, event: Event): void {\n const go = this.dispatchEvent(new CustomEvent('impakt-select', { detail: { plan }, bubbles: true, composed: true, cancelable: true }));\n if (!go) event.preventDefault();\n }\n\n render(): TemplateResult {\n return html`\n ${this.heading ? html`<div class=\"h\" role=\"heading\" aria-level=${this.headingLevel}>${this.heading}</div>` : nothing}\n <div class=\"grid\" style=${`--cols: ${Math.max(1, this.plans.length)}`}>\n ${this.plans.map(\n (p) => html`<section class=\"card plan ${p.badge ? 'top' : ''}\" aria-labelledby=${this.id_(`n-${p.id}`)}>\n ${p.badge ? html`<span class=\"badge\">${p.badge}</span>` : nothing}\n <h3 class=\"name\" id=${this.id_(`n-${p.id}`)}>${p.name}</h3>\n <p class=\"price\">${p.price}${p.period ? html` <span class=\"period\">${p.period}</span>` : nothing}</p>\n ${p.note ? html`<p class=\"note\">${p.note}</p>` : nothing}\n <ul>${this.rows.map((r) => {\n const has = this.has(p, r);\n return html`<li data-has=${String(has)}><span class=\"mark\" aria-hidden=\"true\">${has ? '✓' : '–'}</span><span>${r.label}<span class=\"visually-hidden\">: ${say(has ? 'included' : 'not included')}</span></span></li>`;\n })}</ul>\n ${\n p.href\n ? html`<a class=\"btn ${p.badge ? '' : 'quiet'}\" href=${p.href} @click=${(e: Event) => this.choose(p, e)}>${this.buttonText}<span class=\"visually-hidden\"> ${p.name}</span></a>`\n : html`<button class=\"btn ${p.badge ? '' : 'quiet'}\" type=\"button\" @click=${(e: Event) => this.choose(p, e)}>${this.buttonText}<span class=\"visually-hidden\"> ${p.name}</span></button>`\n }\n </section>`,\n )}\n </div>`;\n }\n}\n\n/** A YouTube or Vimeo address as its privacy-friendly embed, or null for a plain video file. */\nexport function embedOf(src: string, locale?: string): string | null {\n const yt = /(?:youtube\\.com\\/(?:watch\\?v=|embed\\/|shorts\\/)|youtu\\.be\\/)([\\w-]{6,})/.exec(src);\n // The player's own controls and captions in the page's language (ADR 0026).\n const hl =\n locale && !/^en\\b/i.test(locale) ? `&hl=${encodeURIComponent(locale.split('-')[0]!)}&cc_lang_pref=${encodeURIComponent(locale.split('-')[0]!)}` : '';\n if (yt) return `https://www.youtube-nocookie.com/embed/${yt[1]}?autoplay=1&rel=0${hl}`;\n const vimeo = /vimeo\\.com\\/(?:video\\/)?(\\d+)/.exec(src);\n if (vimeo) return `https://player.vimeo.com/video/${vimeo[1]}?autoplay=1&dnt=1`;\n return null;\n}\n\n/**\n * A video, with its title, captions and a transcript link.\n *\n * A YouTube or Vimeo video shows its poster and a Play button first, and only\n * loads the player when pressed, so the page stays fast and nothing is sent to\n * the video site until someone chooses to watch. A video file plays in the\n * browser's own player, with captions from `captions-src`.\n *\n * @category media\n * @icon play\n */\nexport class ImpaktVideo extends ImpaktElement {\n static properties = {\n videoSrc: { type: String, attribute: 'video-src' },\n label: { type: String },\n posterSrc: { type: String, attribute: 'poster-src' },\n captionsSrc: { type: String, attribute: 'captions-src' },\n transcriptHref: { type: String, attribute: 'transcript-href' },\n playText: { type: String, attribute: 'play-text' },\n ratio: { type: String, reflect: true },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n /** A YouTube or Vimeo address, or a video file such as an .mp4. */\n declare videoSrc: string;\n /** What the video is, read out before it plays. */\n declare label: string;\n declare posterSrc: string;\n /** A captions file in WebVTT, for a video file. */\n declare captionsSrc: string;\n declare transcriptHref: string;\n declare playText: string;\n declare ratio: '16:9' | '4:3' | '1:1' | '9:16';\n declare playing: boolean;\n declare spaceAbove: Space;\n declare spaceBelow: Space;\n\n constructor() {\n super();\n this.videoSrc = '';\n this.label = 'Video';\n this.posterSrc = '';\n this.captionsSrc = '';\n this.transcriptHref = '';\n this.playText = 'Play video';\n this.ratio = '16:9';\n this.playing = false;\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n focusRing,\n spaceAround,\n card,\n css`\n :host { display: block; }\n .frame { position: relative; overflow: hidden; aspect-ratio: 16 / 9; border-radius: ${t.radiusXl}; background: #111; }\n :host([ratio='4:3']) .frame { aspect-ratio: 4 / 3; }\n :host([ratio='1:1']) .frame { aspect-ratio: 1; }\n :host([ratio='9:16']) .frame { aspect-ratio: 9 / 16; max-inline-size: 420px; }\n iframe, video, img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; border: 0; object-fit: cover; }\n .play { position: absolute; inset: 0; display: grid; place-items: center; inline-size: 100%; padding: 0; color: #fff; background: linear-gradient(transparent 40%, rgb(0 0 0 / 0.55)); border: 0; cursor: pointer; }\n .disc { display: grid; place-items: center; inline-size: 72px; block-size: 72px; border-radius: 50%; background: ${t.brand}; box-shadow: ${t.shadowLg}; }\n /* Held inside the frame at both edges, so loosened or long words wrap rather than run out of it (1.4.12). */\n .label { position: absolute; inset-inline: ${space(5)}; inset-block-end: ${space(4)}; ${type('lg')} font-weight: ${fontWeight('semibold')}; text-align: start; }\n .foot { margin: ${space(2)} 0 0; ${type('sm')} }\n .foot a { color: ${t.link}; }\n .empty { display: grid; place-items: center; block-size: 100%; color: #ccc; }\n `,\n ];\n\n render(): TemplateResult {\n const embed = embedOf(this.videoSrc, pageLocale(this));\n let player: TemplateResult;\n if (!this.videoSrc) player = html`<div class=\"empty\">${say('Add a video address')}</div>`;\n else if (embed && this.playing)\n player = html`<iframe src=${embed} title=${this.label} allow=\"autoplay; encrypted-media; picture-in-picture; fullscreen\" allowfullscreen></iframe>`;\n else if (embed)\n player = html`${this.posterSrc ? html`<img src=${this.posterSrc} alt=\"\" />` : nothing}\n <button class=\"play\" type=\"button\" @click=${() => {\n this.playing = true;\n }}>\n <span class=\"disc\" aria-hidden=\"true\"><svg width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\"/></svg></span>\n <span class=\"label\">${this.playText}<span class=\"visually-hidden\">: ${this.label}</span></span>\n </button>`;\n else\n player = html`<video controls preload=\"metadata\" poster=${this.posterSrc || nothing} aria-label=${this.label}>\n <source src=${this.videoSrc} />\n ${this.captionsSrc ? html`<track kind=\"captions\" src=${this.captionsSrc} srclang=\"en\" label=\"English\" default />` : nothing}\n </video>`;\n return html`<div class=\"frame\" part=\"frame\">${player}</div>\n ${this.transcriptHref ? html`<p class=\"foot\"><a href=${this.transcriptHref}>${say('Read the transcript')}<span class=\"visually-hidden\">${say(' of {video}', { video: this.label })}</span></a></p>` : nothing}`;\n }\n}\n\nconst NOTICE_WORDS: Record<string, { heading: string; text: string }> = {\n mortgage: { heading: 'Your home may be repossessed', text: 'Your home may be repossessed if you do not keep up repayments on your mortgage.' },\n 'secured-loan': {\n heading: 'Think carefully before securing other debts against your home',\n text: 'Your home may be repossessed if you do not keep up repayments on a mortgage or any other debt secured on it.',\n },\n investment: { heading: 'Capital at risk', text: 'The value of investments can go down as well as up, and you may get back less than you put in.' },\n insurance: { heading: 'Important information', text: 'Read the policy documents to check the cover suits your needs. Limits and exclusions apply.' },\n custom: { heading: '', text: '' },\n};\n\n/**\n * The warning and the regulator wording a financial page must carry, as a\n * block of its own so it is never left off.\n *\n * Pick the kind to start from the usual words, or `custom` to write your own.\n * Whatever it says, check it with whoever signs off your financial promotions.\n *\n * @category feedback\n * @icon shield\n */\nexport class ImpaktRegulatoryNotice extends ImpaktElement {\n static properties = {\n kind: { type: String, reflect: true },\n heading: { type: String },\n text: { type: String },\n firm: { type: String },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n declare kind: 'mortgage' | 'secured-loan' | 'investment' | 'insurance' | 'custom';\n /** Leave empty to use the usual heading for the kind. */\n declare heading: string;\n /** Leave empty to use the usual warning for the kind. */\n declare text: string;\n /** Who you are and who regulates you, such as \"Acme Ltd is authorised and regulated by the Financial Conduct Authority (FRN 123456).\" */\n declare firm: string;\n declare spaceAbove: Space;\n declare spaceBelow: Space;\n\n constructor() {\n super();\n this.kind = 'mortgage';\n this.heading = '';\n this.text = '';\n this.firm = '';\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n spaceAround,\n css`\n :host { display: block; }\n .box { padding: ${space(5)}; border-inline-start: 6px solid ${t.warning}; border-radius: ${t.radiusLg}; background: ${t.warningSubtle}; }\n :host([kind='insurance']) .box { border-color: ${t.info}; background: ${t.infoSubtle}; }\n strong { display: block; margin-block-end: ${space(1)}; ${type('md')} color: ${t.text}; }\n p { margin: 0; color: ${t.text}; }\n /* Muted text is proved against the card colour, not the notice's, so the firm's line is in the text colour (1.4.3). */\n .firm { margin-block-start: ${space(3)}; ${type('sm')} color: ${t.text}; }\n `,\n ];\n\n render(): TemplateResult {\n const preset = NOTICE_WORDS[this.kind] ?? NOTICE_WORDS.custom!;\n const heading = this.heading || (preset.heading ? say(preset.heading) : '');\n const text = this.text || (preset.text ? say(preset.text) : '');\n return html`<aside class=\"box\" part=\"box\" aria-label=${heading || say('Important information')}>\n ${heading ? html`<strong>${heading}</strong>` : nothing}\n ${text ? html`<p>${text}</p>` : nothing}\n ${this.firm ? html`<p class=\"firm\">${this.firm}</p>` : nothing}\n </aside>`;\n }\n}\n\n/** One band of a tax: everything above `from` and up to the next band's `from` is charged at `rate`. */\ninterface Band {\n from: number;\n rate: number;\n}\n\n/**\n * Stamp Duty Land Tax for England and Northern Ireland, from 1 April 2025.\n * Exported so the numbers can be checked, and changed in one place.\n */\nexport const SDLT = {\n standard: [\n { from: 0, rate: 0 },\n { from: 125000, rate: 2 },\n { from: 250000, rate: 5 },\n { from: 925000, rate: 10 },\n { from: 1500000, rate: 12 },\n ] as Band[],\n firstTime: [\n { from: 0, rate: 0 },\n { from: 300000, rate: 5 },\n ] as Band[],\n firstTimeLimit: 500000,\n additionalSurcharge: 5,\n};\n\nfunction taxOn(price: number, bands: Band[], extra = 0): number {\n let tax = 0;\n bands.forEach((band, i) => {\n const top = bands[i + 1]?.from ?? Infinity;\n if (price > band.from) tax += ((Math.min(price, top) - band.from) * (band.rate + extra)) / 100;\n });\n return Math.round(tax);\n}\n\n/** The stamp duty on a home, for a mover, a first-time buyer or a second home. */\nexport function stampDuty(price: number, buyer: 'mover' | 'first-time' | 'additional'): number {\n if (price <= 0) return 0;\n if (buyer === 'first-time' && price <= SDLT.firstTimeLimit) return taxOn(price, SDLT.firstTime);\n if (buyer === 'additional') return price < 40000 ? 0 : taxOn(price, SDLT.standard, SDLT.additionalSurcharge);\n return taxOn(price, SDLT.standard);\n}\n\nconst calcStyles = css`\n :host { display: block; container-type: inline-size; }\n .wrap { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); overflow: hidden; }\n .inputs { display: flex; flex-direction: column; gap: ${space(5)}; padding: ${space(8)}; }\n label, legend { display: block; ${type('sm')} font-weight: ${fontWeight('semibold')}; margin-block-end: ${space(1.5)}; padding: 0; }\n fieldset { margin: 0; padding: 0; border: 0; }\n .choices { display: flex; flex-wrap: wrap; gap: ${space(2)}; }\n .choices label { display: inline-flex; align-items: center; gap: ${space(2)}; margin: 0; padding: ${space(2)} ${space(3)}; font-weight: ${fontWeight('regular')}; border: ${t.borderThin} solid ${t.border}; border-radius: ${t.radiusLg}; cursor: pointer; }\n .choices input { accent-color: ${t.brand}; }\n input[type='number'] { box-sizing: border-box; inline-size: 100%; min-block-size: 44px; padding: ${space(2)} ${space(3)}; font: inherit; color: ${t.text}; background: ${t.surfaceCard}; border: ${t.borderThin} solid ${t.border}; border-radius: ${t.radiusLg}; }\n .result { display: flex; flex-direction: column; justify-content: center; gap: ${space(2)}; padding: ${space(8)}; color: ${t.onBrand}; background: ${t.brand}; }\n .caption { margin: 0; ${type('sm')} opacity: 0.85; }\n output { display: block; font-family: ${t.fontHeading}; ${type('4xl')} font-weight: ${fontWeight('bold')}; }\n .line { margin: 0; ${type('sm')} }\n .foot { grid-column: 1 / -1; padding: ${space(4)} ${space(8)}; background: ${t.surfaceSubtle}; }\n /* Muted text is proved against the card colour, not this band, so the small print here is in the text colour (1.4.3). */\n .foot .small { color: ${t.text}; }\n @container (max-width: 44rem) { .wrap { grid-template-columns: minmax(0, 1fr); } .inputs, .result { padding: ${space(5)}; } .foot { padding: ${space(4)} ${space(5)}; } }\n`;\n\n/**\n * How much stamp duty a home would cost, for a home mover, a first-time buyer\n * or a second home, worked out as the price is typed.\n *\n * The rates are England and Northern Ireland's from 1 April 2025. Scotland and\n * Wales have their own taxes, and rates change, so the small print says which\n * rates these are and points to GOV.UK.\n *\n * @category form\n * @icon pound\n */\nexport class ImpaktStampDutyCalculator extends ImpaktElement {\n static properties = {\n heading: { type: String },\n price: { type: Number },\n buyer: { type: String },\n smallPrint: { type: String, attribute: 'small-print' },\n headingLevel: { type: Number, attribute: 'heading-level' },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n declare heading: string;\n declare price: number;\n declare buyer: 'mover' | 'first-time' | 'additional';\n declare smallPrint: string;\n declare headingLevel: 2 | 3;\n declare spaceAbove: Space;\n declare spaceBelow: Space;\n\n constructor() {\n super();\n this.heading = 'How much stamp duty would you pay?';\n this.price = 385000;\n this.buyer = 'first-time';\n this.smallPrint =\n 'Based on Stamp Duty Land Tax rates in England and Northern Ireland from 1 April 2025. Scotland and Wales have their own taxes. Check what you would pay on GOV.UK.';\n this.headingLevel = 2;\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [...ImpaktElement.styles, focusRing, spaceAround, card, calcStyles];\n\n render(): TemplateResult {\n const duty = stampDuty(this.price, this.buyer);\n const rate = this.price > 0 ? (duty / this.price) * 100 : 0;\n const buyers: [typeof this.buyer, string][] = [\n ['first-time', say('First home')],\n ['mover', say('Moving home')],\n ['additional', say('Second home')],\n ];\n return html`<div class=\"card wrap\" part=\"wrap\">\n <div class=\"inputs\">\n ${this.heading ? html`<div class=\"h\" role=\"heading\" aria-level=${this.headingLevel}>${this.heading}</div>` : nothing}\n <div><label for=${this.id_('price')}>${say('Price of the home (£)')}</label>\n <input id=${this.id_('price')} type=\"number\" min=\"0\" step=\"1000\" inputmode=\"numeric\" .value=${String(this.price)} @input=${(e: Event) => {\n this.price = Number((e.target as HTMLInputElement).value) || 0;\n }} /></div>\n <fieldset><legend>${say('Are you buying')}</legend><div class=\"choices\">\n ${buyers.map(\n ([value, label]) =>\n html`<label><input type=\"radio\" name=${this.id_('buyer')} .checked=${this.buyer === value} @change=${() => {\n this.buyer = value;\n }} />${label}</label>`,\n )}\n </div></fieldset>\n </div>\n <div class=\"result\" aria-live=\"polite\">\n <p class=\"caption\">${say('Stamp duty to pay')}</p>\n <output for=${this.id_('price')}>${money(duty)}</output>\n <p class=\"line\">${duty ? say('About {rate}% of the price', { rate: rate.toFixed(1) }) : say('Nothing to pay at this price')}</p>\n ${this.buyer === 'first-time' && this.price > SDLT.firstTimeLimit ? html`<p class=\"line\">${say('First-time buyer relief stops above {limit}, so the usual rates apply.', { limit: money(SDLT.firstTimeLimit) })}</p>` : nothing}\n </div>\n ${this.smallPrint ? html`<div class=\"foot\"><p class=\"small\">${this.smallPrint}</p></div>` : nothing}\n </div>`;\n }\n}\n\n/**\n * Roughly how much someone could borrow, from what they earn, and the price\n * of home that buys with their deposit.\n *\n * Lenders usually lend four to four and a half times income; the multiple is\n * a setting. It is a guide, not an offer, and the small print says so.\n *\n * @category form\n * @icon pound\n */\nexport class ImpaktAffordabilityCalculator extends ImpaktElement {\n static properties = {\n heading: { type: String },\n income: { type: Number },\n secondIncome: { type: Number, attribute: 'second-income' },\n deposit: { type: Number },\n timesIncome: { type: Number, attribute: 'times-income' },\n smallPrint: { type: String, attribute: 'small-print' },\n headingLevel: { type: Number, attribute: 'heading-level' },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n declare heading: string;\n declare income: number;\n declare secondIncome: number;\n declare deposit: number;\n /** How many times income a lender would lend, such as 4.5. */\n declare timesIncome: number;\n declare smallPrint: string;\n declare headingLevel: 2 | 3;\n declare spaceAbove: Space;\n declare spaceBelow: Space;\n\n constructor() {\n super();\n this.heading = 'How much could you borrow?';\n this.income = 45000;\n this.secondIncome = 0;\n this.deposit = 30000;\n this.timesIncome = 4.5;\n this.smallPrint =\n 'This is a guide, not a mortgage offer. What a lender offers depends on your circumstances. Your home may be repossessed if you do not keep up repayments on your mortgage.';\n this.headingLevel = 2;\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [...ImpaktElement.styles, focusRing, spaceAround, card, calcStyles];\n\n private field(key: 'income' | 'secondIncome' | 'deposit'): (event: Event) => void {\n return (event) => {\n this[key] = Number((event.target as HTMLInputElement).value) || 0;\n };\n }\n\n render(): TemplateResult {\n const borrow = Math.max(0, (this.income + this.secondIncome) * this.timesIncome);\n const input = (key: 'income' | 'secondIncome' | 'deposit', label: string) => html`<div><label for=${this.id_(key)}>${label}</label>\n <input id=${this.id_(key)} type=\"number\" min=\"0\" step=\"1000\" inputmode=\"numeric\" .value=${String(this[key])} @input=${this.field(key)} /></div>`;\n return html`<div class=\"card wrap\" part=\"wrap\">\n <div class=\"inputs\">\n ${this.heading ? html`<div class=\"h\" role=\"heading\" aria-level=${this.headingLevel}>${this.heading}</div>` : nothing}\n ${input('income', say('Your yearly income before tax (£)'))}\n ${input('secondIncome', say('A second person’s income, if buying together (£)'))}\n ${input('deposit', say('Your deposit (£)'))}\n </div>\n <div class=\"result\" aria-live=\"polite\">\n <p class=\"caption\">${say('You could borrow about')}</p>\n <output>${money(borrow)}</output>\n <p class=\"line\">${say('With your deposit, that’s a home of about {amount}.', { amount: money(borrow + this.deposit) })}</p>\n </div>\n ${this.smallPrint ? html`<div class=\"foot\"><p class=\"small\">${this.smallPrint}</p></div>` : nothing}\n </div>`;\n }\n}\n\n/**\n * How to get in touch: a phone number, opening hours, an email address, and a\n * short form to ask for a call back.\n *\n * The form fires `impakt-submit` with the name, phone number and best time; the\n * app sends it on. Then the block thanks them in place.\n *\n * @fires {CustomEvent<{ name: string; phone: string; when: string }>} impakt-submit - When the form is sent.\n * @category content\n * @icon phone\n */\nexport class ImpaktContactBlock extends ImpaktElement {\n static properties = {\n heading: { type: String },\n phone: { type: String },\n hours: { type: String },\n email: { type: String },\n callbackHeading: { type: String, attribute: 'callback-heading' },\n buttonText: { type: String, attribute: 'button-text' },\n doneText: { type: String, attribute: 'done-text' },\n headingLevel: { type: Number, attribute: 'heading-level' },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n declare heading: string;\n declare phone: string;\n /** One line a day or range, such as \"Monday to Friday, 9am to 6pm\". */\n declare hours: string;\n declare email: string;\n /** Leave empty to show no call back form. */\n declare callbackHeading: string;\n declare buttonText: string;\n declare doneText: string;\n declare headingLevel: 2 | 3;\n declare sent: boolean;\n declare spaceAbove: Space;\n declare spaceBelow: Space;\n\n constructor() {\n super();\n this.heading = 'Talk to us';\n this.phone = '0800 000 0000';\n this.hours = 'Monday to Friday, 9am to 6pm\\nSaturday, 10am to 2pm';\n this.email = '';\n this.callbackHeading = 'Or we can call you';\n this.buttonText = 'Ask for a call back';\n this.doneText = 'Thanks. We’ll call you at the time you chose.';\n this.headingLevel = 2;\n this.sent = false;\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n focusRing,\n spaceAround,\n card,\n css`\n :host { display: block; container-type: inline-size; }\n .wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: ${space(6)}; padding: ${space(8)}; }\n .phone { display: inline-block; margin: ${space(3)} 0; font-family: ${t.fontHeading}; ${type('3xl')} font-weight: ${fontWeight('bold')}; color: ${t.link}; text-decoration: none; }\n .hours { margin: 0; white-space: pre-line; color: ${t.textMuted}; }\n .email { display: inline-flex; align-items: center; min-block-size: ${t.targetMin}; margin-block-start: ${space(3)}; color: ${t.link}; overflow-wrap: anywhere; }\n form { display: grid; gap: ${space(3)}; padding: ${space(5)}; border-radius: ${t.radiusLg}; background: ${t.surfaceInset}; }\n .sub { margin: 0; ${type('lg')} font-weight: ${fontWeight('bold')}; color: ${t.text}; }\n label { display: block; ${type('sm')} font-weight: ${fontWeight('semibold')}; margin-block-end: ${space(1)}; }\n input, select { box-sizing: border-box; inline-size: 100%; min-block-size: 44px; padding: ${space(2)} ${space(3)}; font: inherit; color: ${t.text}; background: ${t.surfaceCard}; border: ${t.borderThin} solid ${t.border}; border-radius: ${t.radiusLg}; }\n .done { margin: 0; padding: ${space(5)}; border-radius: ${t.radiusLg}; background: ${t.successSubtle}; color: ${t.successText}; font-weight: ${fontWeight('semibold')}; }\n @container (max-width: 40rem) { .wrap { grid-template-columns: minmax(0, 1fr); padding: ${space(5)}; } }\n `,\n ];\n\n private submit(event: SubmitEvent): void {\n event.preventDefault();\n const form = new FormData(event.target as HTMLFormElement);\n const data = { name: String(form.get('name') ?? ''), phone: String(form.get('phone') ?? ''), when: String(form.get('when') ?? '') };\n this.dispatchEvent(new CustomEvent('impakt-submit', { detail: data, bubbles: true, composed: true }));\n this.sent = true;\n }\n\n render(): TemplateResult {\n return html`<div class=\"card wrap\" part=\"wrap\">\n <div>\n ${this.heading ? html`<div class=\"h\" role=\"heading\" aria-level=${this.headingLevel}>${this.heading}</div>` : nothing}\n ${this.phone ? html`<a class=\"phone\" href=${`tel:${this.phone.replace(/[^\\d+]/g, '')}`}>${this.phone}</a>` : nothing}\n ${this.hours ? html`<p class=\"hours\">${this.hours}</p>` : nothing}\n ${this.email ? html`<a class=\"email\" href=${`mailto:${this.email}`}>${this.email}</a>` : nothing}\n </div>\n ${\n !this.callbackHeading\n ? nothing\n : this.sent\n ? html`<p class=\"done\" role=\"status\">${this.doneText}</p>`\n : html`<form @submit=${this.submit} aria-labelledby=${this.id_('cb')}>\n <p class=\"sub\" id=${this.id_('cb')}>${this.callbackHeading}</p>\n <div><label for=${this.id_('name')}>${say('Your name')}</label><input id=${this.id_('name')} name=\"name\" autocomplete=\"name\" required /></div>\n <div><label for=${this.id_('tel')}>${say('Phone number')}</label><input id=${this.id_('tel')} name=\"phone\" type=\"tel\" autocomplete=\"tel\" required /></div>\n <div><label for=${this.id_('when')}>${say('Best time to call')}</label><select id=${this.id_('when')} name=\"when\"><option value=\"Morning\">${say('Morning')}</option><option value=\"Afternoon\">${say('Afternoon')}</option><option value=\"Evening\">${say('Evening')}</option></select></div>\n <button class=\"btn\" type=\"submit\">${this.buttonText}</button>\n </form>`\n }\n </div>`;\n }\n}\n\n// Working values, not settings: kept out of `properties` so the page designer does not offer them.\nImpaktVideo.createProperty('playing', { state: true });\nImpaktContactBlock.createProperty('sent', { state: true });\n\ncustomElements.define('impakt-plan-comparison', ImpaktPlanComparison);\ncustomElements.define('impakt-video', ImpaktVideo);\ncustomElements.define('impakt-regulatory-notice', ImpaktRegulatoryNotice);\ncustomElements.define('impakt-stamp-duty-calculator', ImpaktStampDutyCalculator);\ncustomElements.define('impakt-affordability-calculator', ImpaktAffordabilityCalculator);\ncustomElements.define('impakt-contact-block', ImpaktContactBlock);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-plan-comparison': ImpaktPlanComparison;\n 'impakt-video': ImpaktVideo;\n 'impakt-regulatory-notice': ImpaktRegulatoryNotice;\n 'impakt-stamp-duty-calculator': ImpaktStampDutyCalculator;\n 'impakt-affordability-calculator': ImpaktAffordabilityCalculator;\n 'impakt-contact-block': ImpaktContactBlock;\n }\n}\n"],"mappings":";AAAA,SAAS,KAAK,MAAM,eAAoC;AACxD,SAAS,KAAK,YAAY,eAAe,WAAW,YAAY,gBAAgB,YAAY,OAAO,aAAa,GAAG,YAAY;AAI/H,IAAM,OAAO;AAAA,wBACW,EAAE,WAAW,oBAAoB,EAAE,QAAQ,iBAAiB,EAAE,QAAQ,eAAe,EAAE,QAAQ;AAAA,iCACtF,EAAE,WAAW,KAAK,KAAK,KAAK,CAAC,iBAAiB,WAAW,MAAM,CAAC,YAAY,EAAE,WAAW;AAAA,8GACZ,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,iCAAiC,WAAW,UAAU,CAAC,YAAY,EAAE,OAAO,wCAAwC,EAAE,KAAK,+BAA+B,EAAE,QAAQ;AAAA,6BAC3Q,EAAE,UAAU;AAAA,wBAC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,IAAI,cAAc,CAAC,qBAAqB,KAAK,IAAI,KAAK,CAAC;AAAA,0BAC1E,KAAK,IAAI,MAAM,CAAC,IAAI,IAAI,mBAAmB,CAAC,sBAAsB,KAAK,IAAI,MAAM,CAAC,wCAAwC,IAAI,SAAS,CAAC,sCAAsC,IAAI,WAAW,CAAC,oCAAoC,IAAI,SAAS,CAAC;AAAA,4CAC9N,KAAK,UAAU;AAAA,cAErD;AAAA;AAAA,EAEJ;AACF;AAGA,YAAY,eAAe,WAAW,EAAE,OAAO,KAAK,CAAC;AACrD,mBAAmB,eAAe,QAAQ,EAAE,OAAO,KAAK,CAAC;AAEzD,eAAe,OAAO,0BAA0B,oBAAoB;AACpE,eAAe,OAAO,gBAAgB,WAAW;AACjD,eAAe,OAAO,4BAA4B,sBAAsB;AACxE,eAAe,OAAO,gCAAgC,yBAAyB;AAC/E,eAAe,OAAO,mCAAmC,6BAA6B;AACtF,eAAe,OAAO,wBAAwB,kBAAkB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/scene.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult, type PropertyValues } from 'lit';\nimport { say, ImpaktElement, fontSize, fontWeight, space, t, token } from '@atomic-ui/ui';\n\nexport type SceneDrive = 'view' | 'page' | 'loop' | 'scrubber';\nexport type SceneLayout = 'stage' | 'split';\n\nconst clamp = (n: number) => Math.min(1, Math.max(0, n));\n\n/**\n * A scene: a stage whose children move along a progress from 0 to 1.\n *\n * The children declare timelines in their `motion` block, and `@atomic-ui/motion`\n * compiles them to keyframes. This element owns only the progress, and where it\n * comes from is the `drive` (ADR 0027):\n *\n * - `view` — the scene's own passage through the viewport. The stage pins\n * while the scene scrolls past, for `length` screens, or beside the content\n * in the default slot when `layout` is `split`.\n * - `page` — the scroll position of the whole page.\n * - `loop` — time, over `duration` seconds, repeating. **It always shows a\n * pause button**, because anything that moves on its own for more than five\n * seconds must be pausable (WCAG 2.2.2), and a scene that could forget that\n * is one the gate would have to catch on every page.\n * - `scrubber` — an `impakt-scrubber` placed in the `controls` slot.\n *\n * Progress is published three ways: the `progress` property, the\n * `--impakt-scene-progress` custom property on the host, and an\n * `impakt-scene-progress` event. Engines with scroll-driven animations run `view`\n * and `page` scenes natively, and the runtime ignores the event for them.\n *\n * Under reduced motion a `loop` does not start, and nothing pins: the stage\n * and the content stack, so every state of the scene can be read in order.\n *\n * @category layout\n * @icon layers\n * @slot stage - What moves, layered one over another. Pinned while the scene plays,\n * beside the content in `split` layout, after it, so the words are read first.\n * @slot - Content that scrolls past the stage, such as chapters.\n * @slot controls - An `impakt-scrubber`, for a scene driven by one.\n * @fires {CustomEvent<{ progress: number }>} impakt-scene-progress - `{ progress }` whenever the progress changes.\n */\nexport class ImpaktScene extends ImpaktElement {\n static properties = {\n drive: { type: String, reflect: true },\n layout: { type: String, reflect: true },\n length: { type: Number },\n duration: { type: Number },\n label: { type: String },\n progress: { type: Number },\n controls: { type: String, reflect: true },\n bleed: { type: Boolean, reflect: true },\n hideOn: { type: String, reflect: true, attribute: 'hide-on' },\n };\n\n /** Where the progress comes from. */\n declare drive: 'view' | 'page' | 'loop' | 'scrubber';\n /** `stage` pins one full-width stage; `split` pins it beside the content. */\n declare layout: 'stage' | 'split';\n /** How many screens of scrolling a `view` scene lasts, in `stage` layout. */\n declare length: number;\n /** Seconds per cycle of a `loop` scene. */\n declare duration: number;\n /** The scene's accessible name. Also names its pause button. */\n declare label: string;\n /** From 0 to 1. Set it to seek a `scrubber` scene, or where one starts. */\n declare progress: number;\n /**\n * Where the controls sit: `below` the stage, or `over` its foot, floating\n * on what it shows, as a video's do. Under reduced motion they sit below.\n */\n declare controls: 'below' | 'over';\n /** Run the stage to the window's edges, past the page's margins, as a hero drawn edge to edge does. */\n declare bleed: boolean;\n /**\n * Leave it out on a phone, or on anything wider, for a picture drawn twice:\n * once for a wide screen and once for a narrow one. Never both.\n */\n declare hideOn: 'never' | 'phone' | 'wide';\n /**\n * Whether a loop is paused: the scene's own state, set by its pause button\n * or by `pause()`. A plain field rather than a property, so it is never one\n * of the settings an author is offered.\n */\n private paused = false;\n\n private frame = 0;\n private started = 0;\n private reduced = false;\n private seekFrom = 0;\n private seekTo = 0;\n private seekStart = 0;\n private seekMs = 0;\n\n constructor() {\n super();\n this.drive = 'view';\n this.layout = 'stage';\n this.length = 3;\n this.duration = 8;\n this.label = 'Animation';\n this.progress = 0;\n this.controls = 'below';\n this.bleed = false;\n this.hideOn = 'never';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n css`\n :host {\n display: block;\n position: relative;\n }\n :host([drive='view'][layout='stage']) {\n min-height: calc(var(--impakt-scene-length, 3) * 100svh);\n }\n .frame {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n }\n :host([layout='split']) .frame {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: ${space(8)};\n }\n .stage {\n position: sticky;\n top: 0;\n height: 100svh;\n display: grid;\n place-items: center;\n overflow: clip;\n }\n /* What is on the stage is layered, as in a motion tool: each thing sits\n over the one before, so a later layer's timeline can reveal it over an\n earlier one. */\n .stage ::slotted(*) {\n grid-area: 1 / 1;\n max-width: 100%;\n }\n :host([drive='loop']) .stage,\n :host([drive='scrubber']) .stage {\n position: relative;\n height: auto;\n min-height: 60svh;\n }\n .controls {\n display: flex;\n gap: ${space(3)};\n align-items: center;\n justify-content: center;\n padding-block: ${space(3)};\n }\n :host([bleed]) { margin-inline: calc(50% - 50vw); }\n @media (max-width: 40rem) { :host([hide-on='phone']) { display: none; } }\n @media (min-width: 40.0625rem) { :host([hide-on='wide']) { display: none; } }\n /* Over the stage, the controls float at its foot, above the layers and clear of its edges. */\n .stage > .controls { position: absolute; inset-inline: ${space(6)}; inset-block-end: ${space(6)}; z-index: 2; padding: 0; }\n .stage > .controls ::slotted(*) { box-shadow: 0 12px 32px rgb(16 19 23 / 14%); border-radius: 16px; background: var(--impakt-color-surface-card, #fff); }\n /* A control takes the row, so a graph scrubber spans the stage; a narrower one centres itself. */\n .controls ::slotted(*) { flex: 1 1 auto; min-width: 0; }\n .pause {\n min-width: ${token('target.min', '24px')};\n min-height: ${token('target.min', '24px')};\n padding: ${space(2)} ${space(4)};\n border-radius: ${token('radius.full', '9999px')};\n border: 1px solid ${t.border};\n background: ${t.surfaceCard};\n color: ${t.text};\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('medium')};\n cursor: pointer;\n }\n .pause:focus-visible {\n outline: none;\n box-shadow: ${token('focus.ring.shadow', '0 0 0 2px #fff, 0 0 0 4px #1a1a1a')};\n }\n @media (max-width: 48rem) {\n :host([layout='split']) .frame {\n grid-template-columns: minmax(0, 1fr);\n }\n :host([layout='split']) .stage {\n height: 50svh;\n z-index: 1;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n min-height: 0 !important;\n }\n .stage {\n position: relative;\n height: auto;\n gap: ${space(6)};\n }\n /* With less motion the layers are shown one after another, so every\n state the scene would have moved through can still be seen. */\n .stage ::slotted(*) {\n grid-area: auto;\n }\n }\n `,\n ];\n\n /** @ignore */\n connectedCallback(): void {\n super.connectedCallback();\n try {\n this.reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n } catch {\n this.reduced = false;\n }\n window.addEventListener('scroll', this.onScroll, { passive: true, capture: true });\n window.addEventListener('resize', this.onScroll);\n this.schedule();\n }\n\n /** @ignore */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener('scroll', this.onScroll, { capture: true });\n window.removeEventListener('resize', this.onScroll);\n if (this.frame) cancelAnimationFrame(this.frame);\n this.frame = 0;\n }\n\n /** @ignore */\n protected updated(changed: PropertyValues<this>): void {\n if (changed.has('length')) this.style.setProperty('--impakt-scene-length', String(this.length));\n if (changed.has('progress')) this.publish();\n if (changed.has('drive')) {\n this.started = 0;\n this.schedule();\n }\n }\n\n /**\n * Move to a progress. With `ms`, ease there; without, jump. A scrubber seeks\n * a scene to a named stop this way.\n */\n seek(to: number, ms = 0): void {\n if (ms <= 0 || this.reduced) {\n this.progress = clamp(to);\n return;\n }\n this.seekFrom = this.progress;\n this.seekTo = clamp(to);\n this.seekStart = 0;\n this.seekMs = ms;\n this.schedule();\n }\n\n private onScroll = () => {\n if (this.drive === 'view' || this.drive === 'page') this.schedule();\n };\n\n private schedule(): void {\n if (!this.frame && typeof requestAnimationFrame === 'function') this.frame = requestAnimationFrame(this.tick);\n }\n\n private tick = (now: number) => {\n this.frame = 0;\n if (this.seekMs) {\n if (!this.seekStart) this.seekStart = now;\n const p = Math.min(1, (now - this.seekStart) / this.seekMs);\n // ease-in-out, so a jump between stops reads as travel rather than a cut\n const e = p < 0.5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;\n this.progress = this.seekFrom + (this.seekTo - this.seekFrom) * e;\n if (p < 1) this.schedule();\n else this.seekMs = 0;\n return;\n }\n if (this.drive === 'view') {\n const r = this.getBoundingClientRect();\n const vh = window.innerHeight || 1;\n this.progress = clamp(-r.top / Math.max(1, r.height - vh));\n } else if (this.drive === 'page') {\n const doc = document.documentElement;\n this.progress = clamp(window.scrollY / Math.max(1, doc.scrollHeight - (window.innerHeight || 0)));\n } else if (this.drive === 'loop' && !this.paused && !this.reduced) {\n if (!this.started) this.started = now - this.progress * this.duration * 1000;\n this.progress = ((now - this.started) / (this.duration * 1000)) % 1;\n this.schedule();\n }\n };\n\n private publish(): void {\n this.style.setProperty('--impakt-scene-progress', this.progress.toFixed(4));\n this.dispatchEvent(new CustomEvent('impakt-scene-progress', { detail: { progress: this.progress }, bubbles: true, composed: true }));\n }\n\n private setPaused(paused: boolean): void {\n if (this.paused === paused) return;\n this.paused = paused;\n this.started = 0;\n this.schedule();\n this.requestUpdate();\n }\n\n private togglePause = () => this.setPaused(!this.paused);\n\n /** Stop a loop where it is, as its pause button does. An editor scrubbing the scene calls it. */\n pause(): void {\n this.setPaused(true);\n }\n\n render(): TemplateResult {\n const loop = this.drive === 'loop';\n const over = this.controls === 'over' && !this.reduced;\n const controls = html`<div class=\"controls\" part=\"controls\">\n <slot name=\"controls\"></slot>\n ${loop && !this.reduced\n ? html`<button class=\"pause\" type=\"button\" aria-pressed=${this.paused ? 'true' : 'false'} @click=${this.togglePause}>\n ${this.paused ? say('Play {name}', { name: this.label }) : say('Pause {name}', { name: this.label })}\n </button>`\n : nothing}\n </div>`;\n const stage = html`<div class=\"stage\" part=\"stage\"><slot name=\"stage\"></slot>${over ? controls : nothing}</div>`;\n return html`\n <div class=\"frame\" part=\"frame\" role=\"region\" aria-label=${this.label}>\n ${this.layout === 'split'\n ? html`<div class=\"content\" part=\"content\"><slot></slot></div>${stage}`\n : html`${stage}<div class=\"content\" part=\"content\"><slot></slot></div>`}\n </div>\n ${over ? nothing : controls}\n `;\n }\n}\n\ncustomElements.define('impakt-scene', ImpaktScene);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-scene': ImpaktScene }\n}\n"],"mappings":";AAAA,SAAS,MAAM,KAAK,eAAyD;AAC7E,SAAS,KAAK,eAAe,UAAU,YAAY,OAAO,GAAG,aAAa;AAK1E,IAAM,QAAQ,CAAC,MAAc,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AAmChD,IAAM,cAAN,cAA0B,cAAc;AAAA,EAoD7C,cAAc;AACZ,UAAM;AAXR;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,SAAS;AAEjB,SAAQ,QAAQ;AAChB,SAAQ,UAAU;AAClB,SAAQ,UAAU;AAClB,SAAQ,WAAW;AACnB,SAAQ,SAAS;AACjB,SAAQ,YAAY;AACpB,SAAQ,SAAS;AAgKjB,SAAQ,WAAW,MAAM;AACvB,UAAI,KAAK,UAAU,UAAU,KAAK,UAAU,OAAQ,MAAK,SAAS;AAAA,IACpE;AAMA,SAAQ,OAAO,CAAC,QAAgB;AAC9B,WAAK,QAAQ;AACb,UAAI,KAAK,QAAQ;AACf,YAAI,CAAC,KAAK,UAAW,MAAK,YAAY;AACtC,cAAM,IAAI,KAAK,IAAI,IAAI,MA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C,KAAK,SAAS,OAAO,0BAA0B,WAAY,MAAK,QAAQ,sBAAsB,KAAK,IAAI;AAAA,EAC9G;AAAA,EA4BQ,UAAgB;AACtB,SAAK,MAAM,YAAY,2BAA2B,KAAK,SAAS,QAAQ,CAAC,CAAC;AAC1E,SAAK,cAAc,IAAI,YAAY,yBAAyB,EAAE,QAAQ,EAAE,UAAU,KAAK,SAAS,GAAG,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AAAA,EACrI;AAAA,EAEQ,UAAU,QAAuB;AACvC,QAAI,KAAK,WAAW,OAAQ;AAC5B,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,SAAS;AACd,SAAK,cAAc;AAAA,EACrB;AAAA;AAAA,EAKA,QAAc;AACZ,SAAK,UAAU,IAAI;AAAA,EACrB;AAAA,EAEA,SAAyB;AACvB,UAAM,OAAO,KAAK,UAAU;AAC5B,UAAM,OAAO,KAAK,aAAa,UAAU,CAAC,KAAK;AAC/C,UAAM,WAAW;AAAA;AAAA,UAEX,QAAQ,CAAC,KAAK,UACZ,wDAAwD,KAAK,SAAS,SAAS,OAAO,WAAW,KAAK,WAAW;AAAA,gBAC7G,KAAK,SAAS,IAAI,eAAe,EAAE,MAAM,KAAK,MAAM,CAAC,IAAI,IAAI,gBAAgB,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAAA,yBAEtG,OAAO;AAAA;AAEf,UAAM,QAAQ,iEAAiE,OAAO,WAAW,OAAO;AACxG,WAAO;AAAA,iEACsD,KAAK,KAAK;AAAA,UACjE,KAAK,WAAW,UACd,8DAA8D,KAAK,KACnE,OAAO,KAAK,yDAAyD;AAAA;AAAA,QAEzE,OAAO,UAAU,QAAQ;AAAA;AAAA,EAE/B;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/components/scene.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult, type PropertyValues } from 'lit';\nimport { say, ImpaktElement, fontSize, fontWeight, space, t, token } from '@atomic-ui/ui';\n\nexport type SceneDrive = 'view' | 'page' | 'loop' | 'scrubber';\nexport type SceneLayout = 'stage' | 'split';\n\nconst clamp = (n: number) => Math.min(1, Math.max(0, n));\n\n/**\n * A scene: a stage whose children move along a progress from 0 to 1.\n *\n * The children declare timelines in their `motion` block, and `@atomic-ui/motion`\n * compiles them to keyframes. This element owns only the progress, and where it\n * comes from is the `drive` (ADR 0027):\n *\n * - `view` — the scene's own passage through the viewport. The stage pins\n * while the scene scrolls past, for `length` screens, or beside the content\n * in the default slot when `layout` is `split`.\n * - `page` — the scroll position of the whole page.\n * - `loop` — time, over `duration` seconds, repeating. **It always shows a\n * pause button**, because anything that moves on its own for more than five\n * seconds must be pausable (WCAG 2.2.2), and a scene that could forget that\n * is one the gate would have to catch on every page.\n * - `scrubber` — an `impakt-scrubber` placed in the `controls` slot.\n *\n * Progress is published three ways: the `progress` property, the\n * `--impakt-scene-progress` custom property on the host, and an\n * `impakt-scene-progress` event. Engines with scroll-driven animations run `view`\n * and `page` scenes natively, and the runtime ignores the event for them.\n *\n * Under reduced motion a `loop` does not start, and nothing pins: the stage\n * and the content stack, so every state of the scene can be read in order.\n *\n * @category layout\n * @icon layers\n * @slot stage - What moves, layered one over another. Pinned while the scene plays,\n * beside the content in `split` layout, after it, so the words are read first.\n * @slot - Content that scrolls past the stage, such as chapters.\n * @slot controls - An `impakt-scrubber`, for a scene driven by one.\n * @fires {CustomEvent<{ progress: number }>} impakt-scene-progress - `{ progress }` whenever the progress changes.\n */\nexport class ImpaktScene extends ImpaktElement {\n static properties = {\n drive: { type: String, reflect: true },\n layout: { type: String, reflect: true },\n length: { type: Number },\n duration: { type: Number },\n label: { type: String },\n progress: { type: Number },\n controls: { type: String, reflect: true },\n bleed: { type: Boolean, reflect: true },\n hideOn: { type: String, reflect: true, attribute: 'hide-on' },\n };\n\n /** Where the progress comes from. */\n declare drive: 'view' | 'page' | 'loop' | 'scrubber';\n /** `stage` pins one full-width stage; `split` pins it beside the content. */\n declare layout: 'stage' | 'split';\n /** How many screens of scrolling a `view` scene lasts, in `stage` layout. */\n declare length: number;\n /** Seconds per cycle of a `loop` scene. */\n declare duration: number;\n /** The scene's accessible name. Also names its pause button. */\n declare label: string;\n /** From 0 to 1. Set it to seek a `scrubber` scene, or where one starts. */\n declare progress: number;\n /**\n * Where the controls sit: `below` the stage, or `over` its foot, floating\n * on what it shows, as a video's do. Under reduced motion they sit below.\n */\n declare controls: 'below' | 'over';\n /** Run the stage to the window's edges, past the page's margins, as a hero drawn edge to edge does. */\n declare bleed: boolean;\n /**\n * Leave it out on a phone, or on anything wider, for a picture drawn twice:\n * once for a wide screen and once for a narrow one. Never both.\n */\n declare hideOn: 'never' | 'phone' | 'wide';\n /**\n * Whether a loop is paused: the scene's own state, set by its pause button\n * or by `pause()`. A plain field rather than a property, so it is never one\n * of the settings an author is offered.\n */\n private paused = false;\n\n private frame = 0;\n private started = 0;\n private reduced = false;\n private seekFrom = 0;\n private seekTo = 0;\n private seekStart = 0;\n private seekMs = 0;\n\n constructor() {\n super();\n this.drive = 'view';\n this.layout = 'stage';\n this.length = 3;\n this.duration = 8;\n this.label = 'Animation';\n this.progress = 0;\n this.controls = 'below';\n this.bleed = false;\n this.hideOn = 'never';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n css`\n :host {\n display: block;\n position: relative;\n }\n :host([drive='view'][layout='stage']) {\n min-height: calc(var(--impakt-scene-length, 3) * 100svh);\n }\n .frame {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n }\n :host([layout='split']) .frame {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: ${space(8)};\n }\n .stage {\n position: sticky;\n top: 0;\n height: 100svh;\n display: grid;\n place-items: center;\n overflow: clip;\n }\n /* What is on the stage is layered, as in a motion tool: each thing sits\n over the one before, so a later layer's timeline can reveal it over an\n earlier one. */\n .stage ::slotted(*) {\n grid-area: 1 / 1;\n max-width: 100%;\n }\n :host([drive='loop']) .stage,\n :host([drive='scrubber']) .stage {\n position: relative;\n height: auto;\n min-height: 60svh;\n }\n .controls {\n display: flex;\n gap: ${space(3)};\n align-items: center;\n justify-content: center;\n padding-block: ${space(3)};\n }\n :host([bleed]) { margin-inline: calc(50% - 50vw); }\n @media (max-width: 40rem) { :host([hide-on='phone']) { display: none; } }\n @media (min-width: 40.0625rem) { :host([hide-on='wide']) { display: none; } }\n /* Over the stage, the controls float at its foot, above the layers and clear of its edges. */\n .stage > .controls { position: absolute; inset-inline: ${space(6)}; inset-block-end: ${space(6)}; z-index: 2; padding: 0; }\n .stage > .controls ::slotted(*) { box-shadow: 0 12px 32px rgb(16 19 23 / 14%); border-radius: 16px; background: var(--impakt-color-surface-card, #fff); }\n /* A control takes the row, so a graph scrubber spans the stage; a narrower one centres itself. */\n .controls ::slotted(*) { flex: 1 1 auto; min-width: 0; }\n .pause {\n min-width: ${token('target.min', '24px')};\n min-height: ${token('target.min', '24px')};\n padding: ${space(2)} ${space(4)};\n border-radius: ${token('radius.full', '9999px')};\n border: 1px solid ${t.border};\n background: ${t.surfaceCard};\n color: ${t.text};\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('medium')};\n cursor: pointer;\n }\n .pause:focus-visible {\n outline: none;\n box-shadow: ${token('focus.ring.shadow', '0 0 0 2px #fff, 0 0 0 4px #1a1a1a')};\n }\n @media (max-width: 48rem) {\n :host([layout='split']) .frame {\n grid-template-columns: minmax(0, 1fr);\n }\n :host([layout='split']) .stage {\n height: 50svh;\n z-index: 1;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n min-height: 0 !important;\n }\n .stage {\n position: relative;\n height: auto;\n gap: ${space(6)};\n }\n /* With less motion the layers are shown one after another, so every\n state the scene would have moved through can still be seen. */\n .stage ::slotted(*) {\n grid-area: auto;\n }\n }\n `,\n ];\n\n /** @ignore */\n connectedCallback(): void {\n super.connectedCallback();\n try {\n this.reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n } catch {\n this.reduced = false;\n }\n window.addEventListener('scroll', this.onScroll, { passive: true, capture: true });\n window.addEventListener('resize', this.onScroll);\n this.schedule();\n }\n\n /** @ignore */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener('scroll', this.onScroll, { capture: true });\n window.removeEventListener('resize', this.onScroll);\n if (this.frame) cancelAnimationFrame(this.frame);\n this.frame = 0;\n }\n\n /** @ignore */\n protected updated(changed: PropertyValues<this>): void {\n if (changed.has('length')) this.style.setProperty('--impakt-scene-length', String(this.length));\n if (changed.has('progress')) this.publish();\n if (changed.has('drive')) {\n this.started = 0;\n this.schedule();\n }\n }\n\n /**\n * Move to a progress. With `ms`, ease there; without, jump. A scrubber seeks\n * a scene to a named stop this way.\n */\n seek(to: number, ms = 0): void {\n if (ms <= 0 || this.reduced) {\n this.progress = clamp(to);\n return;\n }\n this.seekFrom = this.progress;\n this.seekTo = clamp(to);\n this.seekStart = 0;\n this.seekMs = ms;\n this.schedule();\n }\n\n private onScroll = () => {\n if (this.drive === 'view' || this.drive === 'page') this.schedule();\n };\n\n private schedule(): void {\n if (!this.frame && typeof requestAnimationFrame === 'function') this.frame = requestAnimationFrame(this.tick);\n }\n\n private tick = (now: number) => {\n this.frame = 0;\n if (this.seekMs) {\n if (!this.seekStart) this.seekStart = now;\n const p = Math.min(1, (now - this.seekStart) / this.seekMs);\n // ease-in-out, so a jump between stops reads as travel rather than a cut\n const e = p < 0.5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;\n this.progress = this.seekFrom + (this.seekTo - this.seekFrom) * e;\n if (p < 1) this.schedule();\n else this.seekMs = 0;\n return;\n }\n if (this.drive === 'view') {\n const r = this.getBoundingClientRect();\n const vh = window.innerHeight || 1;\n this.progress = clamp(-r.top / Math.max(1, r.height - vh));\n } else if (this.drive === 'page') {\n const doc = document.documentElement;\n this.progress = clamp(window.scrollY / Math.max(1, doc.scrollHeight - (window.innerHeight || 0)));\n } else if (this.drive === 'loop' && !this.paused && !this.reduced) {\n if (!this.started) this.started = now - this.progress * this.duration * 1000;\n this.progress = ((now - this.started) / (this.duration * 1000)) % 1;\n this.schedule();\n }\n };\n\n private publish(): void {\n this.style.setProperty('--impakt-scene-progress', this.progress.toFixed(4));\n this.dispatchEvent(new CustomEvent('impakt-scene-progress', { detail: { progress: this.progress }, bubbles: true, composed: true }));\n }\n\n private setPaused(paused: boolean): void {\n if (this.paused === paused) return;\n this.paused = paused;\n this.started = 0;\n this.schedule();\n this.requestUpdate();\n }\n\n private togglePause = () => this.setPaused(!this.paused);\n\n /** Stop a loop where it is, as its pause button does. An editor scrubbing the scene calls it. */\n pause(): void {\n this.setPaused(true);\n }\n\n render(): TemplateResult {\n const loop = this.drive === 'loop';\n const over = this.controls === 'over' && !this.reduced;\n const controls = html`<div class=\"controls\" part=\"controls\">\n <slot name=\"controls\"></slot>\n ${\n loop && !this.reduced\n ? html`<button class=\"pause\" type=\"button\" aria-pressed=${this.paused ? 'true' : 'false'} @click=${this.togglePause}>\n ${this.paused ? say('Play {name}', { name: this.label }) : say('Pause {name}', { name: this.label })}\n </button>`\n : nothing\n }\n </div>`;\n const stage = html`<div class=\"stage\" part=\"stage\"><slot name=\"stage\"></slot>${over ? controls : nothing}</div>`;\n return html`\n <div class=\"frame\" part=\"frame\" role=\"region\" aria-label=${this.label}>\n ${\n this.layout === 'split'\n ? html`<div class=\"content\" part=\"content\"><slot></slot></div>${stage}`\n : html`${stage}<div class=\"content\" part=\"content\"><slot></slot></div>`\n }\n </div>\n ${over ? nothing : controls}\n `;\n }\n}\n\ncustomElements.define('impakt-scene', ImpaktScene);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-scene': ImpaktScene;\n }\n}\n"],"mappings":";AAAA,SAAS,MAAM,KAAK,eAAyD;AAC7E,SAAS,KAAK,eAAe,UAAU,YAAY,OAAO,GAAG,aAAa;AAK1E,IAAM,QAAQ,CAAC,MAAc,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AAmChD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SAAS,IAAI,eAAe,EAAE,MAAM,KAAK,MAAM,CAAC,IAAI,IAAI,gBAAgB,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAAA,yBAEpG,OACN;AAAA;AAEJ,UAAM,QAAQ,iEAAiE,OAAO,WAAW,OAAO;AACxG,WAAO;AAAA,iEACsD,KAAK,KAAK;AAAA,UAEjE,KAAK,WAAW,UACZ,8DAA8D,KAAK,KACnE,OAAO,KAAK,yDAClB;AAAA;AAAA,QAEA,OAAO,UAAU,QAAQ;AAAA;AAAA,EAE/B;AACF;AAEA,eAAe,OAAO,gBAAgB,WAAW;","names":[]}
|
|
@@ -22,7 +22,11 @@ var ImpaktCardGrid = class extends ImpaktElement {
|
|
|
22
22
|
this.spaceBelow = "none";
|
|
23
23
|
}
|
|
24
24
|
static {
|
|
25
|
-
this.styles = [
|
|
25
|
+
this.styles = [
|
|
26
|
+
...ImpaktElement.styles,
|
|
27
|
+
focusRing,
|
|
28
|
+
spaceAround,
|
|
29
|
+
css`
|
|
26
30
|
:host { display: block; container-type: inline-size; --ratio: 4 / 3; }
|
|
27
31
|
:host([ratio='16:9']) { --ratio: 16 / 9; }
|
|
28
32
|
:host([ratio='3:2']) { --ratio: 3 / 2; }
|
|
@@ -43,10 +47,12 @@ var ImpaktCardGrid = class extends ImpaktElement {
|
|
|
43
47
|
.more { margin-block-start: auto; display: inline-flex; align-items: center; gap: ${space(1)}; color: ${t.link}; font-weight: ${fontWeight("semibold")}; }
|
|
44
48
|
@container (max-width: 48rem) { ul, :host([columns='four']) ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
45
49
|
@container (max-width: 32rem) { ul, :host([columns='two']) ul, :host([columns='four']) ul { grid-template-columns: minmax(0, 1fr); } }
|
|
46
|
-
`
|
|
50
|
+
`
|
|
51
|
+
];
|
|
47
52
|
}
|
|
48
53
|
render() {
|
|
49
|
-
return html`<ul part="list">${(this.items ?? []).map(
|
|
54
|
+
return html`<ul part="list">${(this.items ?? []).map(
|
|
55
|
+
(card) => html`<li class=${card.href ? "linked" : ""} part="card">
|
|
50
56
|
${card.imageSrc ? html`<img src=${card.imageSrc} alt=${card.imageAlt ?? ""} loading="lazy" />` : nothing}
|
|
51
57
|
<div class="words">
|
|
52
58
|
${card.badge ? html`<span class="badge">${card.badge}</span>` : nothing}
|
|
@@ -54,7 +60,8 @@ var ImpaktCardGrid = class extends ImpaktElement {
|
|
|
54
60
|
${card.text ? html`<p class="body">${card.text}</p>` : nothing}
|
|
55
61
|
${card.href ? html`<span class="more" aria-hidden="true">${iconSvg("arrow-right", "1em")}</span>` : nothing}
|
|
56
62
|
</div>
|
|
57
|
-
</li>`
|
|
63
|
+
</li>`
|
|
64
|
+
)}</ul>`;
|
|
58
65
|
}
|
|
59
66
|
};
|
|
60
67
|
customElements.define("impakt-card-grid", ImpaktCardGrid);
|
|
@@ -62,4 +69,4 @@ customElements.define("impakt-card-grid", ImpaktCardGrid);
|
|
|
62
69
|
export {
|
|
63
70
|
ImpaktCardGrid
|
|
64
71
|
};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-YC6KXE6O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/card-grid.ts"],"sourcesContent":["/**\n * A row of linked cards.\n */\nimport { css, html, nothing, type TemplateResult } from 'lit';\nimport { ImpaktElement, focusRing, fontSize, fontWeight, lineHeight, space, spaceAround, t, iconSvg } from '@atomic-ui/ui';\n\n/** One card in a row of them. */\nexport interface CardItem {\n id?: string;\n heading: string;\n text?: string;\n imageSrc?: string;\n imageAlt?: string;\n href?: string;\n badge?: string;\n}\n\n/**\n * A row of cards, each a picture, a heading, a line of text and a link: the\n * developments on a developments page, or the house types at one of them.\n *\n * **The whole card is the link's target, and the heading is its name.** The\n * link is on the heading, so a screen reader hears \"Larkfield Meadows, link\"\n * once rather than the whole card read out as one long link, and a pointer\n * can still press anywhere on the card.\n *\n * @category content\n * @icon cards\n */\nexport class ImpaktCardGrid extends ImpaktElement {\n static properties = {\n items: { type: Array },\n columns: { type: String, reflect: true },\n headingLevel: { type: Number, attribute: 'heading-level' },\n ratio: { type: String, reflect: true },\n spaceAbove: { type: String, reflect: true, attribute: 'space-above' },\n spaceBelow: { type: String, reflect: true, attribute: 'space-below' },\n };\n declare items: CardItem[];\n declare columns: 'two' | 'three' | 'four';\n /** The level of each card's heading. One below the heading above the cards. */\n declare headingLevel: 2 | 3 | 4;\n /** The shape of each card's picture. */\n declare ratio: '16:9' | '4:3' | '3:2' | '1:1';\n declare spaceAbove: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n declare spaceBelow: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n\n constructor() {\n super();\n this.items = [];\n this.columns = 'three';\n this.headingLevel = 3;\n this.ratio = '4:3';\n this.spaceAbove = 'none';\n this.spaceBelow = 'none';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n focusRing,\n spaceAround,\n css`\n :host { display: block; container-type: inline-size; --ratio: 4 / 3; }\n :host([ratio='16:9']) { --ratio: 16 / 9; }\n :host([ratio='3:2']) { --ratio: 3 / 2; }\n :host([ratio='1:1']) { --ratio: 1 / 1; }\n ul { list-style: none; margin: 0; padding: 0; display: grid; gap: ${space(6)}; grid-template-columns: repeat(3, minmax(0, 1fr)); }\n :host([columns='two']) ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n :host([columns='four']) ul { grid-template-columns: repeat(4, minmax(0, 1fr)); }\n li { position: relative; display: flex; flex-direction: column; background: ${t.surfaceCard}; border: ${t.borderThin} solid ${t.hairline}; border-radius: ${t.radiusXl}; box-shadow: ${t.shadowSm}; overflow: hidden; transition: box-shadow 150ms ease-in-out, transform 150ms ease-in-out; }\n li.linked:hover { box-shadow: ${t.shadowLg}; transform: translateY(-2px); }\n img { display: block; inline-size: 100%; aspect-ratio: var(--ratio); object-fit: cover; }\n .words { display: flex; flex-direction: column; gap: ${space(2)}; padding: ${space(5)}; flex: 1; }\n .h { margin: 0; color: ${t.textHeading}; font-family: ${t.fontHeading}; font-size: ${fontSize('lg')}; font-weight: ${fontWeight('bold')}; line-height: ${lineHeight('tight')}; }\n .h a { color: inherit; text-decoration: none; border-radius: ${t.radiusSm}; }\n .h a::after { content: ''; position: absolute; inset: 0; }\n li.linked:hover .h a { text-decoration: underline; text-underline-offset: 0.2em; }\n .body { margin: 0; line-height: ${lineHeight('normal')}; }\n .badge { align-self: flex-start; padding: ${space(0.5)} ${space(2)}; border-radius: ${t.radius}; font-size: ${fontSize('sm')}; font-weight: ${fontWeight('medium')}; background: ${t.brandSubtle}; color: ${t.brand}; box-shadow: inset 0 0 0 1px ${t.hairline}; }\n .more { margin-block-start: auto; display: inline-flex; align-items: center; gap: ${space(1)}; color: ${t.link}; font-weight: ${fontWeight('semibold')}; }\n @container (max-width: 48rem) { ul, :host([columns='four']) ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }\n @container (max-width: 32rem) { ul, :host([columns='two']) ul, :host([columns='four']) ul { grid-template-columns: minmax(0, 1fr); } }\n `,\n ];\n\n render(): TemplateResult {\n return html`<ul part=\"list\">${(this.items ?? []).map(\n (card) => html`<li class=${card.href ? 'linked' : ''} part=\"card\">\n ${card.imageSrc ? html`<img src=${card.imageSrc} alt=${card.imageAlt ?? ''} loading=\"lazy\" />` : nothing}\n <div class=\"words\">\n ${card.badge ? html`<span class=\"badge\">${card.badge}</span>` : nothing}\n <div class=\"h\" role=\"heading\" aria-level=${this.headingLevel}>${card.href ? html`<a href=${card.href}>${card.heading}</a>` : card.heading}</div>\n ${card.text ? html`<p class=\"body\">${card.text}</p>` : nothing}\n ${card.href ? html`<span class=\"more\" aria-hidden=\"true\">${iconSvg('arrow-right', '1em')}</span>` : nothing}\n </div>\n </li>`,\n )}</ul>`;\n }\n}\n\ncustomElements.define('impakt-card-grid', ImpaktCardGrid);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'impakt-card-grid': ImpaktCardGrid;\n }\n}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