@spillway-cms/blocks 0.1.23 → 0.1.24
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 +49 -0
- package/dist/breadcrumbs.d.ts +27 -0
- package/dist/breadcrumbs.js +44 -0
- package/dist/breadcrumbs.js.map +1 -0
- package/dist/config.d.ts +50 -4
- package/dist/config.js +103 -23
- package/dist/config.js.map +1 -1
- package/dist/css.js +26 -0
- package/dist/css.js.map +1 -1
- package/dist/examples.js +67 -1
- package/dist/examples.js.map +1 -1
- package/dist/icons-data.d.ts +18 -0
- package/dist/icons-data.js +117 -0
- package/dist/icons-data.js.map +1 -0
- package/dist/icons.d.ts +31 -0
- package/dist/icons.js +49 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/marketing.d.ts +3 -0
- package/dist/marketing.js +5 -2
- package/dist/marketing.js.map +1 -1
- package/dist/meta.js +38 -13
- package/dist/meta.js.map +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +2 -1
- package/dist/motion.js.map +1 -1
- package/dist/styles.css +183 -1
- package/dist/styles.js +95 -0
- package/dist/styles.js.map +1 -1
- package/dist/toc.d.ts +32 -0
- package/dist/toc.js +79 -0
- package/dist/toc.js.map +1 -0
- package/dist/video.d.ts +36 -1
- package/dist/video.js +157 -4
- package/dist/video.js.map +1 -1
- package/dist/widgets.d.ts +95 -0
- package/dist/widgets.js +449 -0
- package/dist/widgets.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
`@spillway-cms/blocks` bundles a selection of [Lucide](https://lucide.dev) icons (`src/icons-data.ts`, from `lucide-static` 1.76.0). Lucide is licensed under the ISC License; the icons derived from Feather are licensed under the MIT License:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
ISC License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
12
|
+
copyright notice and this permission notice appear in all copies.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
15
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
17
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
18
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
19
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
20
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
The following Lucide icons are derived from the Feather project:
|
|
25
|
+
|
|
26
|
+
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
|
|
27
|
+
|
|
28
|
+
The MIT License (MIT) (for the icons listed above)
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2013-present Cole Bemis
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
in the Software without restriction, including without limitation the rights
|
|
35
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
furnished to do so, subject to the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
|
49
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Breadcrumbs block: the trail from the home page to the page being viewed, as a navigation landmark with an ordered list
|
|
3
|
+
* (the WAI-ARIA breadcrumb pattern: `aria-label="Breadcrumb"`, `aria-current="page"` on the last link).
|
|
4
|
+
*
|
|
5
|
+
* The server resolves the trail (`items`) before render, from the page's path (the titles of the published pages at each
|
|
6
|
+
* ancestor path, the same trail as the BreadcrumbList structured data) or from the page's position in the main menu. It is
|
|
7
|
+
* placed above the content by Structure → Placements or by Site settings → Breadcrumbs. Server-safe; nothing renders when there
|
|
8
|
+
* is no trail (the home page), except a placeholder in the page builder.
|
|
9
|
+
*/
|
|
10
|
+
import type { ComponentConfig } from '@puckeditor/core';
|
|
11
|
+
export interface BreadcrumbItem {
|
|
12
|
+
label: string;
|
|
13
|
+
/** Absent for a menu heading without a link. */
|
|
14
|
+
href?: string;
|
|
15
|
+
/** The page being viewed (the last item). */
|
|
16
|
+
current?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface BreadcrumbsBlockProps {
|
|
19
|
+
/** 'path': the page's path, as the structured data does; 'menu': its position in the main menu (the path when it is not in it). */
|
|
20
|
+
source: 'path' | 'menu';
|
|
21
|
+
/** Whether the trail ends with the page itself. */
|
|
22
|
+
showCurrent: boolean;
|
|
23
|
+
/** Resolved by the server; never stored. */
|
|
24
|
+
items?: BreadcrumbItem[];
|
|
25
|
+
}
|
|
26
|
+
export declare const breadcrumbsBlockComponent: ComponentConfig<BreadcrumbsBlockProps>;
|
|
27
|
+
export declare const breadcrumbsBlockCss = "/* ---------- Breadcrumbs ---------- */\n.sw-breadcrumbs { padding-top: 1rem; padding-bottom: 0; font-size: 0.875rem; }\n.sw-breadcrumbs__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }\n.sw-breadcrumbs__item { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; }\n.sw-breadcrumbs__item + .sw-breadcrumbs__item::before { content: \"\"; flex: none; width: 0.4em; height: 0.4em; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); opacity: 0.55; }\n.sw-breadcrumbs__item a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 0.2em; }\n.sw-breadcrumbs__item a:hover { text-decoration-color: currentColor; }\n.sw-breadcrumbs__item a:focus-visible { outline: 2px solid var(--sw-color-primary, #1d4ed8); outline-offset: 2px; border-radius: 2px; }\n.sw-breadcrumbs__item [aria-current=\"page\"] { font-weight: 600; text-decoration: none; }\n.sw-breadcrumbs__placeholder { padding: 0.75rem 1rem; border: 1px dashed color-mix(in srgb, currentColor 35%, transparent); border-radius: var(--sw-radius, 8px); font-size: 0.9rem; opacity: 0.8; }\n";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const breadcrumbsBlockComponent = {
|
|
3
|
+
label: 'Breadcrumbs',
|
|
4
|
+
fields: {
|
|
5
|
+
source: {
|
|
6
|
+
type: 'radio',
|
|
7
|
+
label: 'Trail from',
|
|
8
|
+
options: [
|
|
9
|
+
{ label: "The page's address", value: 'path' },
|
|
10
|
+
{ label: 'The main menu', value: 'menu' },
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
showCurrent: {
|
|
14
|
+
type: 'radio',
|
|
15
|
+
label: 'End with this page',
|
|
16
|
+
options: [
|
|
17
|
+
{ label: 'Yes', value: true },
|
|
18
|
+
{ label: 'No', value: false },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultProps: { source: 'path', showCurrent: true },
|
|
23
|
+
render: ({ items, source, puck }) => {
|
|
24
|
+
const list = Array.isArray(items) ? items.filter((i) => i && typeof i.label === 'string' && i.label) : [];
|
|
25
|
+
if (!list.length) {
|
|
26
|
+
if (!puck?.isEditing)
|
|
27
|
+
return _jsx(_Fragment, {});
|
|
28
|
+
return (_jsx("section", { className: "sw-block sw-breadcrumbs sw-breadcrumbs--placeholder", children: _jsx("div", { className: "sw-container", children: _jsxs("div", { className: "sw-breadcrumbs__placeholder", role: "note", children: ["Breadcrumbs: the trail to this page from ", source === 'menu' ? 'the main menu' : 'its address', ", shown on the published page."] }) }) }));
|
|
29
|
+
}
|
|
30
|
+
return (_jsx("nav", { className: "sw-block sw-breadcrumbs", "aria-label": "Breadcrumb", children: _jsx("div", { className: "sw-container", children: _jsx("ol", { className: "sw-breadcrumbs__list", children: list.map((item, i) => (_jsx("li", { className: "sw-breadcrumbs__item", children: item.href ? (_jsx("a", { href: item.href, "aria-current": item.current ? 'page' : undefined, children: item.label })) : (_jsx("span", { "aria-current": item.current ? 'page' : undefined, children: item.label })) }, `${item.href ?? ''}-${i}`))) }) }) }));
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const breadcrumbsBlockCss = `/* ---------- Breadcrumbs ---------- */
|
|
34
|
+
.sw-breadcrumbs { padding-top: 1rem; padding-bottom: 0; font-size: 0.875rem; }
|
|
35
|
+
.sw-breadcrumbs__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }
|
|
36
|
+
.sw-breadcrumbs__item { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; }
|
|
37
|
+
.sw-breadcrumbs__item + .sw-breadcrumbs__item::before { content: ""; flex: none; width: 0.4em; height: 0.4em; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); opacity: 0.55; }
|
|
38
|
+
.sw-breadcrumbs__item a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 0.2em; }
|
|
39
|
+
.sw-breadcrumbs__item a:hover { text-decoration-color: currentColor; }
|
|
40
|
+
.sw-breadcrumbs__item a:focus-visible { outline: 2px solid var(--sw-color-primary, #1d4ed8); outline-offset: 2px; border-radius: 2px; }
|
|
41
|
+
.sw-breadcrumbs__item [aria-current="page"] { font-weight: 600; text-decoration: none; }
|
|
42
|
+
.sw-breadcrumbs__placeholder { padding: 0.75rem 1rem; border: 1px dashed color-mix(in srgb, currentColor 35%, transparent); border-radius: var(--sw-radius, 8px); font-size: 0.9rem; opacity: 0.8; }
|
|
43
|
+
`;
|
|
44
|
+
//# sourceMappingURL=breadcrumbs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../src/breadcrumbs.tsx"],"names":[],"mappings":";AA4BA,MAAM,CAAC,MAAM,yBAAyB,GAA2C;IAC/E,KAAK,EAAE,aAAa;IACpB,MAAM,EAAE;QACN,MAAM,EAAE;YACN,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,EAAE;gBAC9C,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE;aAC1C;SACF;QACD,WAAW,EAAE;YACX,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,oBAAoB;YAC3B,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE;gBAC7B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;aAC9B;SACF;KACF;IACD,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE;IACnD,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;QAClC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1G,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,EAAE,SAAS;gBAAE,OAAO,mBAAK,CAAC;YACnC,OAAO,CACL,kBAAS,SAAS,EAAC,qDAAqD,YACtE,cAAK,SAAS,EAAC,cAAc,YAC3B,eAAK,SAAS,EAAC,6BAA6B,EAAC,IAAI,EAAC,MAAM,0DACZ,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,aAAa,sCACzF,GACF,GACE,CACX,CAAC;QACJ,CAAC;QACD,OAAO,CACL,cAAK,SAAS,EAAC,yBAAyB,gBAAY,YAAY,YAC9D,cAAK,SAAS,EAAC,cAAc,YAC3B,aAAI,SAAS,EAAC,sBAAsB,YACjC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACrB,aAAoC,SAAS,EAAC,sBAAsB,YACjE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CACX,YAAG,IAAI,EAAE,IAAI,CAAC,IAAI,kBAAgB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAChE,IAAI,CAAC,KAAK,GACT,CACL,CAAC,CAAC,CAAC,CACF,+BAAoB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAAG,IAAI,CAAC,KAAK,GAAQ,CAC3E,IAPM,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,CAAC,EAAE,CAQ7B,CACN,CAAC,GACC,GACD,GACF,CACP,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;CAUlC,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -25,11 +25,13 @@ import { type RegistryPackageProps } from './registry-package.js';
|
|
|
25
25
|
import { type GalleryProps } from './gallery.js';
|
|
26
26
|
import { type FaqProps, type LogoStripProps, type StatsProps, type TestimonialsProps } from './marketing.js';
|
|
27
27
|
import { type ScrollytellingProps } from './story.js';
|
|
28
|
+
import { type AccordionProps, type CarouselProps, type TabsProps } from './widgets.js';
|
|
28
29
|
import { type LottieProps, type Model3DProps } from './players.js';
|
|
29
30
|
import { type VideoProps } from './video.js';
|
|
30
31
|
import { type SearchProps } from './search.js';
|
|
31
32
|
import { type AskProps } from './ask.js';
|
|
32
33
|
import { type MenuBlockProps } from './menu.js';
|
|
34
|
+
import { type BreadcrumbsBlockProps } from './breadcrumbs.js';
|
|
33
35
|
import { type RegistryStatsProps } from './registry-stats.js';
|
|
34
36
|
import { type StatusBoardProps } from './status-board.js';
|
|
35
37
|
import { type ThemeGalleryProps } from './registry-gallery.js';
|
|
@@ -37,6 +39,8 @@ import { type PublisherProfileProps } from './registry-publisher.js';
|
|
|
37
39
|
import { type OrgProfileProps } from './registry-org.js';
|
|
38
40
|
import { type DocsFeedbackProps } from './docs-feedback.js';
|
|
39
41
|
import { type ModuleBlockProps } from './module-block.js';
|
|
42
|
+
import { type OnThisPageProps } from './toc.js';
|
|
43
|
+
import { type SectionOverlay, type SectionTextColor } from '@spillway-cms/shared';
|
|
40
44
|
export type Align = 'left' | 'center';
|
|
41
45
|
export type TextAlign = 'left' | 'center' | 'right';
|
|
42
46
|
export interface HeroProps {
|
|
@@ -65,6 +69,11 @@ export interface HeroProps {
|
|
|
65
69
|
imagePosition?: 'right' | 'left';
|
|
66
70
|
align: Align;
|
|
67
71
|
size: 'default' | 'large';
|
|
72
|
+
/**
|
|
73
|
+
* The title's heading level: h1 (the default, the page's title) or h2, for a hero further down the page or a carousel's slides
|
|
74
|
+
* after the first, so the page keeps one H1.
|
|
75
|
+
*/
|
|
76
|
+
titleLevel?: 'h1' | 'h2';
|
|
68
77
|
/** The block style's key (Brand → Styles), e.g. "dark-band"; empty means the site's default Hero style. */
|
|
69
78
|
style?: string;
|
|
70
79
|
/** Resolved by the server from `backgroundImage` when it is a library image; never stored. */
|
|
@@ -85,6 +94,10 @@ export interface HeadingProps {
|
|
|
85
94
|
align: TextAlign;
|
|
86
95
|
/** The block style's key; empty means the site's default Heading style. */
|
|
87
96
|
style?: string;
|
|
97
|
+
/** Link name: the heading's id, so `#name` jumps to it (letters, digits and hyphens; unique on the page). */
|
|
98
|
+
anchor?: string;
|
|
99
|
+
/** The id the server settled on for this page (the link name made unique, or one from the text for On this page). Never stored. */
|
|
100
|
+
anchorId?: string;
|
|
88
101
|
}
|
|
89
102
|
export interface TextProps {
|
|
90
103
|
/** HTML (or plain paragraphs). On the page builder canvas only, the rich text editor Puck renders in place. */
|
|
@@ -123,12 +136,31 @@ export interface SectionProps {
|
|
|
123
136
|
content: Slot;
|
|
124
137
|
background: 'none' | 'surface' | 'primary' | 'secondary' | 'dark';
|
|
125
138
|
width: 'narrow' | 'normal' | 'wide';
|
|
139
|
+
/** A media library image behind the blocks, cropped around its focal point (docs/dev/section-media-icons-anchors.md). */
|
|
140
|
+
backgroundImage?: string;
|
|
141
|
+
/** A muted, looping .mp4 or .webm behind the blocks, with the background image as its poster; it plays under the Hero's rules. */
|
|
142
|
+
backgroundVideo?: string;
|
|
143
|
+
/** A brand color laid over the image so text stays readable; unset is Dark. */
|
|
144
|
+
overlay?: SectionOverlay;
|
|
145
|
+
/** The overlay's strength in percent (20 to 80); unset is 60. */
|
|
146
|
+
overlayStrength?: number;
|
|
147
|
+
/** Light or dark text over the image; auto picks from the overlay. */
|
|
148
|
+
textColor?: SectionTextColor;
|
|
149
|
+
/** Link name: the section's id, so `#name` jumps to it. */
|
|
150
|
+
anchor?: string;
|
|
151
|
+
/** Set by the server; never stored. */
|
|
152
|
+
anchorId?: string;
|
|
153
|
+
backgroundMedia?: ResolvedMedia | null;
|
|
154
|
+
backgroundPriority?: boolean;
|
|
126
155
|
}
|
|
127
156
|
export interface ButtonsItem {
|
|
128
157
|
label: string;
|
|
129
158
|
href: string;
|
|
130
159
|
emphasis: 'primary' | 'secondary' | 'link';
|
|
131
160
|
newTab?: boolean;
|
|
161
|
+
/** An icon beside the label (decorative: the label names the button). */
|
|
162
|
+
icon?: string;
|
|
163
|
+
iconPosition?: 'before' | 'after';
|
|
132
164
|
}
|
|
133
165
|
/** One to four buttons in a row that wraps on small screens. */
|
|
134
166
|
export interface ButtonsProps {
|
|
@@ -154,6 +186,9 @@ export interface CardItem {
|
|
|
154
186
|
text: string;
|
|
155
187
|
href: string;
|
|
156
188
|
imageUrl: string;
|
|
189
|
+
/** An icon above the title, from the bundled set; decorative unless `iconLabel` is set. */
|
|
190
|
+
icon?: string;
|
|
191
|
+
iconLabel?: string;
|
|
157
192
|
}
|
|
158
193
|
export interface CardsProps {
|
|
159
194
|
cards: CardItem[];
|
|
@@ -187,6 +222,9 @@ export interface ButtonProps {
|
|
|
187
222
|
align: TextAlign;
|
|
188
223
|
/** The block style's key; empty means the site's default Button style. */
|
|
189
224
|
style?: string;
|
|
225
|
+
/** An icon beside the label (decorative: the label names the button). */
|
|
226
|
+
icon?: string;
|
|
227
|
+
iconPosition?: 'before' | 'after';
|
|
190
228
|
}
|
|
191
229
|
export interface RootProps {
|
|
192
230
|
title: string;
|
|
@@ -200,8 +238,13 @@ export type BlockProps = {
|
|
|
200
238
|
Search: SearchProps;
|
|
201
239
|
Ask: AskProps;
|
|
202
240
|
Menu: MenuBlockProps;
|
|
241
|
+
Breadcrumbs: BreadcrumbsBlockProps;
|
|
203
242
|
Columns: ColumnsProps;
|
|
204
243
|
Section: SectionProps;
|
|
244
|
+
OnThisPage: OnThisPageProps;
|
|
245
|
+
Tabs: TabsProps;
|
|
246
|
+
Accordion: AccordionProps;
|
|
247
|
+
Carousel: CarouselProps;
|
|
205
248
|
Buttons: ButtonsProps;
|
|
206
249
|
CallToAction: CallToActionProps;
|
|
207
250
|
Cards: CardsProps;
|
|
@@ -244,14 +287,16 @@ export type BlocksConfig = Config<{
|
|
|
244
287
|
}>;
|
|
245
288
|
/** The Hero's side image: about half the container from 900px, the full width below. */
|
|
246
289
|
export declare const HERO_SIDE_SIZES = "(min-width: 1200px) 640px, (min-width: 900px) 50vw, 100vw";
|
|
290
|
+
/** A link name as typed, made into an id: lowercase letters, digits and hyphens (empty when nothing usable is left). */
|
|
291
|
+
export declare function anchorIdOf(anchor: unknown): string;
|
|
247
292
|
export declare const config: BlocksConfig;
|
|
248
|
-
export declare const SPACED_BLOCKS: readonly ["Section", "Columns", "Divider", "Heading", "Text", "Image", "Gallery", "Video", "Search", "Ask", "Embed", "Lottie", "Model3D", "Button", "Buttons", "Hero", "CallToAction", "Cards", "Faq", "Testimonials", "Stats", "LogoStrip", "Scrollytelling", "Collection", "Calendar", "MiniCalendar", "Form"];
|
|
293
|
+
export declare const SPACED_BLOCKS: readonly ["Section", "Columns", "Tabs", "Accordion", "Carousel", "OnThisPage", "Divider", "Heading", "Text", "Image", "Gallery", "Video", "Search", "Ask", "Embed", "Lottie", "Model3D", "Button", "Buttons", "Hero", "CallToAction", "Cards", "Faq", "Testimonials", "Stats", "LogoStrip", "Scrollytelling", "Collection", "Calendar", "MiniCalendar", "Form"];
|
|
249
294
|
/** The classes for a block's Space above and Space below; unknown values are ignored. */
|
|
250
295
|
export declare function spacingClasses(props: BlockSpacing | undefined): string;
|
|
251
296
|
/** Blocks whose items (cards, images, logos, quotes, buttons, list items) can arrive one after another and respond to hover. */
|
|
252
297
|
export declare const MOTION_ITEM_BLOCKS: readonly ["Image", "Gallery", "Buttons", "Button", "Cards", "Faq", "Testimonials", "Stats", "LogoStrip", "Collection"];
|
|
253
|
-
/** Blocks with a background image that parallax can move. */
|
|
254
|
-
export declare const MOTION_PARALLAX_BLOCKS: readonly ["Hero"];
|
|
298
|
+
/** Blocks with a background image that parallax can move (a Section's only when it has one). */
|
|
299
|
+
export declare const MOTION_PARALLAX_BLOCKS: readonly ["Hero", "Section"];
|
|
255
300
|
/**
|
|
256
301
|
* A block's Motion settings as attributes on its root element (docs/dev/motion.md): `data-motion` (the entrance), `data-motion-delay`,
|
|
257
302
|
* `data-motion-stagger` and `data-motion-hover`. Unknown values are dropped. Nothing moves until the page's motion script arms them,
|
|
@@ -264,7 +309,8 @@ export declare const MOTION_SCRIPT_BLOCKS: readonly ["Scrollytelling", "Lottie",
|
|
|
264
309
|
export declare const PLAYER_BLOCKS: readonly ["Lottie", "Model3D"];
|
|
265
310
|
/**
|
|
266
311
|
* Whether a block asks for any motion (the page then carries the motion script): Motion settings, Stats that count up, a marquee,
|
|
267
|
-
* a Hero's video, a muted Video that plays on its own, or a block in MOTION_SCRIPT_BLOCKS (pass
|
|
312
|
+
* a Hero's video, a muted Video that plays on its own, a Carousel that plays on its own, or a block in MOTION_SCRIPT_BLOCKS (pass
|
|
313
|
+
* its type).
|
|
268
314
|
*/
|
|
269
315
|
export declare function hasMotion(props: {
|
|
270
316
|
motion?: BlockMotion;
|
package/dist/config.js
CHANGED
|
@@ -15,11 +15,13 @@ import { registryPackageComponent } from './registry-package.js';
|
|
|
15
15
|
import { galleryComponent } from './gallery.js';
|
|
16
16
|
import { faqComponent, logoStripComponent, statsComponent, testimonialsComponent } from './marketing.js';
|
|
17
17
|
import { scrollytellingComponent } from './story.js';
|
|
18
|
+
import { accordionComponent, carouselComponent, slugify, tabsComponent } from './widgets.js';
|
|
18
19
|
import { lottieComponent, model3dComponent } from './players.js';
|
|
19
20
|
import { videoComponent } from './video.js';
|
|
20
21
|
import { searchComponent } from './search.js';
|
|
21
22
|
import { askComponent } from './ask.js';
|
|
22
23
|
import { menuBlockComponent } from './menu.js';
|
|
24
|
+
import { breadcrumbsBlockComponent } from './breadcrumbs.js';
|
|
23
25
|
import { registryStatsComponent } from './registry-stats.js';
|
|
24
26
|
import { statusBoardComponent } from './status-board.js';
|
|
25
27
|
import { themeGalleryComponent } from './registry-gallery.js';
|
|
@@ -27,7 +29,9 @@ import { publisherProfileComponent } from './registry-publisher.js';
|
|
|
27
29
|
import { orgProfileComponent } from './registry-org.js';
|
|
28
30
|
import { docsFeedbackComponent } from './docs-feedback.js';
|
|
29
31
|
import { moduleBlockComponent } from './module-block.js';
|
|
30
|
-
import {
|
|
32
|
+
import { onThisPageComponent } from './toc.js';
|
|
33
|
+
import { Icon, iconField, iconLabelField } from './icons.js';
|
|
34
|
+
import { DEFAULT_EMBED_HOSTS, SECTION_OVERLAY_STRENGTHS, sectionOverlayOf, sectionStrengthOf, sectionTextTone } from '@spillway-cms/shared';
|
|
31
35
|
import { holdEmbedHtml, isPlainText, keyboardScrollable, sanitizeEmbedHtml, sanitizeTextHtml } from './sanitize.js';
|
|
32
36
|
/** `https://www.youtube.com/embed/x` → `www.youtube.com`; empty when it is not a URL. */
|
|
33
37
|
function hostOf(url) {
|
|
@@ -87,17 +91,34 @@ function paragraphs(text) {
|
|
|
87
91
|
function isExternal(href) {
|
|
88
92
|
return /^(https?:)?\/\//i.test(href);
|
|
89
93
|
}
|
|
90
|
-
function Button({ label, href, variant, newTab, }) {
|
|
94
|
+
function Button({ label, href, variant, newTab, icon, iconPosition, }) {
|
|
91
95
|
if (!label)
|
|
92
96
|
return null;
|
|
93
97
|
const external = isExternal(href);
|
|
94
|
-
|
|
98
|
+
const after = iconPosition === 'after';
|
|
99
|
+
return (_jsxs("a", { className: cx('sw-button', `sw-button--${variant}`), href: href || '#', target: newTab ? '_blank' : undefined, rel: newTab || external ? 'noopener' : undefined, children: [!after ? _jsx(Icon, { name: icon }) : null, label, after ? _jsx(Icon, { name: icon }) : null] }));
|
|
95
100
|
}
|
|
101
|
+
const iconPositionField = {
|
|
102
|
+
type: 'radio',
|
|
103
|
+
label: 'Icon position',
|
|
104
|
+
options: [
|
|
105
|
+
{ label: 'Before the label', value: 'before' },
|
|
106
|
+
{ label: 'After the label', value: 'after' },
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
/** A link name as typed, made into an id: lowercase letters, digits and hyphens (empty when nothing usable is left). */
|
|
110
|
+
export function anchorIdOf(anchor) {
|
|
111
|
+
const slug = typeof anchor === 'string' ? slugify(anchor) : '';
|
|
112
|
+
return slug && /^\d/.test(slug) ? `n-${slug}` : slug;
|
|
113
|
+
}
|
|
114
|
+
const anchorField = { type: 'text', label: 'Link name (optional, for #links and On this page)', placeholder: 'admissions' };
|
|
115
|
+
/** Whether a background video URL is one the Section and the Hero play: an .mp4 or .webm at a path or an http(s) URL. */
|
|
116
|
+
const isBackgroundVideo = (v) => typeof v === 'string' && /^(\/(?!\/)|https?:\/\/)/i.test(v.trim()) && /\.(mp4|webm)(\?.*)?$/i.test(v.trim());
|
|
96
117
|
// ---------- Config ----------
|
|
97
118
|
export const config = {
|
|
98
119
|
categories: {
|
|
99
|
-
layout: { title: 'Layout', components: ['Section', 'Columns', 'Spacer', 'Divider'] },
|
|
100
|
-
content: { title: 'Content', components: ['Heading', 'Text', 'Image', 'Gallery', 'Video', 'Embed', 'Lottie', 'Model3D', 'Button', 'Buttons', 'Search', 'Ask', 'Menu'] },
|
|
120
|
+
layout: { title: 'Layout', components: ['Section', 'Columns', 'Tabs', 'Accordion', 'Carousel', 'OnThisPage', 'Spacer', 'Divider'] },
|
|
121
|
+
content: { title: 'Content', components: ['Heading', 'Text', 'Image', 'Gallery', 'Video', 'Embed', 'Lottie', 'Model3D', 'Button', 'Buttons', 'Search', 'Ask', 'Menu', 'Breadcrumbs'] },
|
|
101
122
|
marketing: { title: 'Marketing', components: ['Hero', 'CallToAction', 'Cards', 'Faq', 'Testimonials', 'Stats', 'LogoStrip', 'Scrollytelling', 'Collection', 'Calendar', 'MiniCalendar', 'Form', 'Shared'] },
|
|
102
123
|
// The docs kit's feedback block; the admin lists it only on a site that has the docs_feedback form.
|
|
103
124
|
docs: { title: 'Docs', components: ['DocsFeedback'] },
|
|
@@ -121,6 +142,10 @@ export const config = {
|
|
|
121
142
|
// ----- Marketing -----
|
|
122
143
|
// Saved query rendered as cards, list or grid; items are resolved by the server (see src/collection.tsx).
|
|
123
144
|
Collection: collectionComponent,
|
|
145
|
+
// Slides, items and tabs that each hold blocks, enhanced by the page's widgets script (see src/widgets.tsx).
|
|
146
|
+
Carousel: carouselComponent(() => config),
|
|
147
|
+
Accordion: accordionComponent(() => config),
|
|
148
|
+
Tabs: tabsComponent(() => config),
|
|
124
149
|
// A block from the component library, resolved by the server (see src/shared.tsx).
|
|
125
150
|
Shared: createSharedComponent(() => config),
|
|
126
151
|
// A site component (Components → Site components): a locked design with the page's values, resolved by the server (see src/site-component.tsx).
|
|
@@ -189,6 +214,14 @@ export const config = {
|
|
|
189
214
|
{ label: 'Large', value: 'large' },
|
|
190
215
|
],
|
|
191
216
|
},
|
|
217
|
+
titleLevel: {
|
|
218
|
+
type: 'radio',
|
|
219
|
+
label: 'Title level',
|
|
220
|
+
options: [
|
|
221
|
+
{ label: 'H1 (the page title)', value: 'h1' },
|
|
222
|
+
{ label: 'H2 (further down, or a later slide)', value: 'h2' },
|
|
223
|
+
],
|
|
224
|
+
},
|
|
192
225
|
},
|
|
193
226
|
defaultProps: {
|
|
194
227
|
eyebrow: 'Introducing',
|
|
@@ -205,7 +238,7 @@ export const config = {
|
|
|
205
238
|
align: 'center',
|
|
206
239
|
size: 'default',
|
|
207
240
|
},
|
|
208
|
-
render: ({ eyebrow, title, subtitle, primaryLabel, primaryHref, secondaryLabel, secondaryHref, backgroundImage, backgroundVideo, image, imageAlt, imagePosition, align, size, style, backgroundMedia, imageMedia, imagePriority, backgroundPriority, }) => {
|
|
241
|
+
render: ({ eyebrow, title, subtitle, primaryLabel, primaryHref, secondaryLabel, secondaryHref, backgroundImage, backgroundVideo, image, imageAlt, imagePosition, align, size, titleLevel, style, backgroundMedia, imageMedia, imagePriority, backgroundPriority, }) => {
|
|
209
242
|
const video = backgroundVideo && backgroundImage && /\.(mp4|webm)(\?.*)?$/i.test(backgroundVideo) ? backgroundVideo : null;
|
|
210
243
|
const hasImage = Boolean(backgroundImage);
|
|
211
244
|
// A library image becomes a real, eagerly loaded picture behind the text (first paint matters for a hero);
|
|
@@ -213,7 +246,7 @@ export const config = {
|
|
|
213
246
|
const hasPicture = hasImage && Boolean(backgroundMedia) && !video;
|
|
214
247
|
const hasActions = Boolean(primaryLabel || secondaryLabel);
|
|
215
248
|
const side = typeof image === 'string' && image.trim() ? image.trim() : '';
|
|
216
|
-
const text = (_jsxs("div", { className: "sw-hero__inner", children: [eyebrow ? _jsx("span", { className: "sw-hero__eyebrow", children: eyebrow }) : null, _jsx("h1", { className: "sw-hero__title", children: title }), subtitle ? _jsx("p", { className: "sw-hero__subtitle", children: subtitle }) : null, hasActions ? (_jsxs("div", { className: "sw-actions", children: [_jsx(Button, { label: primaryLabel, href: primaryHref, variant: "primary" }), _jsx(Button, { label: secondaryLabel, href: secondaryHref, variant: "secondary" })] })) : null] }));
|
|
249
|
+
const text = (_jsxs("div", { className: "sw-hero__inner", children: [eyebrow ? _jsx("span", { className: "sw-hero__eyebrow", children: eyebrow }) : null, titleLevel === 'h2' ? _jsx("h2", { className: "sw-hero__title", children: title }) : _jsx("h1", { className: "sw-hero__title", children: title }), subtitle ? _jsx("p", { className: "sw-hero__subtitle", children: subtitle }) : null, hasActions ? (_jsxs("div", { className: "sw-actions", children: [_jsx(Button, { label: primaryLabel, href: primaryHref, variant: "primary" }), _jsx(Button, { label: secondaryLabel, href: secondaryHref, variant: "secondary" })] })) : null] }));
|
|
217
250
|
return (_jsxs("section", { className: cx('sw-block', 'sw-hero', `sw-hero--${size}`, hasImage && 'sw-hero--image', side && 'sw-hero--side', side && `sw-hero--side-${imagePosition === 'left' ? 'left' : 'right'}`, `sw-align-${align}`, styleClassFor('Hero', style)), style: hasImage && !hasPicture && !video ? { backgroundImage: `url("${backgroundImage}")` } : undefined, children: [video ? (_jsxs(_Fragment, { children: [_jsx("video", { className: "sw-hero__bg sw-hero__video", muted: true, loop: true, playsInline: true, preload: "none", poster: backgroundMedia?.url ?? backgroundImage, "aria-hidden": "true", "data-sw-bg-video": "", children: _jsx("source", { src: video, type: /\.webm(\?.*)?$/i.test(video) ? 'video/webm' : 'video/mp4' }) }), _jsx("button", { type: "button", className: "sw-video-toggle", "data-sw-video-toggle": "", "aria-pressed": "false", hidden: true, children: "Pause background video" })] })) : null, hasPicture ? (_jsx(ResponsiveImage, { className: "sw-hero__bg", src: backgroundImage, alt: "", media: backgroundMedia, sizes: "100vw", loading: backgroundPriority === false ? 'lazy' : 'eager', priority: backgroundPriority ? 'high' : 'auto', aspect: { w: 16, h: 7 } })) : null, _jsx("div", { className: "sw-container", children: side ? (
|
|
218
251
|
// Text first in the markup, so it comes first when the columns stack and for screen readers; CSS moves a left image.
|
|
219
252
|
_jsxs("div", { className: "sw-hero__layout", children: [text, _jsx("div", { className: "sw-hero__media", children: _jsx(ResponsiveImage, { className: "sw-hero__image", src: side, alt: (typeof imageAlt === 'string' && imageAlt.trim()) || imageMedia?.alt || '', media: imageMedia, sizes: HERO_SIDE_SIZES, loading: imagePriority === false ? 'lazy' : 'eager', priority: imagePriority && !hasPicture ? 'high' : 'auto', style: sideImageCap(imageMedia) }) })] })) : (text) })] }));
|
|
@@ -250,8 +283,10 @@ export const config = {
|
|
|
250
283
|
text: { type: 'textarea', label: 'Text', contentEditable: true },
|
|
251
284
|
href: { type: 'text', label: 'Link', placeholder: '/page or https://...' },
|
|
252
285
|
imageUrl: { type: 'text', label: 'Image URL', placeholder: '/media/...' },
|
|
286
|
+
icon: iconField('Icon (above the title)'),
|
|
287
|
+
iconLabel: iconLabelField,
|
|
253
288
|
},
|
|
254
|
-
defaultItemProps: { title: 'Card title', text: 'A short description.', href: '', imageUrl: '' },
|
|
289
|
+
defaultItemProps: { title: 'Card title', text: 'A short description.', href: '', imageUrl: '', icon: '', iconLabel: '' },
|
|
255
290
|
},
|
|
256
291
|
columns: {
|
|
257
292
|
type: 'radio',
|
|
@@ -284,7 +319,7 @@ export const config = {
|
|
|
284
319
|
const Title = titleLevel === 'h2' ? 'h2' : 'h3';
|
|
285
320
|
return (_jsx("section", { className: cx('sw-block', 'sw-cards', `sw-cards--${columns}`, styleClassFor('Cards', style)), children: _jsx("div", { className: "sw-container", children: _jsx("ul", { className: "sw-cards__grid", children: (cards ?? []).map((card, i) => {
|
|
286
321
|
const linked = Boolean(card.href);
|
|
287
|
-
return (_jsxs("li", { className: cx('sw-card', linked && 'sw-card--link'), children: [card.imageUrl ? _jsx(ResponsiveImage, { className: "sw-card__image", src: card.imageUrl, alt: "", media: cardMedia?.[i] ?? null, sizes: CARD_SIZES[columns] ?? CARD_SIZES[3], aspect: { w: 16, h: 9 } }) : null, _jsxs("div", { className: "sw-card__body", children: [_jsx(Title, { className: "sw-card__title", children: linked ? _jsx("a", { href: card.href, children: card.title }) : card.title }), card.text ? _jsx("p", { className: "sw-card__text", children: card.text }) : null, linked ? (_jsx("span", { className: "sw-card__more", "aria-hidden": "true", children: "Read more \u2192" })) : null] })] }, i));
|
|
322
|
+
return (_jsxs("li", { className: cx('sw-card', linked && 'sw-card--link'), children: [card.imageUrl ? _jsx(ResponsiveImage, { className: "sw-card__image", src: card.imageUrl, alt: "", media: cardMedia?.[i] ?? null, sizes: CARD_SIZES[columns] ?? CARD_SIZES[3], aspect: { w: 16, h: 9 } }) : null, _jsxs("div", { className: "sw-card__body", children: [_jsx(Icon, { name: card.icon, label: card.iconLabel, className: "sw-card__icon" }), _jsx(Title, { className: "sw-card__title", children: linked ? _jsx("a", { href: card.href, children: card.title }) : card.title }), card.text ? _jsx("p", { className: "sw-card__text", children: card.text }) : null, linked ? (_jsx("span", { className: "sw-card__more", "aria-hidden": "true", children: "Read more \u2192" })) : null] })] }, i));
|
|
288
323
|
}) }) }) }));
|
|
289
324
|
},
|
|
290
325
|
},
|
|
@@ -304,11 +339,13 @@ export const config = {
|
|
|
304
339
|
],
|
|
305
340
|
},
|
|
306
341
|
align: { type: 'radio', label: 'Alignment', options: textAlignOptions },
|
|
342
|
+
anchor: anchorField,
|
|
307
343
|
},
|
|
308
|
-
defaultProps: { text: 'Section heading', level: 'h2', align: 'left' },
|
|
309
|
-
render: ({ text, level, align, style }) => {
|
|
344
|
+
defaultProps: { text: 'Section heading', level: 'h2', align: 'left', anchor: '' },
|
|
345
|
+
render: ({ text, level, align, style, anchor, anchorId }) => {
|
|
310
346
|
const Tag = level;
|
|
311
|
-
|
|
347
|
+
const id = (typeof anchorId === 'string' && anchorId) || anchorIdOf(anchor) || undefined;
|
|
348
|
+
return (_jsx("section", { className: cx('sw-block', 'sw-heading', `sw-align-${align}`, styleClassFor('Heading', style)), children: _jsx("div", { className: "sw-container", children: _jsx(Tag, { className: "sw-heading__text", id: id, children: text }) }) }));
|
|
312
349
|
},
|
|
313
350
|
},
|
|
314
351
|
Text: {
|
|
@@ -379,6 +416,8 @@ export const config = {
|
|
|
379
416
|
Search: searchComponent,
|
|
380
417
|
Ask: askComponent,
|
|
381
418
|
Menu: menuBlockComponent,
|
|
419
|
+
// The trail to the page, resolved by the server from its path or the main menu (see src/breadcrumbs.tsx).
|
|
420
|
+
Breadcrumbs: breadcrumbsBlockComponent,
|
|
382
421
|
Embed: {
|
|
383
422
|
label: 'Embed',
|
|
384
423
|
fields: {
|
|
@@ -400,10 +439,12 @@ export const config = {
|
|
|
400
439
|
label: { type: 'text', label: 'Label' },
|
|
401
440
|
href: { type: 'text', label: 'Link' },
|
|
402
441
|
align: { type: 'radio', label: 'Alignment', options: textAlignOptions },
|
|
442
|
+
icon: iconField(),
|
|
443
|
+
iconPosition: iconPositionField,
|
|
403
444
|
},
|
|
404
|
-
defaultProps: { label: 'Learn more', href: '#', align: 'left' },
|
|
445
|
+
defaultProps: { label: 'Learn more', href: '#', align: 'left', icon: '', iconPosition: 'after' },
|
|
405
446
|
// The emphasis comes from the style; the old `variant` only picks the style of a Button saved without one.
|
|
406
|
-
render: ({ label, href, variant, align, style }) => (_jsx("section", { className: cx('sw-block', 'sw-button-block', `sw-align-${align}`, styleClassFor('Button', style || (variant === 'secondary' ? 'secondary' : ''))), children: _jsx("div", { className: "sw-container", children: _jsx("div", { className: "sw-actions", children: _jsx(Button, { label: label, href: href, variant: variant === 'secondary' ? 'secondary' : 'primary' }) }) }) })),
|
|
447
|
+
render: ({ label, href, variant, align, style, icon, iconPosition }) => (_jsx("section", { className: cx('sw-block', 'sw-button-block', `sw-align-${align}`, styleClassFor('Button', style || (variant === 'secondary' ? 'secondary' : ''))), children: _jsx("div", { className: "sw-container", children: _jsx("div", { className: "sw-actions", children: _jsx(Button, { label: label, href: href, variant: variant === 'secondary' ? 'secondary' : 'primary', icon: icon, iconPosition: iconPosition }) }) }) })),
|
|
407
448
|
},
|
|
408
449
|
Buttons: {
|
|
409
450
|
label: 'Buttons',
|
|
@@ -427,8 +468,10 @@ export const config = {
|
|
|
427
468
|
],
|
|
428
469
|
},
|
|
429
470
|
newTab: { type: 'radio', label: 'Open in a new tab', options: yesNo },
|
|
471
|
+
icon: iconField(),
|
|
472
|
+
iconPosition: iconPositionField,
|
|
430
473
|
},
|
|
431
|
-
defaultItemProps: { label: 'Learn more', href: '', emphasis: 'secondary', newTab: false },
|
|
474
|
+
defaultItemProps: { label: 'Learn more', href: '', emphasis: 'secondary', newTab: false, icon: '', iconPosition: 'after' },
|
|
432
475
|
},
|
|
433
476
|
align: { type: 'radio', label: 'Alignment', options: textAlignOptions },
|
|
434
477
|
},
|
|
@@ -439,7 +482,7 @@ export const config = {
|
|
|
439
482
|
],
|
|
440
483
|
align: 'left',
|
|
441
484
|
},
|
|
442
|
-
render: ({ buttons, align }) => (_jsx("section", { className: cx('sw-block', 'sw-button-block', 'sw-buttons', `sw-align-${align}`), children: _jsx("div", { className: "sw-container", children: _jsx("div", { className: "sw-actions", children: (buttons ?? []).map((b, i) => (_jsx(Button, { label: b.label, href: b.href, variant: b.emphasis === 'secondary' || b.emphasis === 'link' ? b.emphasis : 'primary', newTab: b.newTab === true }, i))) }) }) })),
|
|
485
|
+
render: ({ buttons, align }) => (_jsx("section", { className: cx('sw-block', 'sw-button-block', 'sw-buttons', `sw-align-${align}`), children: _jsx("div", { className: "sw-container", children: _jsx("div", { className: "sw-actions", children: (buttons ?? []).map((b, i) => (_jsx(Button, { label: b.label, href: b.href, variant: b.emphasis === 'secondary' || b.emphasis === 'link' ? b.emphasis : 'primary', newTab: b.newTab === true, icon: b.icon, iconPosition: b.iconPosition }, i))) }) }) })),
|
|
443
486
|
},
|
|
444
487
|
// ----- Layout -----
|
|
445
488
|
Section: {
|
|
@@ -466,13 +509,46 @@ export const config = {
|
|
|
466
509
|
{ label: 'Wide', value: 'wide' },
|
|
467
510
|
],
|
|
468
511
|
},
|
|
512
|
+
backgroundImage: { type: 'text', label: 'Background image URL', placeholder: '/media/...' },
|
|
513
|
+
backgroundVideo: { type: 'text', label: 'Background video URL (needs a background image as its poster)', placeholder: '/media/....mp4' },
|
|
514
|
+
overlay: {
|
|
515
|
+
type: 'select',
|
|
516
|
+
label: 'Overlay on the image',
|
|
517
|
+
options: [
|
|
518
|
+
{ label: 'Dark', value: 'dark' },
|
|
519
|
+
{ label: 'Light', value: 'light' },
|
|
520
|
+
{ label: 'Primary color', value: 'primary' },
|
|
521
|
+
{ label: 'Secondary color', value: 'secondary' },
|
|
522
|
+
{ label: 'None', value: 'none' },
|
|
523
|
+
],
|
|
524
|
+
},
|
|
525
|
+
overlayStrength: { type: 'select', label: 'Overlay strength', options: SECTION_OVERLAY_STRENGTHS.map((n) => ({ label: `${n}%`, value: n })) },
|
|
526
|
+
textColor: {
|
|
527
|
+
type: 'radio',
|
|
528
|
+
label: 'Text color on the image',
|
|
529
|
+
options: [
|
|
530
|
+
{ label: 'Automatic', value: 'auto' },
|
|
531
|
+
{ label: 'Light', value: 'light' },
|
|
532
|
+
{ label: 'Dark', value: 'dark' },
|
|
533
|
+
],
|
|
534
|
+
},
|
|
535
|
+
anchor: anchorField,
|
|
469
536
|
},
|
|
470
|
-
defaultProps: { content: [], background: 'surface', width: 'normal' },
|
|
471
|
-
render: ({ content: Content, background, width }) => {
|
|
537
|
+
defaultProps: { content: [], background: 'surface', width: 'normal', backgroundImage: '', backgroundVideo: '', overlay: 'dark', overlayStrength: 60, textColor: 'auto', anchor: '' },
|
|
538
|
+
render: ({ content: Content, background, width, backgroundImage, backgroundVideo, overlay, overlayStrength, textColor, anchor, anchorId, backgroundMedia, backgroundPriority }) => {
|
|
472
539
|
const bg = ['surface', 'primary', 'secondary', 'dark'].includes(background) ? background : 'none';
|
|
473
|
-
|
|
540
|
+
const image = typeof backgroundImage === 'string' ? backgroundImage.trim() : '';
|
|
541
|
+
// A background video needs the image as its poster (what visitors who see no motion get), like the Hero's.
|
|
542
|
+
const video = image && isBackgroundVideo(backgroundVideo) ? backgroundVideo.trim() : '';
|
|
543
|
+
const ov = image ? sectionOverlayOf(overlay) : 'none';
|
|
544
|
+
const strength = sectionStrengthOf(overlayStrength);
|
|
545
|
+
const tone = image ? sectionTextTone(ov, textColor) : bg === 'primary' || bg === 'secondary' || bg === 'dark' ? 'light' : null;
|
|
546
|
+
const id = (typeof anchorId === 'string' && anchorId) || anchorIdOf(anchor) || undefined;
|
|
547
|
+
return (_jsxs("section", { id: id, className: cx('sw-block', 'sw-section', `sw-section--bg-${bg}`, (bg !== 'none' || image) && 'sw-section--filled', image && 'sw-section--media', image && ov !== 'none' && `sw-section--overlay-${ov} sw-section--strength-${strength}`, tone === 'light' && 'sw-section--on-dark', image && tone === 'dark' && 'sw-section--on-light'), children: [video ? (_jsxs(_Fragment, { children: [_jsx("video", { className: "sw-section__bg sw-section__video", muted: true, loop: true, playsInline: true, preload: "none", poster: backgroundMedia?.url ?? image, "aria-hidden": "true", "data-sw-bg-video": "", children: _jsx("source", { src: video, type: /\.webm(\?.*)?$/i.test(video) ? 'video/webm' : 'video/mp4' }) }), _jsx("button", { type: "button", className: "sw-video-toggle", "data-sw-video-toggle": "", "aria-pressed": "false", hidden: true, children: "Pause background video" })] })) : image ? (_jsx(ResponsiveImage, { className: "sw-section__bg", src: image, alt: "", media: backgroundMedia, sizes: "100vw", loading: backgroundPriority ? 'eager' : 'lazy', priority: backgroundPriority ? 'high' : 'auto' })) : null, image && ov !== 'none' ? _jsx("span", { className: "sw-section__overlay", "aria-hidden": "true" }) : null, _jsx("div", { className: cx('sw-container', width === 'narrow' && 'sw-container--narrow', width === 'wide' && 'sw-container--wide'), children: _jsx(Content, { className: "sw-section__body" }) })] }));
|
|
474
548
|
},
|
|
475
549
|
},
|
|
550
|
+
// Jump links to the page's headings, filled in by the server (see src/toc.tsx).
|
|
551
|
+
OnThisPage: onThisPageComponent,
|
|
476
552
|
Columns: {
|
|
477
553
|
label: 'Columns',
|
|
478
554
|
fields: {
|
|
@@ -580,7 +656,7 @@ const spaceOptions = [
|
|
|
580
656
|
{ label: 'L', value: 'l' },
|
|
581
657
|
{ label: 'XL', value: 'xl' },
|
|
582
658
|
];
|
|
583
|
-
export const SPACED_BLOCKS = ['Section', 'Columns', 'Divider', 'Heading', 'Text', 'Image', 'Gallery', 'Video', 'Search', 'Ask', 'Embed', 'Lottie', 'Model3D', 'Button', 'Buttons', 'Hero', 'CallToAction', 'Cards', 'Faq', 'Testimonials', 'Stats', 'LogoStrip', 'Scrollytelling', 'Collection', 'Calendar', 'MiniCalendar', 'Form'];
|
|
659
|
+
export const SPACED_BLOCKS = ['Section', 'Columns', 'Tabs', 'Accordion', 'Carousel', 'OnThisPage', 'Divider', 'Heading', 'Text', 'Image', 'Gallery', 'Video', 'Search', 'Ask', 'Embed', 'Lottie', 'Model3D', 'Button', 'Buttons', 'Hero', 'CallToAction', 'Cards', 'Faq', 'Testimonials', 'Stats', 'LogoStrip', 'Scrollytelling', 'Collection', 'Calendar', 'MiniCalendar', 'Form'];
|
|
584
660
|
/** The classes for a block's Space above and Space below; unknown values are ignored. */
|
|
585
661
|
export function spacingClasses(props) {
|
|
586
662
|
const out = [];
|
|
@@ -595,8 +671,8 @@ export function spacingClasses(props) {
|
|
|
595
671
|
/** Blocks whose items (cards, images, logos, quotes, buttons, list items) can arrive one after another and respond to hover. */
|
|
596
672
|
export const MOTION_ITEM_BLOCKS = ['Image', 'Gallery', 'Buttons', 'Button', 'Cards', 'Faq', 'Testimonials', 'Stats', 'LogoStrip', 'Collection'];
|
|
597
673
|
const ENTRANCE_LABELS = { none: 'None', fade: 'Fade in', rise: 'Rise', scale: 'Scale up', 'slide-left': 'Slide from the left', 'slide-right': 'Slide from the right' };
|
|
598
|
-
/** Blocks with a background image that parallax can move. */
|
|
599
|
-
export const MOTION_PARALLAX_BLOCKS = ['Hero'];
|
|
674
|
+
/** Blocks with a background image that parallax can move (a Section's only when it has one). */
|
|
675
|
+
export const MOTION_PARALLAX_BLOCKS = ['Hero', 'Section'];
|
|
600
676
|
const SCROLL_LABELS = { none: 'None', parallax: 'Parallax background', 'fade-out': 'Fade out as it leaves', pin: 'Pin while the next blocks scroll over' };
|
|
601
677
|
const HOVER_LABELS = { none: 'None', lift: 'Lift', zoom: 'Zoom the image', tilt: 'Tilt (expressive brands only)' };
|
|
602
678
|
const DELAYS = ['none', 'short', 'medium'];
|
|
@@ -628,13 +704,17 @@ export const MOTION_SCRIPT_BLOCKS = ['Scrollytelling', 'Lottie', 'Model3D'];
|
|
|
628
704
|
export const PLAYER_BLOCKS = ['Lottie', 'Model3D'];
|
|
629
705
|
/**
|
|
630
706
|
* Whether a block asks for any motion (the page then carries the motion script): Motion settings, Stats that count up, a marquee,
|
|
631
|
-
* a Hero's video, a muted Video that plays on its own, or a block in MOTION_SCRIPT_BLOCKS (pass
|
|
707
|
+
* a Hero's video, a muted Video that plays on its own, a Carousel that plays on its own, or a block in MOTION_SCRIPT_BLOCKS (pass
|
|
708
|
+
* its type).
|
|
632
709
|
*/
|
|
633
710
|
export function hasMotion(props, type) {
|
|
634
711
|
if (type && MOTION_SCRIPT_BLOCKS.includes(type))
|
|
635
712
|
return true;
|
|
636
713
|
if (type === 'Video' && props?.autoplay === true && props?.muted === true)
|
|
637
714
|
return true;
|
|
715
|
+
// Autoplay counts as motion: the brand's level gates it, and the page gets the visitor's Reduce motion switch.
|
|
716
|
+
if (type === 'Carousel' && props?.autoplay === true)
|
|
717
|
+
return true;
|
|
638
718
|
// A module block resolved as a scene (its props carry `scene`).
|
|
639
719
|
if (type === 'ModuleBlock' && props?.scene)
|
|
640
720
|
return true;
|