@perkyzz/emvb 1.1.0 → 1.3.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/THIRD_PARTY_NOTICES.md +3 -2
- package/package.json +11 -10
- package/src/admin/agents-api.ts +5 -1
- package/src/admin/content-api.ts +29 -0
- package/src/admin/editor/Editor.tsx +6 -1
- package/src/admin/editor/ScheduleDialog.tsx +167 -0
- package/src/admin/editor/TopBar.tsx +33 -1
- package/src/admin/editor/canvas/vnode-react.tsx +3 -0
- package/src/admin/editor/dnd/new-element.ts +106 -0
- package/src/admin/editor/editor-chrome.tsx +9 -0
- package/src/admin/editor/element-chrome.ts +50 -0
- package/src/admin/editor/panels/ElementPanel.tsx +5 -1
- package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
- package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
- package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
- package/src/admin/editor/panels/settings/ItemList.tsx +69 -2
- package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
- package/src/admin/editor/store.ts +7 -1
- package/src/admin/editor/useEditorData.ts +4 -0
- package/src/admin/editor/useSave.ts +47 -3
- package/src/admin/export-api.ts +20 -3
- package/src/admin/menus-api.ts +113 -0
- package/src/admin/pages/ImportElementorDialog.tsx +25 -1
- package/src/astro/EmVBPage.astro +3 -0
- package/src/astro/render.ts +43 -18
- package/src/astro/request-data.ts +9 -0
- package/src/astro/resolve-theme.ts +77 -44
- package/src/astro/resolve.ts +9 -0
- package/src/astro/visitor.ts +23 -4
- package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCountdownRuntime.astro +8 -0
- package/src/astro/widgets/EmVBCounterRuntime.astro +8 -0
- package/src/astro/widgets/EmVBHeadlineRuntime.astro +9 -0
- package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
- package/src/astro/widgets/EmVBMapRuntime.astro +8 -0
- package/src/astro/widgets/EmVBShareRuntime.astro +9 -0
- package/src/astro/widgets/EmVBWidgetRuntimes.astro +29 -0
- package/src/astro/widgets/alerts.ts +37 -0
- package/src/astro/widgets/carousel.ts +167 -0
- package/src/astro/widgets/countdown.ts +80 -0
- package/src/astro/widgets/counter.ts +98 -0
- package/src/astro/widgets/headline.ts +90 -0
- package/src/astro/widgets/index.ts +1 -0
- package/src/astro/widgets/lightbox.ts +123 -0
- package/src/astro/widgets/map.ts +37 -0
- package/src/astro/widgets/share.ts +21 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +127 -5
- package/src/core/arrange.ts +109 -1
- package/src/core/bounded-array.ts +16 -13
- package/src/core/canvas-collections.ts +28 -0
- package/src/core/contract.ts +4 -1
- package/src/core/elements/counter-format.ts +15 -0
- package/src/core/elements/icon-svg.ts +135 -0
- package/src/core/elements/index.ts +63 -127
- package/src/core/elements/marketing.ts +1490 -0
- package/src/core/elements/widgets.ts +932 -0
- package/src/core/export/runtimes.generated.ts +8 -0
- package/src/core/export/site.ts +25 -3
- package/src/core/extensions/schema.ts +2 -1
- package/src/core/geo-trust.ts +18 -0
- package/src/core/icons/social.generated.ts +29 -0
- package/src/core/image-edit/schema.ts +2 -1
- package/src/core/import/elementor/context.ts +18 -0
- package/src/core/import/elementor/index.ts +50 -7
- package/src/core/import/elementor/widgets.ts +783 -385
- package/src/core/issue-cap.ts +19 -0
- package/src/core/limits.ts +12 -0
- package/src/core/loop-collections.ts +33 -0
- package/src/core/proposals.ts +8 -2
- package/src/core/render/index.ts +48 -5
- package/src/core/render/vnode.ts +44 -6
- package/src/core/sanitize/svg-upload.ts +276 -23
- package/src/core/sanitize/svg.ts +3 -3
- package/src/core/schema/descriptors.ts +4 -0
- package/src/core/schema/design.ts +6 -5
- package/src/core/schema/layout.ts +798 -15
- package/src/core/schema/style.ts +2 -1
- package/src/core/shadowing-ids.ts +41 -0
- package/src/core/theme/conditions.ts +2 -1
- package/src/core/theme/dynamic.ts +2 -0
- package/src/core/theme/parse-doc.ts +10 -5
- package/src/core/theme/triggers.ts +3 -2
- package/src/core/validate.ts +3 -2
- package/src/index.ts +23 -2
- package/src/mcp/ports.ts +18 -7
- package/src/mcp/proposals.ts +36 -11
- package/src/mcp/tools.ts +1 -1
- package/src/server/agent-settings.ts +12 -1
- package/src/server/hooks.ts +41 -6
- package/src/server/mcp-routes.ts +11 -5
- package/src/server/plugin.ts +29 -3
- package/src/server/presence.ts +5 -1
- package/src/server/proposals.ts +16 -4
- package/src/server/requests.ts +60 -11
- package/src/server/site-origin.ts +13 -0
- package/src/server/targets.ts +26 -0
|
@@ -0,0 +1,1490 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 1.3 marketing widgets (PLAN_1.3 part D): new elements from plain markup and CSS. Each one
|
|
3
|
+
* renders without script; a count-up or a ticking clock is an opt-in runtime.
|
|
4
|
+
*/
|
|
5
|
+
import type {
|
|
6
|
+
CountdownNode,
|
|
7
|
+
CounterNode,
|
|
8
|
+
CtaNode,
|
|
9
|
+
FlipBoxNode,
|
|
10
|
+
HeadlineNode,
|
|
11
|
+
HotspotNode,
|
|
12
|
+
HotspotsNode,
|
|
13
|
+
MapNode,
|
|
14
|
+
PriceListItemNode,
|
|
15
|
+
PriceListNode,
|
|
16
|
+
PriceTableNode,
|
|
17
|
+
ProgressNode,
|
|
18
|
+
ShareButtonsNode,
|
|
19
|
+
ShareLinkNode,
|
|
20
|
+
} from "../schema/layout.ts";
|
|
21
|
+
import {
|
|
22
|
+
SHARE_NETWORKS,
|
|
23
|
+
COUNTDOWN_TARGET,
|
|
24
|
+
COUNTER_SEPARATORS,
|
|
25
|
+
MAX_COUNTER,
|
|
26
|
+
MAX_PROGRESS,
|
|
27
|
+
} from "../schema/layout.ts";
|
|
28
|
+
import { sanitizeHref } from "../sanitize/href.ts";
|
|
29
|
+
import { SOCIAL_COLORS, SOCIAL_NAMES, socialSvg } from "./widgets.ts";
|
|
30
|
+
import { sanitizeMediaUrl } from "../sanitize/media-url.ts";
|
|
31
|
+
import type { VNode } from "../render/vnode.ts";
|
|
32
|
+
import { formatCounter } from "./counter-format.ts";
|
|
33
|
+
import type { ElementDefinition } from "./definition.ts";
|
|
34
|
+
|
|
35
|
+
/** Hidden from sight, still read by screen readers. */
|
|
36
|
+
const SR_ONLY =
|
|
37
|
+
"position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0";
|
|
38
|
+
|
|
39
|
+
const SEPARATOR_LABELS: Record<(typeof COUNTER_SEPARATORS)[number], string> = {
|
|
40
|
+
",": "1,000",
|
|
41
|
+
".": "1.000",
|
|
42
|
+
" ": "1 000",
|
|
43
|
+
"'": "1'000",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const counter: ElementDefinition<CounterNode> = {
|
|
47
|
+
baseCss: `.emvb-counter-number{margin:0;font-size:2.5em;font-weight:700;line-height:1.1;font-variant-numeric:tabular-nums}.emvb-counter-title{margin:0.25em 0 0}.emvb-counter-sr{${SR_ONLY}}`,
|
|
48
|
+
defaults: () => ({
|
|
49
|
+
type: "counter",
|
|
50
|
+
props: { value: 1200, separator: ",", suffix: "+", title: "Happy clients" },
|
|
51
|
+
}),
|
|
52
|
+
descriptor: {
|
|
53
|
+
type: "counter",
|
|
54
|
+
name: "Counter",
|
|
55
|
+
group: "content",
|
|
56
|
+
defaultTab: "content",
|
|
57
|
+
fields: [
|
|
58
|
+
{
|
|
59
|
+
key: "value",
|
|
60
|
+
kind: "decimal",
|
|
61
|
+
label: "Number",
|
|
62
|
+
min: -MAX_COUNTER,
|
|
63
|
+
max: MAX_COUNTER,
|
|
64
|
+
message: "Enter a number, such as 1200 or 98.5.",
|
|
65
|
+
},
|
|
66
|
+
{ key: "prefix", kind: "text", label: "Before the number", optional: true },
|
|
67
|
+
{ key: "suffix", kind: "text", label: "After the number", optional: true },
|
|
68
|
+
{ key: "title", kind: "text", label: "Title", optional: true },
|
|
69
|
+
{
|
|
70
|
+
key: "decimals",
|
|
71
|
+
kind: "select",
|
|
72
|
+
label: "Decimals",
|
|
73
|
+
optional: true,
|
|
74
|
+
options: [0, 1, 2, 3].map((value) => ({ value, label: String(value) })),
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: "separator",
|
|
78
|
+
kind: "select",
|
|
79
|
+
label: "Thousands separator",
|
|
80
|
+
optional: true,
|
|
81
|
+
options: COUNTER_SEPARATORS.map((value) => ({ value, label: SEPARATOR_LABELS[value] })),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
key: "countUp",
|
|
85
|
+
kind: "boolean",
|
|
86
|
+
label: "Count up when scrolled into view",
|
|
87
|
+
optional: true,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
key: "start",
|
|
91
|
+
kind: "decimal",
|
|
92
|
+
label: "Count from",
|
|
93
|
+
optional: true,
|
|
94
|
+
min: -MAX_COUNTER,
|
|
95
|
+
max: MAX_COUNTER,
|
|
96
|
+
message: "Enter the number the count-up starts at, such as 0.",
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
key: "duration",
|
|
100
|
+
kind: "int",
|
|
101
|
+
label: "Count-up time (ms)",
|
|
102
|
+
optional: true,
|
|
103
|
+
min: 300,
|
|
104
|
+
max: 5000,
|
|
105
|
+
message: "From 300 to 5000 ms (5 seconds at most).",
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
build: (node, attrs) => {
|
|
110
|
+
const { value, start, decimals, separator, prefix, suffix, title, countUp, duration } =
|
|
111
|
+
node.props;
|
|
112
|
+
const valueAttrs: Record<string, string> = { class: "emvb-counter-value" };
|
|
113
|
+
if (countUp) {
|
|
114
|
+
valueAttrs["data-emvb-counter"] = "";
|
|
115
|
+
valueAttrs["data-from"] = String(start ?? 0);
|
|
116
|
+
valueAttrs["data-to"] = String(value);
|
|
117
|
+
if (decimals) valueAttrs["data-decimals"] = String(decimals);
|
|
118
|
+
if (separator) valueAttrs["data-separator"] = separator;
|
|
119
|
+
valueAttrs["data-duration"] = String(duration ?? 2000);
|
|
120
|
+
}
|
|
121
|
+
const number: (VNode | string)[] = [];
|
|
122
|
+
if (prefix)
|
|
123
|
+
number.push({ tag: "span", attrs: { class: "emvb-counter-prefix" }, children: [prefix] });
|
|
124
|
+
number.push({
|
|
125
|
+
tag: "span",
|
|
126
|
+
attrs: valueAttrs,
|
|
127
|
+
children: [formatCounter(value, decimals, separator)],
|
|
128
|
+
});
|
|
129
|
+
if (suffix)
|
|
130
|
+
number.push({ tag: "span", attrs: { class: "emvb-counter-suffix" }, children: [suffix] });
|
|
131
|
+
const children: VNode[] = [
|
|
132
|
+
{ tag: "p", attrs: { class: "emvb-counter-number" }, children: number },
|
|
133
|
+
];
|
|
134
|
+
if (title?.trim())
|
|
135
|
+
children.push({ tag: "p", attrs: { class: "emvb-counter-title" }, children: [title] });
|
|
136
|
+
return { tag: "div", attrs, children };
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/** A number with at most two decimals, as people write it. */
|
|
141
|
+
const short = (value: number) => String(Math.round(value * 100) / 100);
|
|
142
|
+
|
|
143
|
+
/** W-1039: how far a Progress bar is filled, from 0 to 100. */
|
|
144
|
+
function progressPercent(props: ProgressNode["props"]): number {
|
|
145
|
+
const max = props.max ?? 100;
|
|
146
|
+
return Math.min(100, Math.max(0, (props.value / max) * 100));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const progress: ElementDefinition<ProgressNode> = {
|
|
150
|
+
baseCss:
|
|
151
|
+
".emvb-progress-head{display:flex;justify-content:space-between;gap:1em;margin:0 0 0.375em}.emvb-progress-svg{display:block;width:100%;overflow:visible}[dir=rtl] .emvb-progress-svg,.emvb-progress[dir=rtl] .emvb-progress-svg{transform:scaleX(-1)}@keyframes emvb-progress-grow{from{transform:scaleX(0)}to{transform:scaleX(1)}}@media (prefers-reduced-motion:no-preference){@supports (animation-timeline:view()){.emvb-progress-grow .emvb-progress-fill{transform-box:fill-box;transform-origin:left center;animation:emvb-progress-grow linear both;animation-timeline:view();animation-range:entry 10% cover 40%}}}",
|
|
152
|
+
defaults: () => ({
|
|
153
|
+
type: "progress",
|
|
154
|
+
props: { value: 75, label: "Design", showValue: true },
|
|
155
|
+
}),
|
|
156
|
+
descriptor: {
|
|
157
|
+
type: "progress",
|
|
158
|
+
name: "Progress bar",
|
|
159
|
+
group: "content",
|
|
160
|
+
defaultTab: "content",
|
|
161
|
+
fields: [
|
|
162
|
+
{ key: "label", kind: "text", label: "Title", optional: true },
|
|
163
|
+
{
|
|
164
|
+
key: "value",
|
|
165
|
+
kind: "decimal",
|
|
166
|
+
label: "Value",
|
|
167
|
+
max: MAX_PROGRESS,
|
|
168
|
+
maxProp: "max",
|
|
169
|
+
message: "Enter a number from 0 up to the maximum, such as 75.",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
key: "max",
|
|
173
|
+
kind: "decimal",
|
|
174
|
+
label: "Maximum",
|
|
175
|
+
optional: true,
|
|
176
|
+
min: 0.01,
|
|
177
|
+
max: MAX_PROGRESS,
|
|
178
|
+
message: "Enter a number above 0, such as 100.",
|
|
179
|
+
},
|
|
180
|
+
{ key: "showValue", kind: "boolean", label: "Show the percentage", optional: true },
|
|
181
|
+
{
|
|
182
|
+
key: "kind",
|
|
183
|
+
kind: "select",
|
|
184
|
+
label: "Meaning",
|
|
185
|
+
optional: true,
|
|
186
|
+
options: [
|
|
187
|
+
{ value: "meter", label: "A measurement, such as a skill" },
|
|
188
|
+
{ value: "progressbar", label: "How far a task has got" },
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
{ key: "thickness", kind: "int", label: "Bar height (px)", optional: true, min: 2, max: 48 },
|
|
192
|
+
{ key: "grow", kind: "boolean", label: "Grow in when scrolled into view", optional: true },
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
build: (node, attrs) => {
|
|
196
|
+
const { value, label, showValue, kind, thickness, grow } = node.props;
|
|
197
|
+
const max = node.props.max ?? 100;
|
|
198
|
+
const percent = progressPercent(node.props);
|
|
199
|
+
const shown = `${Math.round(percent)}%`;
|
|
200
|
+
const height = thickness ?? 8;
|
|
201
|
+
const radius = String(height / 2);
|
|
202
|
+
const children: VNode[] = [];
|
|
203
|
+
const title = label?.trim();
|
|
204
|
+
if (title || showValue) {
|
|
205
|
+
const head: VNode[] = [];
|
|
206
|
+
head.push({
|
|
207
|
+
tag: "span",
|
|
208
|
+
attrs: { class: "emvb-progress-label" },
|
|
209
|
+
children: title ? [title] : [],
|
|
210
|
+
});
|
|
211
|
+
if (showValue)
|
|
212
|
+
head.push({
|
|
213
|
+
tag: "span",
|
|
214
|
+
attrs: { class: "emvb-progress-value", "aria-hidden": "true" },
|
|
215
|
+
children: [shown],
|
|
216
|
+
});
|
|
217
|
+
children.push({ tag: "div", attrs: { class: "emvb-progress-head" }, children: head });
|
|
218
|
+
}
|
|
219
|
+
const rect = (className: string, width: string, extra: Record<string, string>): VNode => ({
|
|
220
|
+
tag: "rect",
|
|
221
|
+
attrs: {
|
|
222
|
+
class: className,
|
|
223
|
+
width,
|
|
224
|
+
height: "100%",
|
|
225
|
+
rx: radius,
|
|
226
|
+
fill: "currentColor",
|
|
227
|
+
...extra,
|
|
228
|
+
},
|
|
229
|
+
children: [],
|
|
230
|
+
});
|
|
231
|
+
children.push({
|
|
232
|
+
tag: "div",
|
|
233
|
+
attrs: {
|
|
234
|
+
class: "emvb-progress-bar",
|
|
235
|
+
role: kind ?? "meter",
|
|
236
|
+
...(title ? { "aria-label": title } : {}),
|
|
237
|
+
"aria-valuemin": "0",
|
|
238
|
+
"aria-valuemax": short(max),
|
|
239
|
+
"aria-valuenow": short(Math.min(value, max)),
|
|
240
|
+
"aria-valuetext": shown,
|
|
241
|
+
},
|
|
242
|
+
children: [
|
|
243
|
+
{
|
|
244
|
+
tag: "svg",
|
|
245
|
+
attrs: {
|
|
246
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
247
|
+
class: "emvb-progress-svg",
|
|
248
|
+
width: "100%",
|
|
249
|
+
height: String(height),
|
|
250
|
+
"aria-hidden": "true",
|
|
251
|
+
focusable: "false",
|
|
252
|
+
},
|
|
253
|
+
children: [
|
|
254
|
+
rect("emvb-progress-track", "100%", { "fill-opacity": "0.2" }),
|
|
255
|
+
...(percent > 0 ? [rect("emvb-progress-fill", `${short(percent)}%`, {})] : []),
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
tag: "div",
|
|
262
|
+
attrs: grow
|
|
263
|
+
? { ...attrs, class: `${attrs["class"] ?? ""} emvb-progress-grow`.trim() }
|
|
264
|
+
: attrs,
|
|
265
|
+
children,
|
|
266
|
+
};
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* W-1040: a Countdown's target as people read it, in the time zone it was written in:
|
|
274
|
+
* "1 Dec 2026, 09:00 UTC−5". The page doesn't know the visitor's zone, so it names its own.
|
|
275
|
+
*/
|
|
276
|
+
function countdownDate(target: string): string {
|
|
277
|
+
const m = COUNTDOWN_TARGET.exec(target);
|
|
278
|
+
if (!m) return target;
|
|
279
|
+
const [, year, month, day, hour, minute, , zone = "Z"] = m;
|
|
280
|
+
let offset = "";
|
|
281
|
+
if (zone !== "Z") {
|
|
282
|
+
const [h = "00", min = "00"] = zone.slice(1).split(":");
|
|
283
|
+
const hours = String(Number(h));
|
|
284
|
+
offset = `${zone[0] === "-" ? "\u2212" : "+"}${hours}${min === "00" ? "" : `:${min}`}`;
|
|
285
|
+
if (h === "00" && min === "00") offset = "";
|
|
286
|
+
}
|
|
287
|
+
return `${Number(day)} ${MONTHS[Number(month) - 1]} ${year}, ${hour}:${minute} UTC${offset}`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const COUNTDOWN_UNITS = [
|
|
291
|
+
["days", "Days"],
|
|
292
|
+
["hours", "Hours"],
|
|
293
|
+
["minutes", "Minutes"],
|
|
294
|
+
["seconds", "Seconds"],
|
|
295
|
+
] as const;
|
|
296
|
+
|
|
297
|
+
export const countdown: ElementDefinition<CountdownNode> = {
|
|
298
|
+
baseCss:
|
|
299
|
+
".emvb-countdown-title{margin:0 0 0.25em;font-weight:600}.emvb-countdown-target{margin:0}.emvb-countdown-clock{display:flex;flex-wrap:wrap;align-items:center;gap:0.75em;margin:0.5em 0 0}.emvb-countdown:not([data-emvb-ready]) .emvb-countdown-clock,.emvb-countdown-expired:not([data-emvb-shown]),.emvb-countdown[hidden],.emvb-countdown-clock[hidden]{display:none}.emvb-countdown-units{display:flex;gap:0.75em}.emvb-countdown-unit{display:flex;flex-direction:column;align-items:center;min-width:3.5em}.emvb-countdown-num{font-size:2em;font-weight:700;line-height:1.1;font-variant-numeric:tabular-nums}.emvb-countdown-name{font-size:0.75em;text-transform:uppercase;letter-spacing:0.05em}.emvb-countdown-pause{padding:0.25em 0.75em;border:1px solid currentColor;border-radius:4px;background:none;color:inherit;font:inherit;cursor:pointer}.emvb-countdown-pause:focus-visible{outline:2px solid currentColor;outline-offset:2px}.emvb-countdown-expired{margin:0.5em 0 0}",
|
|
300
|
+
defaults: () => ({
|
|
301
|
+
type: "countdown",
|
|
302
|
+
props: { target: "2027-01-01T00:00Z", title: "Offer ends soon", ticking: true },
|
|
303
|
+
}),
|
|
304
|
+
descriptor: {
|
|
305
|
+
type: "countdown",
|
|
306
|
+
name: "Countdown",
|
|
307
|
+
group: "content",
|
|
308
|
+
defaultTab: "content",
|
|
309
|
+
fields: [
|
|
310
|
+
{
|
|
311
|
+
key: "target",
|
|
312
|
+
kind: "text",
|
|
313
|
+
label: "Ends at",
|
|
314
|
+
message: "Date, time and UTC offset, such as 2026-12-01T09:00-05:00 (or Z for UTC).",
|
|
315
|
+
},
|
|
316
|
+
{ key: "title", kind: "text", label: "Title", optional: true },
|
|
317
|
+
{
|
|
318
|
+
key: "label",
|
|
319
|
+
kind: "text",
|
|
320
|
+
label: "Words before the date",
|
|
321
|
+
optional: true,
|
|
322
|
+
message: "Leave it empty for Ends.",
|
|
323
|
+
},
|
|
324
|
+
{ key: "ticking", kind: "boolean", label: "Show a live countdown", optional: true },
|
|
325
|
+
{ key: "hideSeconds", kind: "boolean", label: "Hide seconds", optional: true },
|
|
326
|
+
{
|
|
327
|
+
key: "expired",
|
|
328
|
+
kind: "select",
|
|
329
|
+
label: "When time is up",
|
|
330
|
+
optional: true,
|
|
331
|
+
options: [
|
|
332
|
+
{ value: "text", label: "Show the ended text" },
|
|
333
|
+
{ value: "hide", label: "Hide the countdown" },
|
|
334
|
+
{ value: "link", label: "Show the ended text as a link" },
|
|
335
|
+
],
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
key: "expiredText",
|
|
339
|
+
kind: "text",
|
|
340
|
+
label: "Ended text",
|
|
341
|
+
optional: true,
|
|
342
|
+
message:
|
|
343
|
+
"Shown by the live countdown once time is up. Leave it empty for This offer has ended.",
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
key: "expiredHref",
|
|
347
|
+
kind: "href",
|
|
348
|
+
label: "Ended link",
|
|
349
|
+
optional: true,
|
|
350
|
+
message: "Use a full URL such as https://example.com or a path such as /offers.",
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
build: (node, attrs) => {
|
|
355
|
+
const { target, title, label, ticking, hideSeconds, expired, expiredText, expiredHref } =
|
|
356
|
+
node.props;
|
|
357
|
+
const children: VNode[] = [];
|
|
358
|
+
if (title?.trim())
|
|
359
|
+
children.push({ tag: "p", attrs: { class: "emvb-countdown-title" }, children: [title] });
|
|
360
|
+
children.push({
|
|
361
|
+
tag: "p",
|
|
362
|
+
attrs: { class: "emvb-countdown-target" },
|
|
363
|
+
children: [
|
|
364
|
+
`${label?.trim() || "Ends"} `,
|
|
365
|
+
{ tag: "time", attrs: { datetime: target }, children: [countdownDate(target)] },
|
|
366
|
+
],
|
|
367
|
+
});
|
|
368
|
+
if (!ticking) return { tag: "div", attrs, children };
|
|
369
|
+
const units = COUNTDOWN_UNITS.filter(([unit]) => !(hideSeconds && unit === "seconds"));
|
|
370
|
+
children.push({
|
|
371
|
+
tag: "div",
|
|
372
|
+
attrs: { class: "emvb-countdown-clock" },
|
|
373
|
+
children: [
|
|
374
|
+
{
|
|
375
|
+
tag: "div",
|
|
376
|
+
attrs: { class: "emvb-countdown-units", "aria-hidden": "true" },
|
|
377
|
+
children: units.map(([unit, name]): VNode => ({
|
|
378
|
+
tag: "span",
|
|
379
|
+
attrs: { class: "emvb-countdown-unit" },
|
|
380
|
+
children: [
|
|
381
|
+
{
|
|
382
|
+
tag: "span",
|
|
383
|
+
attrs: { class: "emvb-countdown-num", "data-unit": unit },
|
|
384
|
+
children: ["00"],
|
|
385
|
+
},
|
|
386
|
+
{ tag: "span", attrs: { class: "emvb-countdown-name" }, children: [name] },
|
|
387
|
+
],
|
|
388
|
+
})),
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
tag: "button",
|
|
392
|
+
attrs: { type: "button", class: "emvb-countdown-pause", "aria-pressed": "false" },
|
|
393
|
+
children: ["Pause"],
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
});
|
|
397
|
+
const action = expired ?? "text";
|
|
398
|
+
if (action !== "hide") {
|
|
399
|
+
const words = expiredText?.trim() || "This offer has ended.";
|
|
400
|
+
const href = action === "link" && expiredHref ? sanitizeHref(expiredHref) : undefined;
|
|
401
|
+
children.push({
|
|
402
|
+
tag: "p",
|
|
403
|
+
attrs: { class: "emvb-countdown-expired" },
|
|
404
|
+
children: [href ? { tag: "a", attrs: { href }, children: [words] } : words],
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
tag: "div",
|
|
409
|
+
attrs: {
|
|
410
|
+
...attrs,
|
|
411
|
+
"data-emvb-countdown": "",
|
|
412
|
+
"data-target": target,
|
|
413
|
+
"data-expired": action,
|
|
414
|
+
},
|
|
415
|
+
children,
|
|
416
|
+
};
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
const MAP_NAMES = { osm: "OpenStreetMap", google: "Google Maps" } as const;
|
|
421
|
+
|
|
422
|
+
/** A coordinate with at most 6 decimals (about 10 cm). */
|
|
423
|
+
const coord = (value: number) => String(Math.round(value * 1e6) / 1e6);
|
|
424
|
+
|
|
425
|
+
/** W-1041: where a Map's link goes and what its embed loads (undefined: it can't be embedded). */
|
|
426
|
+
function mapUrls(props: MapNode["props"]): { link: string; embed?: string } {
|
|
427
|
+
const { address, lat, lng } = props;
|
|
428
|
+
const zoom = props.zoom ?? 15;
|
|
429
|
+
const at = lat !== undefined && lng !== undefined ? [coord(lat), coord(lng)] : undefined;
|
|
430
|
+
const query = encodeURIComponent(address.trim());
|
|
431
|
+
if ((props.provider ?? "osm") === "google") {
|
|
432
|
+
const q = at ? `${at[0]},${at[1]}` : query;
|
|
433
|
+
return {
|
|
434
|
+
link: `https://www.google.com/maps/search/?api=1&query=${q}`,
|
|
435
|
+
embed: `https://www.google.com/maps?q=${q}&z=${zoom}&output=embed`,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
if (!at) return { link: `https://www.openstreetmap.org/search?query=${query}` };
|
|
439
|
+
const [la, lo] = at;
|
|
440
|
+
// A box around the place, about as wide as the zoom level shows.
|
|
441
|
+
const span = 360 / 2 ** zoom;
|
|
442
|
+
const box = [
|
|
443
|
+
Number(lo) - span,
|
|
444
|
+
Number(la) - span / 2,
|
|
445
|
+
Number(lo) + span,
|
|
446
|
+
Number(la) + span / 2,
|
|
447
|
+
].map(coord);
|
|
448
|
+
return {
|
|
449
|
+
link: `https://www.openstreetmap.org/?mlat=${la}&mlon=${lo}#map=${zoom}/${la}/${lo}`,
|
|
450
|
+
embed: `https://www.openstreetmap.org/export/embed.html?bbox=${box.join("%2C")}&layer=mapnik&marker=${la}%2C${lo}`,
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export const map: ElementDefinition<MapNode> = {
|
|
455
|
+
baseCss:
|
|
456
|
+
".emvb-map-address{margin:0 0 0.25em;white-space:pre-line}.emvb-map-frame{margin:0.75em 0 0}.emvb-map:not([data-emvb-ready]) .emvb-map-frame{display:none}.emvb-map-load{padding:0.5em 1em;border:1px solid currentColor;border-radius:4px;background:none;color:inherit;font:inherit;cursor:pointer}.emvb-map-load:focus-visible{outline:2px solid currentColor;outline-offset:2px}.emvb-map-note{margin:0.25em 0 0;font-size:0.875em}.emvb-map iframe{display:block;width:100%;border:0}",
|
|
457
|
+
defaults: () => ({
|
|
458
|
+
type: "map",
|
|
459
|
+
props: { address: "Tour Eiffel, Paris", lat: 48.8584, lng: 2.2945 },
|
|
460
|
+
}),
|
|
461
|
+
descriptor: {
|
|
462
|
+
type: "map",
|
|
463
|
+
name: "Map",
|
|
464
|
+
group: "content",
|
|
465
|
+
defaultTab: "content",
|
|
466
|
+
fields: [
|
|
467
|
+
{ key: "address", kind: "textarea", label: "Address" },
|
|
468
|
+
{
|
|
469
|
+
key: "provider",
|
|
470
|
+
kind: "select",
|
|
471
|
+
label: "Map service",
|
|
472
|
+
optional: true,
|
|
473
|
+
options: [
|
|
474
|
+
{ value: "osm", label: "OpenStreetMap" },
|
|
475
|
+
{ value: "google", label: "Google Maps" },
|
|
476
|
+
],
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
key: "lat",
|
|
480
|
+
kind: "decimal",
|
|
481
|
+
label: "Latitude",
|
|
482
|
+
optional: true,
|
|
483
|
+
min: -90,
|
|
484
|
+
max: 90,
|
|
485
|
+
message: "From -90 to 90, such as 48.8584.",
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
key: "lng",
|
|
489
|
+
kind: "decimal",
|
|
490
|
+
label: "Longitude",
|
|
491
|
+
optional: true,
|
|
492
|
+
min: -180,
|
|
493
|
+
max: 180,
|
|
494
|
+
message: "From -180 to 180, such as 2.2945.",
|
|
495
|
+
},
|
|
496
|
+
{ key: "zoom", kind: "int", label: "Zoom", optional: true, min: 1, max: 19 },
|
|
497
|
+
{ key: "linkText", kind: "text", label: "Link text", optional: true },
|
|
498
|
+
{
|
|
499
|
+
key: "embed",
|
|
500
|
+
kind: "boolean",
|
|
501
|
+
label: "Visitors can load the map on the page",
|
|
502
|
+
optional: true,
|
|
503
|
+
},
|
|
504
|
+
{ key: "height", kind: "int", label: "Map height (px)", optional: true, min: 150, max: 800 },
|
|
505
|
+
],
|
|
506
|
+
},
|
|
507
|
+
build: (node, attrs) => {
|
|
508
|
+
const { address, provider, linkText, embed, height } = node.props;
|
|
509
|
+
const service = MAP_NAMES[provider ?? "osm"];
|
|
510
|
+
const urls = mapUrls(node.props);
|
|
511
|
+
const children: VNode[] = [
|
|
512
|
+
{ tag: "p", attrs: { class: "emvb-map-address" }, children: [address] },
|
|
513
|
+
{
|
|
514
|
+
tag: "a",
|
|
515
|
+
attrs: { class: "emvb-map-link", href: urls.link, rel: "noopener" },
|
|
516
|
+
children: [linkText?.trim() || `Open in ${service}`],
|
|
517
|
+
},
|
|
518
|
+
];
|
|
519
|
+
if (!embed || !urls.embed) return { tag: "div", attrs, children };
|
|
520
|
+
children.push({
|
|
521
|
+
tag: "div",
|
|
522
|
+
attrs: {
|
|
523
|
+
class: "emvb-map-frame",
|
|
524
|
+
"data-src": urls.embed,
|
|
525
|
+
"data-title": `Map of ${address.split("\n")[0]?.trim() ?? address}`,
|
|
526
|
+
"data-height": String(height ?? 360),
|
|
527
|
+
},
|
|
528
|
+
children: [
|
|
529
|
+
{
|
|
530
|
+
tag: "button",
|
|
531
|
+
attrs: { type: "button", class: "emvb-map-load" },
|
|
532
|
+
children: ["Show the map"],
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
tag: "p",
|
|
536
|
+
attrs: { class: "emvb-map-note" },
|
|
537
|
+
children: [`Loads a map from ${service}.`],
|
|
538
|
+
},
|
|
539
|
+
],
|
|
540
|
+
});
|
|
541
|
+
return { tag: "div", attrs: { ...attrs, "data-emvb-map": "" }, children };
|
|
542
|
+
},
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
/** A small stroke icon on a 24 × 24 grid, hidden from screen readers. */
|
|
546
|
+
const mark = (className: string, d: string): VNode => ({
|
|
547
|
+
tag: "svg",
|
|
548
|
+
attrs: {
|
|
549
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
550
|
+
class: className,
|
|
551
|
+
width: "16",
|
|
552
|
+
height: "16",
|
|
553
|
+
viewBox: "0 0 24 24",
|
|
554
|
+
fill: "none",
|
|
555
|
+
stroke: "currentColor",
|
|
556
|
+
"stroke-width": "2.5",
|
|
557
|
+
"stroke-linecap": "round",
|
|
558
|
+
"stroke-linejoin": "round",
|
|
559
|
+
"aria-hidden": "true",
|
|
560
|
+
focusable: "false",
|
|
561
|
+
},
|
|
562
|
+
children: [{ tag: "path", attrs: { d }, children: [] }],
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
/** Words screen readers hear that the eye doesn't need. */
|
|
566
|
+
const srText = (className: string, text: string): VNode => ({
|
|
567
|
+
tag: "span",
|
|
568
|
+
attrs: { class: className },
|
|
569
|
+
children: [text],
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
/** W-1042: a link the visitor can follow: sanitised, opening a new tab safely when asked. */
|
|
573
|
+
function linkAttrs(href: string | undefined, newTab?: boolean): Record<string, string> | undefined {
|
|
574
|
+
const safe = href ? sanitizeHref(href) : undefined;
|
|
575
|
+
if (!safe) return undefined;
|
|
576
|
+
return newTab ? { href: safe, target: "_blank", rel: "noopener noreferrer" } : { href: safe };
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export const priceTable: ElementDefinition<PriceTableNode> = {
|
|
580
|
+
baseCss: `.emvb-price-table{position:relative;display:flex;flex-direction:column;gap:0.75em;padding:1.5em;border:1px solid rgb(0 0 0 / 0.15);border-radius:8px}.emvb-price-table-featured{border-width:2px;border-color:currentColor}.emvb-price-table-ribbon{position:absolute;top:0;right:1.5em;transform:translateY(-50%);margin:0;padding:0.125em 0.75em;border-radius:999px;background:#1f2937;color:#fff;font-size:0.75em;font-weight:600;text-transform:uppercase;letter-spacing:0.05em}.emvb-price-table-title{margin:0}.emvb-price-table-desc{margin:0}.emvb-price-table-price{display:flex;flex-wrap:wrap;align-items:baseline;gap:0.25em 0.5em;margin:0}.emvb-price-table-amount{font-size:2.5em;font-weight:700;line-height:1}.emvb-price-table-currency{font-size:0.5em;vertical-align:super}.emvb-price-table-regular{opacity:0.7}.emvb-price-table-features{display:flex;flex-direction:column;gap:0.5em;margin:0;padding:0;list-style:none}.emvb-price-table-features li{display:flex;gap:0.5em;align-items:baseline}.emvb-price-table-features svg{flex:none;align-self:center}.emvb-price-table-no{opacity:0.6}.emvb-price-table-no .emvb-price-table-text{text-decoration:line-through}.emvb-price-table-button{display:inline-flex;align-items:center;justify-content:center;margin-top:auto;padding:0.625em 1.25em;border:1px solid currentColor;border-radius:6px;color:inherit;font:inherit;text-decoration:none;text-align:center}.emvb-price-table-button:focus-visible{outline:2px solid currentColor;outline-offset:2px}.emvb-price-table-sr{${SR_ONLY}}`,
|
|
581
|
+
defaults: () => ({
|
|
582
|
+
type: "price-table",
|
|
583
|
+
props: {
|
|
584
|
+
title: "Pro",
|
|
585
|
+
description: "For growing teams.",
|
|
586
|
+
price: "29",
|
|
587
|
+
currency: "$",
|
|
588
|
+
period: "per month",
|
|
589
|
+
features: ["Unlimited pages", "Priority support"],
|
|
590
|
+
excluded: ["Custom domain"],
|
|
591
|
+
buttonText: "Choose Pro",
|
|
592
|
+
buttonHref: "/signup",
|
|
593
|
+
featured: true,
|
|
594
|
+
},
|
|
595
|
+
}),
|
|
596
|
+
descriptor: {
|
|
597
|
+
type: "price-table",
|
|
598
|
+
name: "Price table",
|
|
599
|
+
group: "content",
|
|
600
|
+
defaultTab: "content",
|
|
601
|
+
fields: [
|
|
602
|
+
{ key: "title", kind: "text", label: "Title" },
|
|
603
|
+
{
|
|
604
|
+
key: "titleLevel",
|
|
605
|
+
kind: "select",
|
|
606
|
+
label: "Title level",
|
|
607
|
+
optional: true,
|
|
608
|
+
options: [2, 3, 4, 5, 6].map((level) => ({ value: level, label: `H${level}` })),
|
|
609
|
+
},
|
|
610
|
+
{ key: "description", kind: "textarea", label: "Description", optional: true },
|
|
611
|
+
{ key: "currency", kind: "text", label: "Currency", optional: true },
|
|
612
|
+
{ key: "price", kind: "text", label: "Price", message: "Such as 29, 29.99 or Free." },
|
|
613
|
+
{
|
|
614
|
+
key: "period",
|
|
615
|
+
kind: "text",
|
|
616
|
+
label: "Period",
|
|
617
|
+
optional: true,
|
|
618
|
+
message: "Such as per month.",
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
key: "regularPrice",
|
|
622
|
+
kind: "text",
|
|
623
|
+
label: "Regular price (on sale)",
|
|
624
|
+
optional: true,
|
|
625
|
+
message: "Shown struck through before the price.",
|
|
626
|
+
},
|
|
627
|
+
{ key: "features", kind: "list-items", label: "Included", optional: true },
|
|
628
|
+
{ key: "excluded", kind: "list-items", label: "Not included", optional: true },
|
|
629
|
+
{ key: "buttonText", kind: "text", label: "Button text", optional: true },
|
|
630
|
+
{
|
|
631
|
+
key: "buttonHref",
|
|
632
|
+
kind: "href",
|
|
633
|
+
label: "Button link",
|
|
634
|
+
optional: true,
|
|
635
|
+
message: "Use a full URL such as https://example.com or a path such as /signup.",
|
|
636
|
+
},
|
|
637
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true },
|
|
638
|
+
{ key: "featured", kind: "boolean", label: "Featured", optional: true },
|
|
639
|
+
{ key: "ribbon", kind: "text", label: "Ribbon text", optional: true },
|
|
640
|
+
],
|
|
641
|
+
},
|
|
642
|
+
build: (node, attrs) => {
|
|
643
|
+
const p = node.props;
|
|
644
|
+
const children: VNode[] = [];
|
|
645
|
+
if (p.featured)
|
|
646
|
+
children.push({
|
|
647
|
+
tag: "p",
|
|
648
|
+
attrs: { class: "emvb-price-table-ribbon" },
|
|
649
|
+
children: [p.ribbon?.trim() || "Featured"],
|
|
650
|
+
});
|
|
651
|
+
children.push({
|
|
652
|
+
tag: `h${p.titleLevel ?? 3}`,
|
|
653
|
+
attrs: { class: "emvb-price-table-title" },
|
|
654
|
+
children: [p.title],
|
|
655
|
+
});
|
|
656
|
+
if (p.description?.trim())
|
|
657
|
+
children.push({
|
|
658
|
+
tag: "p",
|
|
659
|
+
attrs: { class: "emvb-price-table-desc" },
|
|
660
|
+
children: [p.description],
|
|
661
|
+
});
|
|
662
|
+
const currency = p.currency?.trim();
|
|
663
|
+
const regular = p.regularPrice?.trim();
|
|
664
|
+
const price: VNode[] = [];
|
|
665
|
+
if (regular)
|
|
666
|
+
price.push({
|
|
667
|
+
tag: "s",
|
|
668
|
+
attrs: { class: "emvb-price-table-regular" },
|
|
669
|
+
children: [srText("emvb-price-table-sr", "Regular price: "), `${currency ?? ""}${regular}`],
|
|
670
|
+
});
|
|
671
|
+
price.push({
|
|
672
|
+
tag: "span",
|
|
673
|
+
attrs: { class: "emvb-price-table-amount" },
|
|
674
|
+
children: [
|
|
675
|
+
...(regular ? [srText("emvb-price-table-sr", "Sale price: ")] : []),
|
|
676
|
+
...(currency
|
|
677
|
+
? [{ tag: "span", attrs: { class: "emvb-price-table-currency" }, children: [currency] }]
|
|
678
|
+
: []),
|
|
679
|
+
p.price,
|
|
680
|
+
],
|
|
681
|
+
});
|
|
682
|
+
if (p.period?.trim())
|
|
683
|
+
price.push({
|
|
684
|
+
tag: "span",
|
|
685
|
+
attrs: { class: "emvb-price-table-period" },
|
|
686
|
+
children: [p.period],
|
|
687
|
+
});
|
|
688
|
+
children.push({ tag: "p", attrs: { class: "emvb-price-table-price" }, children: price });
|
|
689
|
+
const items: VNode[] = [];
|
|
690
|
+
for (const feature of p.features ?? []) {
|
|
691
|
+
if (!feature.trim()) continue;
|
|
692
|
+
items.push({
|
|
693
|
+
tag: "li",
|
|
694
|
+
attrs: { class: "emvb-price-table-yes" },
|
|
695
|
+
children: [
|
|
696
|
+
mark("emvb-price-table-check", "M20 6 9 17l-5-5"),
|
|
697
|
+
{ tag: "span", attrs: { class: "emvb-price-table-text" }, children: [feature] },
|
|
698
|
+
],
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
for (const feature of p.excluded ?? []) {
|
|
702
|
+
if (!feature.trim()) continue;
|
|
703
|
+
items.push({
|
|
704
|
+
tag: "li",
|
|
705
|
+
attrs: { class: "emvb-price-table-no" },
|
|
706
|
+
children: [
|
|
707
|
+
mark("emvb-price-table-cross", "M18 6 6 18M6 6l12 12"),
|
|
708
|
+
srText("emvb-price-table-sr", "Not included: "),
|
|
709
|
+
{ tag: "span", attrs: { class: "emvb-price-table-text" }, children: [feature] },
|
|
710
|
+
],
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
if (items.length > 0)
|
|
714
|
+
children.push({ tag: "ul", attrs: { class: "emvb-price-table-features" }, children: items });
|
|
715
|
+
const link = linkAttrs(p.buttonHref, p.newTab);
|
|
716
|
+
if (p.buttonText?.trim() && link)
|
|
717
|
+
children.push({
|
|
718
|
+
tag: "a",
|
|
719
|
+
attrs: { class: "emvb-price-table-button", ...link },
|
|
720
|
+
children: [p.buttonText],
|
|
721
|
+
});
|
|
722
|
+
return {
|
|
723
|
+
tag: "div",
|
|
724
|
+
attrs: p.featured
|
|
725
|
+
? { ...attrs, class: `${attrs["class"] ?? ""} emvb-price-table-featured`.trim() }
|
|
726
|
+
: attrs,
|
|
727
|
+
children,
|
|
728
|
+
};
|
|
729
|
+
},
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
export const priceList: ElementDefinition<PriceListNode> = {
|
|
733
|
+
baseCss:
|
|
734
|
+
".emvb-price-list{display:flex;flex-direction:column;gap:1em;margin:0;padding:0;list-style:none}.emvb-price-list-item{display:flex;gap:1em;align-items:flex-start}.emvb-price-list-image{flex:none;width:4em;height:4em;object-fit:cover;border-radius:6px}.emvb-price-list-body{flex:1;min-width:0}.emvb-price-list-head{display:flex;align-items:baseline;gap:0.5em;margin:0;font-weight:600}.emvb-price-list-title a{color:inherit}.emvb-price-list-leader{flex:1;min-width:1em;border-bottom:2px dotted currentColor;opacity:0.5}.emvb-price-list-price{flex:none}.emvb-price-list-desc{margin:0.25em 0 0;opacity:0.8}",
|
|
735
|
+
defaults: () => ({ type: "price-list", props: {}, children: [] }),
|
|
736
|
+
descriptor: {
|
|
737
|
+
type: "price-list",
|
|
738
|
+
name: "Price list",
|
|
739
|
+
group: "content",
|
|
740
|
+
defaultTab: "content",
|
|
741
|
+
fields: [
|
|
742
|
+
{
|
|
743
|
+
key: "label",
|
|
744
|
+
kind: "text",
|
|
745
|
+
label: "List name",
|
|
746
|
+
optional: true,
|
|
747
|
+
message: "What screen readers call the list, such as Drinks. Leave it empty for none.",
|
|
748
|
+
},
|
|
749
|
+
],
|
|
750
|
+
},
|
|
751
|
+
build: (node, attrs, children) => ({
|
|
752
|
+
tag: "ul",
|
|
753
|
+
attrs: node.props.label?.trim() ? { ...attrs, "aria-label": node.props.label } : attrs,
|
|
754
|
+
children,
|
|
755
|
+
}),
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
export const priceListItem: ElementDefinition<PriceListItemNode> = {
|
|
759
|
+
baseCss: "",
|
|
760
|
+
defaults: () => ({
|
|
761
|
+
type: "price-list-item",
|
|
762
|
+
props: { title: "Item", price: "$10" },
|
|
763
|
+
}),
|
|
764
|
+
descriptor: {
|
|
765
|
+
type: "price-list-item",
|
|
766
|
+
name: "Price list item",
|
|
767
|
+
group: "content",
|
|
768
|
+
defaultTab: "content",
|
|
769
|
+
fields: [
|
|
770
|
+
{ key: "title", kind: "text", label: "Title" },
|
|
771
|
+
{ key: "price", kind: "text", label: "Price", message: "Such as $12 or 12 €." },
|
|
772
|
+
{ key: "description", kind: "textarea", label: "Description", optional: true },
|
|
773
|
+
{ key: "src", kind: "media", label: "Picture", optional: true },
|
|
774
|
+
{
|
|
775
|
+
key: "alt",
|
|
776
|
+
kind: "text",
|
|
777
|
+
label: "Alt text",
|
|
778
|
+
optional: true,
|
|
779
|
+
message: "Leave it empty when the picture only decorates the row.",
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
key: "href",
|
|
783
|
+
kind: "href",
|
|
784
|
+
label: "Link",
|
|
785
|
+
optional: true,
|
|
786
|
+
message: "Use a full URL such as https://example.com or a path such as /menu.",
|
|
787
|
+
},
|
|
788
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true },
|
|
789
|
+
],
|
|
790
|
+
},
|
|
791
|
+
build: (node, attrs) => {
|
|
792
|
+
const p = node.props;
|
|
793
|
+
const src = p.src?.trim() ? sanitizeMediaUrl(p.src.trim()) : undefined;
|
|
794
|
+
const link = linkAttrs(p.href, p.newTab);
|
|
795
|
+
const children: VNode[] = [];
|
|
796
|
+
if (src)
|
|
797
|
+
children.push({
|
|
798
|
+
tag: "img",
|
|
799
|
+
attrs: {
|
|
800
|
+
class: "emvb-price-list-image",
|
|
801
|
+
src,
|
|
802
|
+
alt: p.alt?.trim() ?? "",
|
|
803
|
+
...(p.width ? { width: String(p.width) } : {}),
|
|
804
|
+
...(p.height ? { height: String(p.height) } : {}),
|
|
805
|
+
loading: "lazy",
|
|
806
|
+
decoding: "async",
|
|
807
|
+
},
|
|
808
|
+
children: [],
|
|
809
|
+
});
|
|
810
|
+
const body: VNode[] = [
|
|
811
|
+
{
|
|
812
|
+
tag: "p",
|
|
813
|
+
attrs: { class: "emvb-price-list-head" },
|
|
814
|
+
children: [
|
|
815
|
+
{
|
|
816
|
+
tag: "span",
|
|
817
|
+
attrs: { class: "emvb-price-list-title" },
|
|
818
|
+
children: [link ? { tag: "a", attrs: link, children: [p.title] } : p.title],
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
tag: "span",
|
|
822
|
+
attrs: { class: "emvb-price-list-leader", "aria-hidden": "true" },
|
|
823
|
+
children: [],
|
|
824
|
+
},
|
|
825
|
+
{ tag: "span", attrs: { class: "emvb-price-list-price" }, children: [p.price] },
|
|
826
|
+
],
|
|
827
|
+
},
|
|
828
|
+
];
|
|
829
|
+
if (p.description?.trim())
|
|
830
|
+
body.push({ tag: "p", attrs: { class: "emvb-price-list-desc" }, children: [p.description] });
|
|
831
|
+
children.push({ tag: "div", attrs: { class: "emvb-price-list-body" }, children: body });
|
|
832
|
+
return { tag: "li", attrs, children };
|
|
833
|
+
},
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
export const cta: ElementDefinition<CtaNode> = {
|
|
837
|
+
baseCss:
|
|
838
|
+
'.emvb-cta{position:relative;display:flex;flex-direction:column;gap:1em;overflow:hidden;border-radius:8px;min-width:0}.emvb-cta-left{flex-direction:row;align-items:center}.emvb-cta-right{flex-direction:row-reverse;align-items:center}.emvb-cta-media{flex:none;line-height:0}.emvb-cta-media img{display:block;width:100%;height:100%;object-fit:cover}.emvb-cta:is(.emvb-cta-left,.emvb-cta-right) .emvb-cta-media{flex-basis:40%;max-width:40%;align-self:stretch}.emvb-cta-body{position:relative;flex:1;min-width:0;display:flex;flex-direction:column;align-items:flex-start;gap:0.75em;padding:1.5em}.emvb-cta-behind{justify-content:center;min-height:16em;color:#fff}.emvb-cta-behind .emvb-cta-media{position:absolute;inset:0}.emvb-cta-behind .emvb-cta-media::after{content:"";position:absolute;inset:0;background:rgb(0 0 0 / 0.55)}.emvb-cta-title{margin:0;font-size:1.5em}.emvb-cta-text{margin:0;white-space:pre-line}.emvb-cta-link{color:inherit;text-decoration:none}.emvb-cta-link::after{content:"";position:absolute;inset:0;z-index:1}.emvb-cta-linked .emvb-cta-body{position:static}.emvb-cta-linked:has(.emvb-cta-link:focus-visible){outline:2px solid currentColor;outline-offset:4px}.emvb-cta-link:focus-visible{outline:none}.emvb-cta-button{display:inline-flex;padding:0.625em 1.25em;border:1px solid currentColor;border-radius:6px}.emvb-cta-ribbon{position:absolute;top:0.75em;right:0.75em;z-index:2;margin:0;padding:0.125em 0.75em;border-radius:999px;background:#1f2937;color:#fff;font-size:0.75em;font-weight:600;text-transform:uppercase;letter-spacing:0.05em}',
|
|
839
|
+
defaults: () => ({
|
|
840
|
+
type: "cta",
|
|
841
|
+
props: {
|
|
842
|
+
title: "Ready to start?",
|
|
843
|
+
text: "Create your first page in minutes.",
|
|
844
|
+
buttonText: "Get started",
|
|
845
|
+
href: "/signup",
|
|
846
|
+
layout: "top",
|
|
847
|
+
},
|
|
848
|
+
}),
|
|
849
|
+
descriptor: {
|
|
850
|
+
type: "cta",
|
|
851
|
+
name: "Call to action",
|
|
852
|
+
group: "content",
|
|
853
|
+
defaultTab: "content",
|
|
854
|
+
fields: [
|
|
855
|
+
{ key: "title", kind: "text", label: "Title" },
|
|
856
|
+
{
|
|
857
|
+
key: "titleLevel",
|
|
858
|
+
kind: "select",
|
|
859
|
+
label: "Title level",
|
|
860
|
+
optional: true,
|
|
861
|
+
options: [2, 3, 4, 5, 6].map((level) => ({ value: level, label: `H${level}` })),
|
|
862
|
+
},
|
|
863
|
+
{ key: "text", kind: "textarea", label: "Text", optional: true },
|
|
864
|
+
{ key: "src", kind: "media", label: "Picture", optional: true },
|
|
865
|
+
{
|
|
866
|
+
key: "alt",
|
|
867
|
+
kind: "text",
|
|
868
|
+
label: "Alt text",
|
|
869
|
+
optional: true,
|
|
870
|
+
message: "Leave it empty when the picture only sets the mood.",
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
key: "layout",
|
|
874
|
+
kind: "select",
|
|
875
|
+
label: "Picture",
|
|
876
|
+
optional: true,
|
|
877
|
+
options: [
|
|
878
|
+
{ value: "behind", label: "Behind the text" },
|
|
879
|
+
{ value: "top", label: "Above" },
|
|
880
|
+
{ value: "left", label: "Before" },
|
|
881
|
+
{ value: "right", label: "After" },
|
|
882
|
+
],
|
|
883
|
+
},
|
|
884
|
+
{ key: "buttonText", kind: "text", label: "Button text", optional: true },
|
|
885
|
+
{
|
|
886
|
+
key: "href",
|
|
887
|
+
kind: "href",
|
|
888
|
+
label: "Link",
|
|
889
|
+
optional: true,
|
|
890
|
+
message: "The whole box opens it. Use a full URL or a path such as /signup.",
|
|
891
|
+
},
|
|
892
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true },
|
|
893
|
+
{ key: "ribbon", kind: "text", label: "Ribbon text", optional: true },
|
|
894
|
+
],
|
|
895
|
+
},
|
|
896
|
+
build: (node, attrs) => {
|
|
897
|
+
const p = node.props;
|
|
898
|
+
const layout = p.layout ?? "behind";
|
|
899
|
+
const src = p.src?.trim() ? sanitizeMediaUrl(p.src.trim()) : undefined;
|
|
900
|
+
const link = linkAttrs(p.href, p.newTab);
|
|
901
|
+
const children: VNode[] = [];
|
|
902
|
+
if (p.ribbon?.trim())
|
|
903
|
+
children.push({ tag: "p", attrs: { class: "emvb-cta-ribbon" }, children: [p.ribbon] });
|
|
904
|
+
if (src)
|
|
905
|
+
children.push({
|
|
906
|
+
tag: "div",
|
|
907
|
+
attrs: { class: "emvb-cta-media" },
|
|
908
|
+
children: [
|
|
909
|
+
{
|
|
910
|
+
tag: "img",
|
|
911
|
+
attrs: {
|
|
912
|
+
src,
|
|
913
|
+
alt: p.alt?.trim() ?? "",
|
|
914
|
+
...(p.width ? { width: String(p.width) } : {}),
|
|
915
|
+
...(p.height ? { height: String(p.height) } : {}),
|
|
916
|
+
loading: "lazy",
|
|
917
|
+
decoding: "async",
|
|
918
|
+
},
|
|
919
|
+
children: [],
|
|
920
|
+
},
|
|
921
|
+
],
|
|
922
|
+
});
|
|
923
|
+
const body: VNode[] = [
|
|
924
|
+
{
|
|
925
|
+
tag: `h${p.titleLevel ?? 3}`,
|
|
926
|
+
attrs: { class: "emvb-cta-title" },
|
|
927
|
+
children: [
|
|
928
|
+
link
|
|
929
|
+
? { tag: "a", attrs: { class: "emvb-cta-link", ...link }, children: [p.title] }
|
|
930
|
+
: p.title,
|
|
931
|
+
],
|
|
932
|
+
},
|
|
933
|
+
];
|
|
934
|
+
if (p.text?.trim())
|
|
935
|
+
body.push({ tag: "p", attrs: { class: "emvb-cta-text" }, children: [p.text] });
|
|
936
|
+
// The title is the link; the button shows where the box leads, for the eye only.
|
|
937
|
+
if (link && p.buttonText?.trim())
|
|
938
|
+
body.push({
|
|
939
|
+
tag: "span",
|
|
940
|
+
attrs: { class: "emvb-cta-button", "aria-hidden": "true" },
|
|
941
|
+
children: [p.buttonText],
|
|
942
|
+
});
|
|
943
|
+
children.push({ tag: "div", attrs: { class: "emvb-cta-body" }, children: body });
|
|
944
|
+
const classes = [attrs["class"] ?? "", `emvb-cta-${src ? layout : "top"}`];
|
|
945
|
+
if (link) classes.push("emvb-cta-linked");
|
|
946
|
+
return { tag: "div", attrs: { ...attrs, class: classes.join(" ").trim() }, children };
|
|
947
|
+
},
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
const FLIP_TURNS = {
|
|
951
|
+
left: "rotateY(-180deg)",
|
|
952
|
+
right: "rotateY(180deg)",
|
|
953
|
+
up: "rotateX(180deg)",
|
|
954
|
+
down: "rotateX(-180deg)",
|
|
955
|
+
} as const;
|
|
956
|
+
|
|
957
|
+
export const flipBox: ElementDefinition<FlipBoxNode> = {
|
|
958
|
+
baseCss:
|
|
959
|
+
":where(.emvb-flip-box){color:#fff;border-radius:8px}.emvb-flip-box{position:relative;perspective:1200px}.emvb-flip-inner{display:grid;transition:transform 0.6s ease;transform-style:preserve-3d}.emvb-flip-face{grid-area:1/1;display:flex;flex-direction:column;justify-content:center;gap:0.75em;min-height:16em;padding:1.5em 1.5em 3em;border-radius:inherit;background:#1f2937;color:inherit;backface-visibility:hidden;-webkit-backface-visibility:hidden}.emvb-flip-back{background:#374151}.emvb-flip-title{margin:0;font-size:1.25em}.emvb-flip-text{margin:0;white-space:pre-line}.emvb-flip-button{align-self:flex-start;padding:0.625em 1.25em;border:1px solid currentColor;border-radius:6px;color:inherit;text-decoration:none}.emvb-flip-button:focus-visible{outline:2px solid currentColor;outline-offset:2px}.emvb-flip-toggle{position:absolute;right:0.75em;bottom:0.75em;z-index:1;display:inline-flex;gap:0.375em;align-items:center;font-size:0.875em;cursor:pointer}.emvb-flip-check{margin:0;accent-color:currentColor}.emvb-flip-check:focus-visible{outline:2px solid currentColor;outline-offset:2px}" +
|
|
960
|
+
(Object.keys(FLIP_TURNS) as (keyof typeof FLIP_TURNS)[])
|
|
961
|
+
.map((dir) => {
|
|
962
|
+
const turn = FLIP_TURNS[dir];
|
|
963
|
+
const on = `.emvb-flip-${dir}:has(.emvb-flip-check:checked) .emvb-flip-inner,.emvb-flip-${dir}:has(.emvb-flip-back :focus-visible) .emvb-flip-inner`;
|
|
964
|
+
return `.emvb-flip-${dir} .emvb-flip-back{transform:${turn}}${on}{transform:${turn}}@media (hover:hover){.emvb-flip-${dir}:hover .emvb-flip-inner{transform:${turn}}}`;
|
|
965
|
+
})
|
|
966
|
+
.join("") +
|
|
967
|
+
"@media (prefers-reduced-motion:reduce){.emvb-flip-inner{transition:none}}",
|
|
968
|
+
defaults: () => ({
|
|
969
|
+
type: "flip-box",
|
|
970
|
+
props: {
|
|
971
|
+
frontTitle: "Hover or tap to learn more",
|
|
972
|
+
frontText: "A short teaser on the front.",
|
|
973
|
+
backTitle: "Here is the detail",
|
|
974
|
+
backText: "The back says more and can link somewhere.",
|
|
975
|
+
buttonText: "Read more",
|
|
976
|
+
href: "/about",
|
|
977
|
+
},
|
|
978
|
+
}),
|
|
979
|
+
descriptor: {
|
|
980
|
+
type: "flip-box",
|
|
981
|
+
name: "Flip box",
|
|
982
|
+
group: "content",
|
|
983
|
+
defaultTab: "content",
|
|
984
|
+
fields: [
|
|
985
|
+
{ key: "frontTitle", kind: "text", label: "Front title" },
|
|
986
|
+
{ key: "frontText", kind: "textarea", label: "Front text", optional: true },
|
|
987
|
+
{ key: "backTitle", kind: "text", label: "Back title", optional: true },
|
|
988
|
+
{ key: "backText", kind: "textarea", label: "Back text", optional: true },
|
|
989
|
+
{
|
|
990
|
+
key: "titleLevel",
|
|
991
|
+
kind: "select",
|
|
992
|
+
label: "Title level",
|
|
993
|
+
optional: true,
|
|
994
|
+
options: [2, 3, 4, 5, 6].map((level) => ({ value: level, label: `H${level}` })),
|
|
995
|
+
},
|
|
996
|
+
{ key: "buttonText", kind: "text", label: "Button text", optional: true },
|
|
997
|
+
{
|
|
998
|
+
key: "href",
|
|
999
|
+
kind: "href",
|
|
1000
|
+
label: "Button link",
|
|
1001
|
+
optional: true,
|
|
1002
|
+
message: "Use a full URL such as https://example.com or a path such as /about.",
|
|
1003
|
+
},
|
|
1004
|
+
{ key: "newTab", kind: "boolean", label: "Open in a new tab", optional: true },
|
|
1005
|
+
{
|
|
1006
|
+
key: "direction",
|
|
1007
|
+
kind: "select",
|
|
1008
|
+
label: "Turns",
|
|
1009
|
+
optional: true,
|
|
1010
|
+
options: [
|
|
1011
|
+
{ value: "right", label: "Right" },
|
|
1012
|
+
{ value: "left", label: "Left" },
|
|
1013
|
+
{ value: "up", label: "Up" },
|
|
1014
|
+
{ value: "down", label: "Down" },
|
|
1015
|
+
],
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
key: "toggleLabel",
|
|
1019
|
+
kind: "text",
|
|
1020
|
+
label: "Turn-over control text",
|
|
1021
|
+
optional: true,
|
|
1022
|
+
message: "The tick box that turns the card on touch screens. Leave it empty for Turn over.",
|
|
1023
|
+
},
|
|
1024
|
+
],
|
|
1025
|
+
},
|
|
1026
|
+
build: (node, attrs) => {
|
|
1027
|
+
const p = node.props;
|
|
1028
|
+
const heading = `h${p.titleLevel ?? 3}`;
|
|
1029
|
+
const face = (
|
|
1030
|
+
side: "front" | "back",
|
|
1031
|
+
title?: string,
|
|
1032
|
+
text?: string,
|
|
1033
|
+
extra: VNode[] = [],
|
|
1034
|
+
): VNode => {
|
|
1035
|
+
const children: VNode[] = [];
|
|
1036
|
+
if (title?.trim())
|
|
1037
|
+
children.push({ tag: heading, attrs: { class: "emvb-flip-title" }, children: [title] });
|
|
1038
|
+
if (text?.trim())
|
|
1039
|
+
children.push({ tag: "p", attrs: { class: "emvb-flip-text" }, children: [text] });
|
|
1040
|
+
return {
|
|
1041
|
+
tag: "div",
|
|
1042
|
+
attrs: { class: `emvb-flip-face emvb-flip-${side}` },
|
|
1043
|
+
children: [...children, ...extra],
|
|
1044
|
+
};
|
|
1045
|
+
};
|
|
1046
|
+
const link = linkAttrs(p.href, p.newTab);
|
|
1047
|
+
const button: VNode[] =
|
|
1048
|
+
link && p.buttonText?.trim()
|
|
1049
|
+
? [{ tag: "a", attrs: { class: "emvb-flip-button", ...link }, children: [p.buttonText] }]
|
|
1050
|
+
: [];
|
|
1051
|
+
return {
|
|
1052
|
+
tag: "div",
|
|
1053
|
+
attrs: {
|
|
1054
|
+
...attrs,
|
|
1055
|
+
class: `${attrs["class"] ?? ""} emvb-flip-${p.direction ?? "right"}`.trim(),
|
|
1056
|
+
},
|
|
1057
|
+
children: [
|
|
1058
|
+
{
|
|
1059
|
+
tag: "div",
|
|
1060
|
+
attrs: { class: "emvb-flip-inner" },
|
|
1061
|
+
children: [
|
|
1062
|
+
face("front", p.frontTitle, p.frontText),
|
|
1063
|
+
face("back", p.backTitle, p.backText, button),
|
|
1064
|
+
],
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
tag: "label",
|
|
1068
|
+
attrs: { class: "emvb-flip-toggle" },
|
|
1069
|
+
children: [
|
|
1070
|
+
{ tag: "input", attrs: { type: "checkbox", class: "emvb-flip-check" }, children: [] },
|
|
1071
|
+
{ tag: "span", attrs: {}, children: [p.toggleLabel?.trim() || "Turn over"] },
|
|
1072
|
+
],
|
|
1073
|
+
},
|
|
1074
|
+
],
|
|
1075
|
+
};
|
|
1076
|
+
},
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
/** The circle drawn around a highlighted word, on a 100 × 40 grid stretched to the word. */
|
|
1080
|
+
const HEADLINE_CIRCLE = "M50 3C20 2 3 10 3 20s20 18 48 17 47-8 46-17S78 3 46 4";
|
|
1081
|
+
|
|
1082
|
+
export const headline: ElementDefinition<HeadlineNode> = {
|
|
1083
|
+
baseCss: `.emvb-headline{margin:0}.emvb-headline-mark{position:relative;display:inline-block;white-space:nowrap}.emvb-headline-underline .emvb-headline-mark{background:linear-gradient(var(--emvb-headline-mark,#f59e0b),var(--emvb-headline-mark,#f59e0b)) no-repeat 0 92%/100% 0.12em}.emvb-headline-strike .emvb-headline-mark{background:linear-gradient(var(--emvb-headline-mark,#f59e0b),var(--emvb-headline-mark,#f59e0b)) no-repeat 0 55%/100% 0.1em}.emvb-headline-shape{position:absolute;left:-0.25em;top:-0.15em;width:calc(100% + 0.5em);height:calc(100% + 0.3em);overflow:visible;pointer-events:none;color:var(--emvb-headline-mark,#f59e0b)}.emvb-headline-shape path{stroke-dasharray:300;stroke-dashoffset:0}.emvb-headline-pause{margin:0.5em 0 0;padding:0.25em 0.75em;border:1px solid currentColor;border-radius:4px;background:none;color:inherit;font:inherit;font-size:0.875em;cursor:pointer}.emvb-headline-pause:focus-visible{outline:2px solid currentColor;outline-offset:2px}.emvb-headline-sr{${SR_ONLY}}@keyframes emvb-headline-line{from{background-size:0 0.12em}}@keyframes emvb-headline-strike{from{background-size:0 0.1em}}@keyframes emvb-headline-circle{from{stroke-dashoffset:300}}@media (prefers-reduced-motion:no-preference){.emvb-headline-underline .emvb-headline-mark{animation:emvb-headline-line 0.8s ease-out 0.3s both}.emvb-headline-strike .emvb-headline-mark{animation:emvb-headline-strike 0.8s ease-out 0.3s both}.emvb-headline-shape path{animation:emvb-headline-circle 1s ease-out 0.3s both}}`,
|
|
1084
|
+
defaults: () => ({
|
|
1085
|
+
type: "headline",
|
|
1086
|
+
props: {
|
|
1087
|
+
level: 2,
|
|
1088
|
+
before: "We build",
|
|
1089
|
+
highlight: "fast",
|
|
1090
|
+
after: "websites",
|
|
1091
|
+
rotate: ["accessible", "beautiful"],
|
|
1092
|
+
},
|
|
1093
|
+
}),
|
|
1094
|
+
descriptor: {
|
|
1095
|
+
type: "headline",
|
|
1096
|
+
name: "Animated headline",
|
|
1097
|
+
group: "content",
|
|
1098
|
+
defaultTab: "content",
|
|
1099
|
+
fields: [
|
|
1100
|
+
{ key: "before", kind: "text", label: "Before", optional: true },
|
|
1101
|
+
{ key: "highlight", kind: "text", label: "Highlighted words" },
|
|
1102
|
+
{ key: "after", kind: "text", label: "After", optional: true },
|
|
1103
|
+
{
|
|
1104
|
+
key: "level",
|
|
1105
|
+
kind: "select",
|
|
1106
|
+
label: "Level",
|
|
1107
|
+
optional: true,
|
|
1108
|
+
options: [1, 2, 3, 4, 5, 6].map((level) => ({ value: level, label: `H${level}` })),
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
key: "mark",
|
|
1112
|
+
kind: "select",
|
|
1113
|
+
label: "Mark",
|
|
1114
|
+
optional: true,
|
|
1115
|
+
options: [
|
|
1116
|
+
{ value: "underline", label: "Underline" },
|
|
1117
|
+
{ value: "circle", label: "Circle" },
|
|
1118
|
+
{ value: "strike", label: "Strike through" },
|
|
1119
|
+
{ value: "none", label: "None" },
|
|
1120
|
+
],
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
key: "rotate",
|
|
1124
|
+
kind: "list-items",
|
|
1125
|
+
label: "Other words",
|
|
1126
|
+
optional: true,
|
|
1127
|
+
message: "One per line. They take turns with the highlighted words.",
|
|
1128
|
+
},
|
|
1129
|
+
{ key: "rotating", kind: "boolean", label: "Rotate the words", optional: true },
|
|
1130
|
+
{
|
|
1131
|
+
key: "interval",
|
|
1132
|
+
kind: "decimal",
|
|
1133
|
+
label: "Seconds per word",
|
|
1134
|
+
optional: true,
|
|
1135
|
+
min: 1.5,
|
|
1136
|
+
max: 10,
|
|
1137
|
+
message: "From 1.5 to 10 seconds.",
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
key: "turns",
|
|
1141
|
+
kind: "int",
|
|
1142
|
+
label: "Rounds before it stops",
|
|
1143
|
+
optional: true,
|
|
1144
|
+
min: 1,
|
|
1145
|
+
max: 5,
|
|
1146
|
+
},
|
|
1147
|
+
],
|
|
1148
|
+
},
|
|
1149
|
+
build: (node, attrs) => {
|
|
1150
|
+
const p = node.props;
|
|
1151
|
+
const style = p.mark ?? "underline";
|
|
1152
|
+
const words = (p.rotate ?? []).map((w) => w.trim()).filter(Boolean);
|
|
1153
|
+
const rotating = Boolean(p.rotating) && words.length > 0;
|
|
1154
|
+
const markChildren: (VNode | string)[] = [p.highlight];
|
|
1155
|
+
if (style === "circle")
|
|
1156
|
+
markChildren.push({
|
|
1157
|
+
tag: "svg",
|
|
1158
|
+
attrs: {
|
|
1159
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1160
|
+
class: "emvb-headline-shape",
|
|
1161
|
+
viewBox: "0 0 100 40",
|
|
1162
|
+
preserveAspectRatio: "none",
|
|
1163
|
+
fill: "none",
|
|
1164
|
+
stroke: "currentColor",
|
|
1165
|
+
"stroke-width": "2.5",
|
|
1166
|
+
"stroke-linecap": "round",
|
|
1167
|
+
"aria-hidden": "true",
|
|
1168
|
+
focusable: "false",
|
|
1169
|
+
},
|
|
1170
|
+
children: [{ tag: "path", attrs: { d: HEADLINE_CIRCLE }, children: [] }],
|
|
1171
|
+
});
|
|
1172
|
+
const markAttrs: Record<string, string> = { class: "emvb-headline-mark" };
|
|
1173
|
+
if (rotating) {
|
|
1174
|
+
markAttrs["data-emvb-rotate"] = JSON.stringify([p.highlight, ...words]);
|
|
1175
|
+
markAttrs["data-interval"] = String(p.interval ?? 2.5);
|
|
1176
|
+
markAttrs["data-turns"] = String(p.turns ?? 2);
|
|
1177
|
+
}
|
|
1178
|
+
const children: (VNode | string)[] = [];
|
|
1179
|
+
if (p.before?.trim()) children.push(`${p.before.trim()} `);
|
|
1180
|
+
children.push({ tag: "span", attrs: markAttrs, children: markChildren });
|
|
1181
|
+
if (p.after?.trim()) children.push(` ${p.after.trim()}`);
|
|
1182
|
+
// The runtime adds its Pause button after the heading, so the heading reads as one sentence.
|
|
1183
|
+
return {
|
|
1184
|
+
tag: `h${p.level ?? 2}`,
|
|
1185
|
+
attrs: { ...attrs, class: `${attrs["class"] ?? ""} emvb-headline-${style}`.trim() },
|
|
1186
|
+
children,
|
|
1187
|
+
};
|
|
1188
|
+
},
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
type ShareNetwork = (typeof SHARE_NETWORKS)[number];
|
|
1192
|
+
|
|
1193
|
+
/** W-1047: each service's own share address for `url` (no tracking script, no API key). */
|
|
1194
|
+
export function shareHref(network: ShareNetwork, url: string): string {
|
|
1195
|
+
const u = encodeURIComponent(url);
|
|
1196
|
+
switch (network) {
|
|
1197
|
+
case "facebook":
|
|
1198
|
+
return `https://www.facebook.com/sharer/sharer.php?u=${u}`;
|
|
1199
|
+
case "x":
|
|
1200
|
+
return `https://x.com/intent/post?url=${u}`;
|
|
1201
|
+
case "linkedin":
|
|
1202
|
+
return `https://www.linkedin.com/sharing/share-offsite/?url=${u}`;
|
|
1203
|
+
case "whatsapp":
|
|
1204
|
+
return `https://wa.me/?text=${u}`;
|
|
1205
|
+
case "telegram":
|
|
1206
|
+
return `https://t.me/share/url?url=${u}`;
|
|
1207
|
+
case "reddit":
|
|
1208
|
+
return `https://www.reddit.com/submit?url=${u}`;
|
|
1209
|
+
case "bluesky":
|
|
1210
|
+
return `https://bsky.app/intent/compose?text=${u}`;
|
|
1211
|
+
case "threads":
|
|
1212
|
+
return `https://www.threads.net/intent/post?text=${u}`;
|
|
1213
|
+
case "email":
|
|
1214
|
+
return `mailto:?body=${u}`;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/** What screen readers call a share link: "Share on X", "Share by email". */
|
|
1219
|
+
const shareName = (network: ShareNetwork) =>
|
|
1220
|
+
network === "email" ? "Share by email" : `Share on ${SOCIAL_NAMES[network]}`;
|
|
1221
|
+
|
|
1222
|
+
export const shareButtons: ElementDefinition<ShareButtonsNode> = {
|
|
1223
|
+
baseCss:
|
|
1224
|
+
".emvb-share-buttons{display:flex;flex-wrap:wrap;align-items:center;gap:0.5em;margin:0;padding:0;list-style:none;font-size:1.5em}.emvb-share-link{display:flex}.emvb-share-link>a,.emvb-share-native{display:inline-flex;align-items:center;justify-content:center;color:inherit;text-decoration:none}.emvb-share-buttons .emvb-social-svg{display:block;width:1em;height:1em}.emvb-share-brand.emvb-share-plain .emvb-share-link>a{color:var(--emvb-social,currentColor)}.emvb-share-buttons:not(.emvb-share-plain) .emvb-share-link>a{width:2em;height:2em;background:var(--emvb-social,currentColor)}.emvb-share-buttons:not(.emvb-share-plain) .emvb-social-svg{width:1.1em;height:1.1em;color:#fff}.emvb-share-circle .emvb-share-link>a{border-radius:50%}.emvb-share-rounded .emvb-share-link>a{border-radius:0.4em}.emvb-share-link>a:focus-visible,.emvb-share-native:focus-visible{outline:2px solid currentColor;outline-offset:2px}.emvb-share-native{gap:0.375em;padding:0.25em 0.75em;border:1px solid currentColor;border-radius:999px;background:none;font:inherit;font-size:0.6em;cursor:pointer}.emvb-share-buttons:not([data-emvb-ready]) .emvb-share-native-item{display:none}" +
|
|
1225
|
+
SHARE_NETWORKS.map(
|
|
1226
|
+
(network) =>
|
|
1227
|
+
`.emvb-share-brand .emvb-share-${network}{--emvb-social:${SOCIAL_COLORS[network]}}`,
|
|
1228
|
+
).join(""),
|
|
1229
|
+
defaults: () => ({ type: "share-buttons", props: { shape: "circle" }, children: [] }),
|
|
1230
|
+
descriptor: {
|
|
1231
|
+
type: "share-buttons",
|
|
1232
|
+
name: "Share buttons",
|
|
1233
|
+
group: "content",
|
|
1234
|
+
defaultTab: "content",
|
|
1235
|
+
fields: [
|
|
1236
|
+
{
|
|
1237
|
+
key: "label",
|
|
1238
|
+
kind: "text",
|
|
1239
|
+
label: "List name",
|
|
1240
|
+
optional: true,
|
|
1241
|
+
message: "What screen readers call the list. Leave it empty for Share this page.",
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
key: "shape",
|
|
1245
|
+
kind: "select",
|
|
1246
|
+
label: "Shape",
|
|
1247
|
+
optional: true,
|
|
1248
|
+
options: [
|
|
1249
|
+
{ value: "plain", label: "Icon only" },
|
|
1250
|
+
{ value: "circle", label: "Circle" },
|
|
1251
|
+
{ value: "rounded", label: "Rounded square" },
|
|
1252
|
+
{ value: "square", label: "Square" },
|
|
1253
|
+
],
|
|
1254
|
+
},
|
|
1255
|
+
{ key: "brandColors", kind: "boolean", label: "Brand colours", optional: true },
|
|
1256
|
+
{
|
|
1257
|
+
key: "nativeShare",
|
|
1258
|
+
kind: "boolean",
|
|
1259
|
+
label: "Add the device's Share button where it has one",
|
|
1260
|
+
optional: true,
|
|
1261
|
+
},
|
|
1262
|
+
],
|
|
1263
|
+
},
|
|
1264
|
+
build: (node, attrs, children) => {
|
|
1265
|
+
const items: VNode[] = [...children];
|
|
1266
|
+
if (node.props.nativeShare)
|
|
1267
|
+
items.push({
|
|
1268
|
+
tag: "li",
|
|
1269
|
+
attrs: { class: "emvb-share-native-item" },
|
|
1270
|
+
children: [
|
|
1271
|
+
{
|
|
1272
|
+
tag: "button",
|
|
1273
|
+
attrs: { type: "button", class: "emvb-share-native", "data-emvb-share": "" },
|
|
1274
|
+
children: ["Share…"],
|
|
1275
|
+
},
|
|
1276
|
+
],
|
|
1277
|
+
});
|
|
1278
|
+
const classes = [
|
|
1279
|
+
attrs["class"] ?? "",
|
|
1280
|
+
`emvb-share-${node.props.shape ?? "plain"}`,
|
|
1281
|
+
...(node.props.brandColors ? ["emvb-share-brand"] : []),
|
|
1282
|
+
];
|
|
1283
|
+
return {
|
|
1284
|
+
tag: "ul",
|
|
1285
|
+
attrs: {
|
|
1286
|
+
...attrs,
|
|
1287
|
+
class: classes.join(" ").trim(),
|
|
1288
|
+
"aria-label": node.props.label?.trim() || "Share this page",
|
|
1289
|
+
...(node.props.nativeShare ? { "data-emvb-share-list": "" } : {}),
|
|
1290
|
+
},
|
|
1291
|
+
children: items,
|
|
1292
|
+
};
|
|
1293
|
+
},
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
/** W-1047: a share link for `url`; the renderer passes the page's address. */
|
|
1297
|
+
export function shareLinkVNode(
|
|
1298
|
+
node: ShareLinkNode,
|
|
1299
|
+
attrs: Record<string, string>,
|
|
1300
|
+
url: string,
|
|
1301
|
+
): VNode {
|
|
1302
|
+
const { network, label } = node.props;
|
|
1303
|
+
const icon = socialSvg(network);
|
|
1304
|
+
const href = sanitizeHref(shareHref(network, url)) ?? "#";
|
|
1305
|
+
return {
|
|
1306
|
+
tag: "li",
|
|
1307
|
+
attrs: { ...attrs, class: `${attrs["class"] ?? ""} emvb-share-${network}`.trim() },
|
|
1308
|
+
children: [
|
|
1309
|
+
{
|
|
1310
|
+
tag: "a",
|
|
1311
|
+
attrs: {
|
|
1312
|
+
href,
|
|
1313
|
+
"aria-label": label?.trim() || shareName(network),
|
|
1314
|
+
...(network === "email" ? {} : { target: "_blank", rel: "noopener noreferrer" }),
|
|
1315
|
+
},
|
|
1316
|
+
children: icon ? [icon] : [],
|
|
1317
|
+
},
|
|
1318
|
+
],
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
export const shareLink: ElementDefinition<ShareLinkNode> = {
|
|
1323
|
+
baseCss: "",
|
|
1324
|
+
defaults: () => ({ type: "share-link", props: { network: "facebook" } }),
|
|
1325
|
+
descriptor: {
|
|
1326
|
+
type: "share-link",
|
|
1327
|
+
name: "Share link",
|
|
1328
|
+
group: "content",
|
|
1329
|
+
defaultTab: "content",
|
|
1330
|
+
fields: [
|
|
1331
|
+
{
|
|
1332
|
+
key: "network",
|
|
1333
|
+
kind: "select",
|
|
1334
|
+
label: "Share to",
|
|
1335
|
+
options: SHARE_NETWORKS.map((value) => ({
|
|
1336
|
+
value,
|
|
1337
|
+
label: value === "email" ? "Email" : SOCIAL_NAMES[value],
|
|
1338
|
+
})),
|
|
1339
|
+
},
|
|
1340
|
+
{
|
|
1341
|
+
key: "label",
|
|
1342
|
+
kind: "text",
|
|
1343
|
+
label: "Name for screen readers",
|
|
1344
|
+
optional: true,
|
|
1345
|
+
message: "Leave it empty for Share on and the service's name.",
|
|
1346
|
+
},
|
|
1347
|
+
],
|
|
1348
|
+
},
|
|
1349
|
+
// The editor shows where it would lead from an example page; public pages use their own URL.
|
|
1350
|
+
build: (node, attrs) => shareLinkVNode(node, attrs, "https://example.com/"),
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1353
|
+
export const hotspots: ElementDefinition<HotspotsNode> = {
|
|
1354
|
+
baseCss:
|
|
1355
|
+
".emvb-hotspots{position:relative;margin:0;line-height:0}.emvb-hotspots-image{display:block;width:100%;height:auto}.emvb-hotspots-list{margin:0;padding:0;list-style:none;counter-reset:emvb-hotspot}.emvb-hotspot{position:absolute;line-height:1.4;counter-increment:emvb-hotspot;transform:translate(-50%,-50%)}.emvb-hotspot-button{display:flex;align-items:center;justify-content:center;width:2em;height:2em;padding:0;border:2px solid #fff;border-radius:50%;background:#1f2937;color:#fff;font:inherit;font-weight:700;box-shadow:0 1px 4px rgb(0 0 0 / 0.4);cursor:pointer}.emvb-hotspot-button::before{content:counter(emvb-hotspot)}.emvb-hotspot-button:focus-visible{outline:3px solid #fff;outline-offset:2px}.emvb-hotspot-note{max-width:min(20em,90vw);margin:auto;padding:0.75em 1em;border:1px solid rgb(0 0 0 / 0.2);border-radius:8px;background:#fff;color:#1f2937;line-height:1.4;box-shadow:0 4px 16px rgb(0 0 0 / 0.2)}.emvb-hotspot-title{margin:0;font-weight:600}.emvb-hotspot-text{margin:0.25em 0 0;white-space:pre-line}@supports (position-area:bottom){.emvb-hotspot-note{margin:0.5em;position-area:bottom;position-try-fallbacks:flip-block,flip-inline}}",
|
|
1356
|
+
defaults: () => ({ type: "hotspots", props: { src: "", alt: "Image" }, children: [] }),
|
|
1357
|
+
descriptor: {
|
|
1358
|
+
type: "hotspots",
|
|
1359
|
+
name: "Hotspots",
|
|
1360
|
+
group: "content",
|
|
1361
|
+
defaultTab: "content",
|
|
1362
|
+
fields: [
|
|
1363
|
+
{ key: "src", kind: "media", label: "Picture" },
|
|
1364
|
+
{ key: "alt", kind: "text", label: "Alt text" },
|
|
1365
|
+
{ key: "decorative", kind: "boolean", label: "Decorative", optional: true },
|
|
1366
|
+
{
|
|
1367
|
+
key: "label",
|
|
1368
|
+
kind: "text",
|
|
1369
|
+
label: "Markers list name",
|
|
1370
|
+
optional: true,
|
|
1371
|
+
message: "What screen readers call the markers. Leave it empty for Points on the picture.",
|
|
1372
|
+
},
|
|
1373
|
+
],
|
|
1374
|
+
},
|
|
1375
|
+
build: (node, attrs, children) => {
|
|
1376
|
+
const p = node.props;
|
|
1377
|
+
const src = p.src.trim() ? sanitizeMediaUrl(p.src.trim()) : undefined;
|
|
1378
|
+
const image: VNode[] = src
|
|
1379
|
+
? [
|
|
1380
|
+
{
|
|
1381
|
+
tag: "img",
|
|
1382
|
+
attrs: {
|
|
1383
|
+
class: "emvb-hotspots-image",
|
|
1384
|
+
src,
|
|
1385
|
+
alt: p.decorative ? "" : p.alt,
|
|
1386
|
+
...(p.width ? { width: String(p.width) } : {}),
|
|
1387
|
+
...(p.height ? { height: String(p.height) } : {}),
|
|
1388
|
+
loading: "lazy",
|
|
1389
|
+
decoding: "async",
|
|
1390
|
+
},
|
|
1391
|
+
children: [],
|
|
1392
|
+
},
|
|
1393
|
+
]
|
|
1394
|
+
: [];
|
|
1395
|
+
return {
|
|
1396
|
+
tag: "div",
|
|
1397
|
+
attrs,
|
|
1398
|
+
children: [
|
|
1399
|
+
...image,
|
|
1400
|
+
{
|
|
1401
|
+
tag: "ol",
|
|
1402
|
+
attrs: {
|
|
1403
|
+
class: "emvb-hotspots-list",
|
|
1404
|
+
"aria-label": p.label?.trim() || "Points on the picture",
|
|
1405
|
+
},
|
|
1406
|
+
children,
|
|
1407
|
+
},
|
|
1408
|
+
],
|
|
1409
|
+
};
|
|
1410
|
+
},
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1413
|
+
export const hotspot: ElementDefinition<HotspotNode> = {
|
|
1414
|
+
baseCss: "",
|
|
1415
|
+
defaults: () => ({ type: "hotspot", props: { title: "Point", x: 50, y: 50 } }),
|
|
1416
|
+
descriptor: {
|
|
1417
|
+
type: "hotspot",
|
|
1418
|
+
name: "Hotspot",
|
|
1419
|
+
group: "content",
|
|
1420
|
+
defaultTab: "content",
|
|
1421
|
+
fields: [
|
|
1422
|
+
{ key: "title", kind: "text", label: "Title" },
|
|
1423
|
+
{ key: "text", kind: "textarea", label: "Note", optional: true },
|
|
1424
|
+
{
|
|
1425
|
+
key: "x",
|
|
1426
|
+
kind: "decimal",
|
|
1427
|
+
label: "Across (%)",
|
|
1428
|
+
max: 100,
|
|
1429
|
+
message: "From 0 (left edge) to 100 (right edge).",
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
key: "y",
|
|
1433
|
+
kind: "decimal",
|
|
1434
|
+
label: "Down (%)",
|
|
1435
|
+
max: 100,
|
|
1436
|
+
message: "From 0 (top) to 100 (bottom).",
|
|
1437
|
+
},
|
|
1438
|
+
{ key: "xTablet", kind: "decimal", label: "Across on tablets (%)", optional: true, max: 100 },
|
|
1439
|
+
{ key: "yTablet", kind: "decimal", label: "Down on tablets (%)", optional: true, max: 100 },
|
|
1440
|
+
{ key: "xMobile", kind: "decimal", label: "Across on phones (%)", optional: true, max: 100 },
|
|
1441
|
+
{ key: "yMobile", kind: "decimal", label: "Down on phones (%)", optional: true, max: 100 },
|
|
1442
|
+
],
|
|
1443
|
+
},
|
|
1444
|
+
build: (node, attrs) => {
|
|
1445
|
+
const { title, text } = node.props;
|
|
1446
|
+
const noteId = `emvb-hotspot-${node.id}`;
|
|
1447
|
+
const note: VNode[] = [{ tag: "p", attrs: { class: "emvb-hotspot-title" }, children: [title] }];
|
|
1448
|
+
if (text?.trim())
|
|
1449
|
+
note.push({ tag: "p", attrs: { class: "emvb-hotspot-text" }, children: [text] });
|
|
1450
|
+
const marker: VNode[] = [
|
|
1451
|
+
{
|
|
1452
|
+
tag: "button",
|
|
1453
|
+
attrs: {
|
|
1454
|
+
type: "button",
|
|
1455
|
+
class: "emvb-hotspot-button",
|
|
1456
|
+
popovertarget: noteId,
|
|
1457
|
+
"aria-label": title,
|
|
1458
|
+
},
|
|
1459
|
+
children: [],
|
|
1460
|
+
},
|
|
1461
|
+
{
|
|
1462
|
+
tag: "div",
|
|
1463
|
+
attrs: { id: noteId, class: "emvb-hotspot-note", popover: "auto" },
|
|
1464
|
+
children: note,
|
|
1465
|
+
},
|
|
1466
|
+
];
|
|
1467
|
+
return { tag: "li", attrs, children: marker };
|
|
1468
|
+
},
|
|
1469
|
+
};
|
|
1470
|
+
|
|
1471
|
+
/** A percentage with at most two decimals. */
|
|
1472
|
+
const pct = (n: number) => `${Math.round(n * 100) / 100}%`;
|
|
1473
|
+
|
|
1474
|
+
/** W-1048: a marker's place as CSS, desktop first; unset devices follow the wider one. */
|
|
1475
|
+
export function hotspotPlace(props: HotspotNode["props"]): {
|
|
1476
|
+
desktop: string[];
|
|
1477
|
+
tablet: string[];
|
|
1478
|
+
mobile: string[];
|
|
1479
|
+
} {
|
|
1480
|
+
const tx = props.xTablet ?? props.x;
|
|
1481
|
+
const ty = props.yTablet ?? props.y;
|
|
1482
|
+
return {
|
|
1483
|
+
desktop: [pct(props.x), pct(props.y)],
|
|
1484
|
+
tablet: props.xTablet === undefined && props.yTablet === undefined ? [] : [pct(tx), pct(ty)],
|
|
1485
|
+
mobile:
|
|
1486
|
+
props.xMobile === undefined && props.yMobile === undefined
|
|
1487
|
+
? []
|
|
1488
|
+
: [pct(props.xMobile ?? tx), pct(props.yMobile ?? ty)],
|
|
1489
|
+
};
|
|
1490
|
+
}
|