@spectare-personalisation/react 0.4.0 → 0.6.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/dist/index.cjs +292 -164
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -55
- package/dist/index.d.ts +98 -55
- package/dist/index.js +213 -115
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -44,12 +44,59 @@ interface PersonalisedSectionProps {
|
|
|
44
44
|
align?: 'left' | 'center' | 'right';
|
|
45
45
|
/**
|
|
46
46
|
* Brand accent. Passed through to ComponentRenderer, which emits it into the scoped
|
|
47
|
-
* token set. Defaults to #60a5fa.
|
|
47
|
+
* token set. Defaults to #60a5fa (dark) or #2563eb (light).
|
|
48
48
|
*/
|
|
49
49
|
accent?: string;
|
|
50
|
+
/** dark (default) or light, matching your page's ground. See ComponentRenderer. */
|
|
51
|
+
theme?: 'dark' | 'light';
|
|
50
52
|
}
|
|
51
|
-
declare function PersonalisedSection({ orgSlug, baseUrl, brand, pageHint, className, style, initialAssembly, initialIntent, initialVariantId, directSummary, zone, align, accent, }: PersonalisedSectionProps): react_jsx_runtime.JSX.Element | null;
|
|
53
|
+
declare function PersonalisedSection({ orgSlug, baseUrl, brand, pageHint, className, style, initialAssembly, initialIntent, initialVariantId, directSummary, zone, align, accent, theme, }: PersonalisedSectionProps): react_jsx_runtime.JSX.Element | null;
|
|
52
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The one place this package's design tokens are defined.
|
|
57
|
+
*
|
|
58
|
+
* Two things that are easy to get wrong here:
|
|
59
|
+
*
|
|
60
|
+
* 1. Tokens are declared on `.sp-root`, not `:root`. Declaring them at `:root` writes into
|
|
61
|
+
* the host's document, allows only one theme per page, and means a customer overriding
|
|
62
|
+
* `--sp-accent` competes with us at equal specificity so tag order decides the winner.
|
|
63
|
+
* Scoping also lets two differently themed sections sit on one page.
|
|
64
|
+
*
|
|
65
|
+
* 2. `tokens.css` must stay byte-identical to `buildTokenCss({ scope: STYLESHEET_SCOPE })`,
|
|
66
|
+
* which differs from the injected CSS in its selector and in nothing else.
|
|
67
|
+
* tests/unit/react-tokens.test.ts enforces both halves, because a customer who imports the
|
|
68
|
+
* stylesheet and a customer who renders the component must get the same page.
|
|
69
|
+
*
|
|
70
|
+
* components/ServerAssemblyRenderer.tsx in the Spectare app is a deliberate mirror of the
|
|
71
|
+
* values below. It is not the same file: that renderer uses rem, this one uses px.
|
|
72
|
+
*/
|
|
73
|
+
/** The package default. `spectare.js` and the WordPress plugin default to #2563eb, which is
|
|
74
|
+
* a live inconsistency and a brand decision rather than a technical one, so it is left alone
|
|
75
|
+
* here. Pass `accent` to override on either path. */
|
|
76
|
+
declare const DEFAULT_ACCENT = "#60a5fa";
|
|
77
|
+
type SpTheme = 'dark' | 'light';
|
|
78
|
+
/** Class the tokens are scoped to. Applied by ComponentRenderer to its own wrapper. */
|
|
79
|
+
declare const SP_ROOT = "sp-root";
|
|
80
|
+
/**
|
|
81
|
+
* Returns the stylesheet a renderer injects.
|
|
82
|
+
*
|
|
83
|
+
* @param accent brand colour. Accepts anything CSS does; `--sp-accent-bg` and
|
|
84
|
+
* `--sp-accent-border` are derived from it so a customer sets one value
|
|
85
|
+
* rather than three. Defaults to DEFAULT_ACCENT.
|
|
86
|
+
* @param unit length unit for layout rules. 'px' for this package, 'rem' for the app's
|
|
87
|
+
* server renderer, which sizes in rem throughout.
|
|
88
|
+
* @param scope selector the custom properties are declared on. Defaults to `.sp-root`, which is
|
|
89
|
+
* what a renderer injecting this at runtime wants. `tokens.css` is generated with
|
|
90
|
+
* STYLESHEET_SCOPE instead, so importing it works without a wrapper.
|
|
91
|
+
*/
|
|
92
|
+
declare function buildTokenCss({ accent, unit, scope, theme }?: {
|
|
93
|
+
accent?: string;
|
|
94
|
+
unit?: 'px' | 'rem';
|
|
95
|
+
scope?: string;
|
|
96
|
+
theme?: SpTheme;
|
|
97
|
+
}): string;
|
|
98
|
+
|
|
99
|
+
type Unit = 'px' | 'rem';
|
|
53
100
|
type Align = 'left' | 'center' | 'right';
|
|
54
101
|
/**
|
|
55
102
|
* A single line above everything else. Deliberately the plainest component in the set: no
|
|
@@ -60,21 +107,24 @@ type Align = 'left' | 'center' | 'right';
|
|
|
60
107
|
* warning, and a venue putting "members book from Thursday" in an alarm colour reads as a problem
|
|
61
108
|
* rather than an offer.
|
|
62
109
|
*/
|
|
63
|
-
declare function AnnouncementBar({ text, link }: {
|
|
110
|
+
declare function AnnouncementBar({ text, link, unit }: {
|
|
64
111
|
text?: string;
|
|
65
112
|
link?: {
|
|
66
113
|
label: string;
|
|
67
114
|
href: string;
|
|
68
115
|
};
|
|
116
|
+
unit?: Unit;
|
|
69
117
|
}): react_jsx_runtime.JSX.Element | null;
|
|
70
|
-
declare function HeroStatement({ headline, subheading, align }: {
|
|
118
|
+
declare function HeroStatement({ headline, subheading, align, unit }: {
|
|
71
119
|
headline: string;
|
|
72
120
|
subheading?: string;
|
|
73
121
|
align?: Align;
|
|
122
|
+
unit?: Unit;
|
|
74
123
|
}): react_jsx_runtime.JSX.Element;
|
|
75
|
-
declare function AtomCard({ title, content, layout, stats, ctaText, ctaUrl, full }: {
|
|
124
|
+
declare function AtomCard({ title, content, summary, layout, stats, ctaText, ctaUrl, full, variant, unit }: {
|
|
76
125
|
title?: string;
|
|
77
126
|
content?: string;
|
|
127
|
+
summary?: string;
|
|
78
128
|
layout?: string[];
|
|
79
129
|
stats?: {
|
|
80
130
|
value: string;
|
|
@@ -83,20 +133,24 @@ declare function AtomCard({ title, content, layout, stats, ctaText, ctaUrl, full
|
|
|
83
133
|
ctaText?: string;
|
|
84
134
|
ctaUrl?: string;
|
|
85
135
|
full?: boolean;
|
|
136
|
+
variant?: string;
|
|
137
|
+
unit?: Unit;
|
|
86
138
|
}): react_jsx_runtime.JSX.Element;
|
|
87
|
-
declare function StatGrid({ stats, caption }: {
|
|
139
|
+
declare function StatGrid({ stats, caption, unit }: {
|
|
88
140
|
stats?: {
|
|
89
141
|
value: string;
|
|
90
142
|
label: string;
|
|
91
143
|
}[];
|
|
92
144
|
caption?: string;
|
|
145
|
+
unit?: Unit;
|
|
93
146
|
}): react_jsx_runtime.JSX.Element;
|
|
94
|
-
declare function CodeBlock({ code, lang, caption }: {
|
|
147
|
+
declare function CodeBlock({ code, lang, caption, unit }: {
|
|
95
148
|
code: string;
|
|
96
149
|
lang?: string;
|
|
97
150
|
caption?: string;
|
|
151
|
+
unit?: Unit;
|
|
98
152
|
}): react_jsx_runtime.JSX.Element;
|
|
99
|
-
declare function ComparisonTable({ brand, competitor, rows }: {
|
|
153
|
+
declare function ComparisonTable({ brand, competitor, rows, unit }: {
|
|
100
154
|
brand?: string;
|
|
101
155
|
competitor: string;
|
|
102
156
|
rows?: {
|
|
@@ -104,20 +158,23 @@ declare function ComparisonTable({ brand, competitor, rows }: {
|
|
|
104
158
|
spectare: string;
|
|
105
159
|
them: string;
|
|
106
160
|
}[];
|
|
161
|
+
unit?: Unit;
|
|
107
162
|
}): react_jsx_runtime.JSX.Element;
|
|
108
|
-
declare function FeatureList({ items }: {
|
|
163
|
+
declare function FeatureList({ items, unit }: {
|
|
109
164
|
items?: {
|
|
110
165
|
text: string;
|
|
111
166
|
sub?: string;
|
|
112
167
|
}[];
|
|
168
|
+
unit?: Unit;
|
|
113
169
|
}): react_jsx_runtime.JSX.Element;
|
|
114
|
-
declare function TestimonialCard({ quote, name, role, company }: {
|
|
170
|
+
declare function TestimonialCard({ quote, name, role, company, unit }: {
|
|
115
171
|
quote: string;
|
|
116
172
|
name: string;
|
|
117
173
|
role: string;
|
|
118
174
|
company?: string;
|
|
175
|
+
unit?: Unit;
|
|
119
176
|
}): react_jsx_runtime.JSX.Element;
|
|
120
|
-
declare function ImageCtaHero({ src, alt, headline, subheading, ctaLabel, ctaHref, align }: {
|
|
177
|
+
declare function ImageCtaHero({ src, alt, headline, subheading, ctaLabel, ctaHref, align, unit }: {
|
|
121
178
|
src?: string;
|
|
122
179
|
alt?: string;
|
|
123
180
|
headline?: string;
|
|
@@ -125,8 +182,9 @@ declare function ImageCtaHero({ src, alt, headline, subheading, ctaLabel, ctaHre
|
|
|
125
182
|
ctaLabel?: string;
|
|
126
183
|
ctaHref?: string;
|
|
127
184
|
align?: Align;
|
|
185
|
+
unit?: Unit;
|
|
128
186
|
}): react_jsx_runtime.JSX.Element | null;
|
|
129
|
-
declare function CtaStrip({ headline, primary, secondary, align }: {
|
|
187
|
+
declare function CtaStrip({ headline, primary, secondary, align, unit }: {
|
|
130
188
|
headline: string;
|
|
131
189
|
primary: {
|
|
132
190
|
label: string;
|
|
@@ -137,6 +195,7 @@ declare function CtaStrip({ headline, primary, secondary, align }: {
|
|
|
137
195
|
href: string;
|
|
138
196
|
};
|
|
139
197
|
align?: Align;
|
|
198
|
+
unit?: Unit;
|
|
140
199
|
}): react_jsx_runtime.JSX.Element;
|
|
141
200
|
interface ComponentRendererProps {
|
|
142
201
|
assembly: ComponentAssembly;
|
|
@@ -158,49 +217,33 @@ interface ComponentRendererProps {
|
|
|
158
217
|
* from it, so one value covers all three. Defaults to #60a5fa.
|
|
159
218
|
*/
|
|
160
219
|
accent?: string;
|
|
220
|
+
/**
|
|
221
|
+
* dark (default) is the package's original near-black card set. light renders white cards
|
|
222
|
+
* with a dark text ramp for light host pages; without it the components paint near-white
|
|
223
|
+
* text and near-black slabs onto a light ground. Both palettes hold the same contrast
|
|
224
|
+
* floors (see tests/unit/token-contrast.test.ts).
|
|
225
|
+
*/
|
|
226
|
+
theme?: SpTheme;
|
|
227
|
+
/**
|
|
228
|
+
* px (default) sizes components absolutely, predictable inside arbitrary host pages.
|
|
229
|
+
* rem tracks the reader's font-size preference; the root then also inherits the host's
|
|
230
|
+
* font size instead of pinning 16px.
|
|
231
|
+
*/
|
|
232
|
+
unit?: Unit;
|
|
233
|
+
/**
|
|
234
|
+
* Substitute rendering for an item: return a node to replace the built-in renderer
|
|
235
|
+
* (including null to render nothing), or undefined to keep the default. How the Spectare
|
|
236
|
+
* app swaps the card-variant AtomCard for its server-rendered card face.
|
|
237
|
+
*/
|
|
238
|
+
renderOverride?: (item: ComponentAssembly[0]) => React.ReactNode | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Wrap each rendered item, e.g. with source attribution or a debug badge. Receives the
|
|
241
|
+
* assembly item and its rendered node; whatever it returns is placed in the layout.
|
|
242
|
+
*/
|
|
243
|
+
renderItem?: (item: ComponentAssembly[0], rendered: React.ReactNode) => React.ReactNode;
|
|
244
|
+
/** Extra attributes for the root element (e.g. a data marker a host overlay targets). */
|
|
245
|
+
rootProps?: Record<string, unknown>;
|
|
161
246
|
}
|
|
162
|
-
declare function ComponentRenderer({ assembly, brand, xray, zone, align, accent }: ComponentRendererProps): react_jsx_runtime.JSX.Element;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* The one place this package's design tokens are defined.
|
|
166
|
-
*
|
|
167
|
-
* Two things that are easy to get wrong here:
|
|
168
|
-
*
|
|
169
|
-
* 1. Tokens are declared on `.sp-root`, not `:root`. Declaring them at `:root` writes into
|
|
170
|
-
* the host's document, allows only one theme per page, and means a customer overriding
|
|
171
|
-
* `--sp-accent` competes with us at equal specificity so tag order decides the winner.
|
|
172
|
-
* Scoping also lets two differently themed sections sit on one page.
|
|
173
|
-
*
|
|
174
|
-
* 2. `tokens.css` must stay byte-identical to `buildTokenCss({ scope: STYLESHEET_SCOPE })`,
|
|
175
|
-
* which differs from the injected CSS in its selector and in nothing else.
|
|
176
|
-
* tests/unit/react-tokens.test.ts enforces both halves, because a customer who imports the
|
|
177
|
-
* stylesheet and a customer who renders the component must get the same page.
|
|
178
|
-
*
|
|
179
|
-
* components/ServerAssemblyRenderer.tsx in the Spectare app is a deliberate mirror of the
|
|
180
|
-
* values below. It is not the same file: that renderer uses rem, this one uses px.
|
|
181
|
-
*/
|
|
182
|
-
/** The package default. `spectare.js` and the WordPress plugin default to #2563eb, which is
|
|
183
|
-
* a live inconsistency and a brand decision rather than a technical one, so it is left alone
|
|
184
|
-
* here. Pass `accent` to override on either path. */
|
|
185
|
-
declare const DEFAULT_ACCENT = "#60a5fa";
|
|
186
|
-
/** Class the tokens are scoped to. Applied by ComponentRenderer to its own wrapper. */
|
|
187
|
-
declare const SP_ROOT = "sp-root";
|
|
188
|
-
/**
|
|
189
|
-
* Returns the stylesheet a renderer injects.
|
|
190
|
-
*
|
|
191
|
-
* @param accent brand colour. Accepts anything CSS does; `--sp-accent-bg` and
|
|
192
|
-
* `--sp-accent-border` are derived from it so a customer sets one value
|
|
193
|
-
* rather than three. Defaults to DEFAULT_ACCENT.
|
|
194
|
-
* @param unit length unit for layout rules. 'px' for this package, 'rem' for the app's
|
|
195
|
-
* server renderer, which sizes in rem throughout.
|
|
196
|
-
* @param scope selector the custom properties are declared on. Defaults to `.sp-root`, which is
|
|
197
|
-
* what a renderer injecting this at runtime wants. `tokens.css` is generated with
|
|
198
|
-
* STYLESHEET_SCOPE instead, so importing it works without a wrapper.
|
|
199
|
-
*/
|
|
200
|
-
declare function buildTokenCss({ accent, unit, scope }?: {
|
|
201
|
-
accent?: string;
|
|
202
|
-
unit?: 'px' | 'rem';
|
|
203
|
-
scope?: string;
|
|
204
|
-
}): string;
|
|
247
|
+
declare function ComponentRenderer({ assembly, brand, xray, zone, align, accent, theme, unit, renderOverride, renderItem, rootProps }: ComponentRendererProps): react_jsx_runtime.JSX.Element;
|
|
205
248
|
|
|
206
249
|
export { AnnouncementBar, type AssemblyZone, AtomCard, CodeBlock, ComparisonTable, type ComponentAssembly, type ComponentName, ComponentRenderer, type ComponentRendererProps, CtaStrip, DEFAULT_ACCENT, FeatureList, HeroStatement, ImageCtaHero, PersonalisedSection, type PersonalisedSectionProps, SP_ROOT, StatGrid, TestimonialCard, buildTokenCss, filterAssemblyByZone };
|
package/dist/index.d.ts
CHANGED
|
@@ -44,12 +44,59 @@ interface PersonalisedSectionProps {
|
|
|
44
44
|
align?: 'left' | 'center' | 'right';
|
|
45
45
|
/**
|
|
46
46
|
* Brand accent. Passed through to ComponentRenderer, which emits it into the scoped
|
|
47
|
-
* token set. Defaults to #60a5fa.
|
|
47
|
+
* token set. Defaults to #60a5fa (dark) or #2563eb (light).
|
|
48
48
|
*/
|
|
49
49
|
accent?: string;
|
|
50
|
+
/** dark (default) or light, matching your page's ground. See ComponentRenderer. */
|
|
51
|
+
theme?: 'dark' | 'light';
|
|
50
52
|
}
|
|
51
|
-
declare function PersonalisedSection({ orgSlug, baseUrl, brand, pageHint, className, style, initialAssembly, initialIntent, initialVariantId, directSummary, zone, align, accent, }: PersonalisedSectionProps): react_jsx_runtime.JSX.Element | null;
|
|
53
|
+
declare function PersonalisedSection({ orgSlug, baseUrl, brand, pageHint, className, style, initialAssembly, initialIntent, initialVariantId, directSummary, zone, align, accent, theme, }: PersonalisedSectionProps): react_jsx_runtime.JSX.Element | null;
|
|
52
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The one place this package's design tokens are defined.
|
|
57
|
+
*
|
|
58
|
+
* Two things that are easy to get wrong here:
|
|
59
|
+
*
|
|
60
|
+
* 1. Tokens are declared on `.sp-root`, not `:root`. Declaring them at `:root` writes into
|
|
61
|
+
* the host's document, allows only one theme per page, and means a customer overriding
|
|
62
|
+
* `--sp-accent` competes with us at equal specificity so tag order decides the winner.
|
|
63
|
+
* Scoping also lets two differently themed sections sit on one page.
|
|
64
|
+
*
|
|
65
|
+
* 2. `tokens.css` must stay byte-identical to `buildTokenCss({ scope: STYLESHEET_SCOPE })`,
|
|
66
|
+
* which differs from the injected CSS in its selector and in nothing else.
|
|
67
|
+
* tests/unit/react-tokens.test.ts enforces both halves, because a customer who imports the
|
|
68
|
+
* stylesheet and a customer who renders the component must get the same page.
|
|
69
|
+
*
|
|
70
|
+
* components/ServerAssemblyRenderer.tsx in the Spectare app is a deliberate mirror of the
|
|
71
|
+
* values below. It is not the same file: that renderer uses rem, this one uses px.
|
|
72
|
+
*/
|
|
73
|
+
/** The package default. `spectare.js` and the WordPress plugin default to #2563eb, which is
|
|
74
|
+
* a live inconsistency and a brand decision rather than a technical one, so it is left alone
|
|
75
|
+
* here. Pass `accent` to override on either path. */
|
|
76
|
+
declare const DEFAULT_ACCENT = "#60a5fa";
|
|
77
|
+
type SpTheme = 'dark' | 'light';
|
|
78
|
+
/** Class the tokens are scoped to. Applied by ComponentRenderer to its own wrapper. */
|
|
79
|
+
declare const SP_ROOT = "sp-root";
|
|
80
|
+
/**
|
|
81
|
+
* Returns the stylesheet a renderer injects.
|
|
82
|
+
*
|
|
83
|
+
* @param accent brand colour. Accepts anything CSS does; `--sp-accent-bg` and
|
|
84
|
+
* `--sp-accent-border` are derived from it so a customer sets one value
|
|
85
|
+
* rather than three. Defaults to DEFAULT_ACCENT.
|
|
86
|
+
* @param unit length unit for layout rules. 'px' for this package, 'rem' for the app's
|
|
87
|
+
* server renderer, which sizes in rem throughout.
|
|
88
|
+
* @param scope selector the custom properties are declared on. Defaults to `.sp-root`, which is
|
|
89
|
+
* what a renderer injecting this at runtime wants. `tokens.css` is generated with
|
|
90
|
+
* STYLESHEET_SCOPE instead, so importing it works without a wrapper.
|
|
91
|
+
*/
|
|
92
|
+
declare function buildTokenCss({ accent, unit, scope, theme }?: {
|
|
93
|
+
accent?: string;
|
|
94
|
+
unit?: 'px' | 'rem';
|
|
95
|
+
scope?: string;
|
|
96
|
+
theme?: SpTheme;
|
|
97
|
+
}): string;
|
|
98
|
+
|
|
99
|
+
type Unit = 'px' | 'rem';
|
|
53
100
|
type Align = 'left' | 'center' | 'right';
|
|
54
101
|
/**
|
|
55
102
|
* A single line above everything else. Deliberately the plainest component in the set: no
|
|
@@ -60,21 +107,24 @@ type Align = 'left' | 'center' | 'right';
|
|
|
60
107
|
* warning, and a venue putting "members book from Thursday" in an alarm colour reads as a problem
|
|
61
108
|
* rather than an offer.
|
|
62
109
|
*/
|
|
63
|
-
declare function AnnouncementBar({ text, link }: {
|
|
110
|
+
declare function AnnouncementBar({ text, link, unit }: {
|
|
64
111
|
text?: string;
|
|
65
112
|
link?: {
|
|
66
113
|
label: string;
|
|
67
114
|
href: string;
|
|
68
115
|
};
|
|
116
|
+
unit?: Unit;
|
|
69
117
|
}): react_jsx_runtime.JSX.Element | null;
|
|
70
|
-
declare function HeroStatement({ headline, subheading, align }: {
|
|
118
|
+
declare function HeroStatement({ headline, subheading, align, unit }: {
|
|
71
119
|
headline: string;
|
|
72
120
|
subheading?: string;
|
|
73
121
|
align?: Align;
|
|
122
|
+
unit?: Unit;
|
|
74
123
|
}): react_jsx_runtime.JSX.Element;
|
|
75
|
-
declare function AtomCard({ title, content, layout, stats, ctaText, ctaUrl, full }: {
|
|
124
|
+
declare function AtomCard({ title, content, summary, layout, stats, ctaText, ctaUrl, full, variant, unit }: {
|
|
76
125
|
title?: string;
|
|
77
126
|
content?: string;
|
|
127
|
+
summary?: string;
|
|
78
128
|
layout?: string[];
|
|
79
129
|
stats?: {
|
|
80
130
|
value: string;
|
|
@@ -83,20 +133,24 @@ declare function AtomCard({ title, content, layout, stats, ctaText, ctaUrl, full
|
|
|
83
133
|
ctaText?: string;
|
|
84
134
|
ctaUrl?: string;
|
|
85
135
|
full?: boolean;
|
|
136
|
+
variant?: string;
|
|
137
|
+
unit?: Unit;
|
|
86
138
|
}): react_jsx_runtime.JSX.Element;
|
|
87
|
-
declare function StatGrid({ stats, caption }: {
|
|
139
|
+
declare function StatGrid({ stats, caption, unit }: {
|
|
88
140
|
stats?: {
|
|
89
141
|
value: string;
|
|
90
142
|
label: string;
|
|
91
143
|
}[];
|
|
92
144
|
caption?: string;
|
|
145
|
+
unit?: Unit;
|
|
93
146
|
}): react_jsx_runtime.JSX.Element;
|
|
94
|
-
declare function CodeBlock({ code, lang, caption }: {
|
|
147
|
+
declare function CodeBlock({ code, lang, caption, unit }: {
|
|
95
148
|
code: string;
|
|
96
149
|
lang?: string;
|
|
97
150
|
caption?: string;
|
|
151
|
+
unit?: Unit;
|
|
98
152
|
}): react_jsx_runtime.JSX.Element;
|
|
99
|
-
declare function ComparisonTable({ brand, competitor, rows }: {
|
|
153
|
+
declare function ComparisonTable({ brand, competitor, rows, unit }: {
|
|
100
154
|
brand?: string;
|
|
101
155
|
competitor: string;
|
|
102
156
|
rows?: {
|
|
@@ -104,20 +158,23 @@ declare function ComparisonTable({ brand, competitor, rows }: {
|
|
|
104
158
|
spectare: string;
|
|
105
159
|
them: string;
|
|
106
160
|
}[];
|
|
161
|
+
unit?: Unit;
|
|
107
162
|
}): react_jsx_runtime.JSX.Element;
|
|
108
|
-
declare function FeatureList({ items }: {
|
|
163
|
+
declare function FeatureList({ items, unit }: {
|
|
109
164
|
items?: {
|
|
110
165
|
text: string;
|
|
111
166
|
sub?: string;
|
|
112
167
|
}[];
|
|
168
|
+
unit?: Unit;
|
|
113
169
|
}): react_jsx_runtime.JSX.Element;
|
|
114
|
-
declare function TestimonialCard({ quote, name, role, company }: {
|
|
170
|
+
declare function TestimonialCard({ quote, name, role, company, unit }: {
|
|
115
171
|
quote: string;
|
|
116
172
|
name: string;
|
|
117
173
|
role: string;
|
|
118
174
|
company?: string;
|
|
175
|
+
unit?: Unit;
|
|
119
176
|
}): react_jsx_runtime.JSX.Element;
|
|
120
|
-
declare function ImageCtaHero({ src, alt, headline, subheading, ctaLabel, ctaHref, align }: {
|
|
177
|
+
declare function ImageCtaHero({ src, alt, headline, subheading, ctaLabel, ctaHref, align, unit }: {
|
|
121
178
|
src?: string;
|
|
122
179
|
alt?: string;
|
|
123
180
|
headline?: string;
|
|
@@ -125,8 +182,9 @@ declare function ImageCtaHero({ src, alt, headline, subheading, ctaLabel, ctaHre
|
|
|
125
182
|
ctaLabel?: string;
|
|
126
183
|
ctaHref?: string;
|
|
127
184
|
align?: Align;
|
|
185
|
+
unit?: Unit;
|
|
128
186
|
}): react_jsx_runtime.JSX.Element | null;
|
|
129
|
-
declare function CtaStrip({ headline, primary, secondary, align }: {
|
|
187
|
+
declare function CtaStrip({ headline, primary, secondary, align, unit }: {
|
|
130
188
|
headline: string;
|
|
131
189
|
primary: {
|
|
132
190
|
label: string;
|
|
@@ -137,6 +195,7 @@ declare function CtaStrip({ headline, primary, secondary, align }: {
|
|
|
137
195
|
href: string;
|
|
138
196
|
};
|
|
139
197
|
align?: Align;
|
|
198
|
+
unit?: Unit;
|
|
140
199
|
}): react_jsx_runtime.JSX.Element;
|
|
141
200
|
interface ComponentRendererProps {
|
|
142
201
|
assembly: ComponentAssembly;
|
|
@@ -158,49 +217,33 @@ interface ComponentRendererProps {
|
|
|
158
217
|
* from it, so one value covers all three. Defaults to #60a5fa.
|
|
159
218
|
*/
|
|
160
219
|
accent?: string;
|
|
220
|
+
/**
|
|
221
|
+
* dark (default) is the package's original near-black card set. light renders white cards
|
|
222
|
+
* with a dark text ramp for light host pages; without it the components paint near-white
|
|
223
|
+
* text and near-black slabs onto a light ground. Both palettes hold the same contrast
|
|
224
|
+
* floors (see tests/unit/token-contrast.test.ts).
|
|
225
|
+
*/
|
|
226
|
+
theme?: SpTheme;
|
|
227
|
+
/**
|
|
228
|
+
* px (default) sizes components absolutely, predictable inside arbitrary host pages.
|
|
229
|
+
* rem tracks the reader's font-size preference; the root then also inherits the host's
|
|
230
|
+
* font size instead of pinning 16px.
|
|
231
|
+
*/
|
|
232
|
+
unit?: Unit;
|
|
233
|
+
/**
|
|
234
|
+
* Substitute rendering for an item: return a node to replace the built-in renderer
|
|
235
|
+
* (including null to render nothing), or undefined to keep the default. How the Spectare
|
|
236
|
+
* app swaps the card-variant AtomCard for its server-rendered card face.
|
|
237
|
+
*/
|
|
238
|
+
renderOverride?: (item: ComponentAssembly[0]) => React.ReactNode | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Wrap each rendered item, e.g. with source attribution or a debug badge. Receives the
|
|
241
|
+
* assembly item and its rendered node; whatever it returns is placed in the layout.
|
|
242
|
+
*/
|
|
243
|
+
renderItem?: (item: ComponentAssembly[0], rendered: React.ReactNode) => React.ReactNode;
|
|
244
|
+
/** Extra attributes for the root element (e.g. a data marker a host overlay targets). */
|
|
245
|
+
rootProps?: Record<string, unknown>;
|
|
161
246
|
}
|
|
162
|
-
declare function ComponentRenderer({ assembly, brand, xray, zone, align, accent }: ComponentRendererProps): react_jsx_runtime.JSX.Element;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* The one place this package's design tokens are defined.
|
|
166
|
-
*
|
|
167
|
-
* Two things that are easy to get wrong here:
|
|
168
|
-
*
|
|
169
|
-
* 1. Tokens are declared on `.sp-root`, not `:root`. Declaring them at `:root` writes into
|
|
170
|
-
* the host's document, allows only one theme per page, and means a customer overriding
|
|
171
|
-
* `--sp-accent` competes with us at equal specificity so tag order decides the winner.
|
|
172
|
-
* Scoping also lets two differently themed sections sit on one page.
|
|
173
|
-
*
|
|
174
|
-
* 2. `tokens.css` must stay byte-identical to `buildTokenCss({ scope: STYLESHEET_SCOPE })`,
|
|
175
|
-
* which differs from the injected CSS in its selector and in nothing else.
|
|
176
|
-
* tests/unit/react-tokens.test.ts enforces both halves, because a customer who imports the
|
|
177
|
-
* stylesheet and a customer who renders the component must get the same page.
|
|
178
|
-
*
|
|
179
|
-
* components/ServerAssemblyRenderer.tsx in the Spectare app is a deliberate mirror of the
|
|
180
|
-
* values below. It is not the same file: that renderer uses rem, this one uses px.
|
|
181
|
-
*/
|
|
182
|
-
/** The package default. `spectare.js` and the WordPress plugin default to #2563eb, which is
|
|
183
|
-
* a live inconsistency and a brand decision rather than a technical one, so it is left alone
|
|
184
|
-
* here. Pass `accent` to override on either path. */
|
|
185
|
-
declare const DEFAULT_ACCENT = "#60a5fa";
|
|
186
|
-
/** Class the tokens are scoped to. Applied by ComponentRenderer to its own wrapper. */
|
|
187
|
-
declare const SP_ROOT = "sp-root";
|
|
188
|
-
/**
|
|
189
|
-
* Returns the stylesheet a renderer injects.
|
|
190
|
-
*
|
|
191
|
-
* @param accent brand colour. Accepts anything CSS does; `--sp-accent-bg` and
|
|
192
|
-
* `--sp-accent-border` are derived from it so a customer sets one value
|
|
193
|
-
* rather than three. Defaults to DEFAULT_ACCENT.
|
|
194
|
-
* @param unit length unit for layout rules. 'px' for this package, 'rem' for the app's
|
|
195
|
-
* server renderer, which sizes in rem throughout.
|
|
196
|
-
* @param scope selector the custom properties are declared on. Defaults to `.sp-root`, which is
|
|
197
|
-
* what a renderer injecting this at runtime wants. `tokens.css` is generated with
|
|
198
|
-
* STYLESHEET_SCOPE instead, so importing it works without a wrapper.
|
|
199
|
-
*/
|
|
200
|
-
declare function buildTokenCss({ accent, unit, scope }?: {
|
|
201
|
-
accent?: string;
|
|
202
|
-
unit?: 'px' | 'rem';
|
|
203
|
-
scope?: string;
|
|
204
|
-
}): string;
|
|
247
|
+
declare function ComponentRenderer({ assembly, brand, xray, zone, align, accent, theme, unit, renderOverride, renderItem, rootProps }: ComponentRendererProps): react_jsx_runtime.JSX.Element;
|
|
205
248
|
|
|
206
249
|
export { AnnouncementBar, type AssemblyZone, AtomCard, CodeBlock, ComparisonTable, type ComponentAssembly, type ComponentName, ComponentRenderer, type ComponentRendererProps, CtaStrip, DEFAULT_ACCENT, FeatureList, HeroStatement, ImageCtaHero, PersonalisedSection, type PersonalisedSectionProps, SP_ROOT, StatGrid, TestimonialCard, buildTokenCss, filterAssemblyByZone };
|