@spillway-cms/blocks 0.1.35 → 0.1.37

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/styles.css CHANGED
@@ -100,7 +100,8 @@
100
100
  .sw-container { padding-inline: var(--sw-space-3); }
101
101
  }
102
102
  .sw-container--narrow { max-width: min(var(--sw-max-width, 1120px), 720px); }
103
- .sw-container--wide { max-width: min(calc(var(--sw-max-width, 1120px) * 1.25), 1400px); }
103
+ /* --sw-wide-width (a theme's custom token "wide-width") sets the wide container; unset, it is a quarter wider than the content. */
104
+ .sw-container--wide { max-width: var(--sw-wide-width, min(calc(var(--sw-max-width, 1120px) * 1.25), 1400px)); }
104
105
 
105
106
  .sw-block { padding-block: var(--sw-block-pad, 1.5rem); }
106
107
  /* Two blocks on the page background share one gap instead of adding theirs up. */
@@ -176,6 +177,55 @@
176
177
  text-underline-offset: 0.15em;
177
178
  }
178
179
  .sw-button--link:hover { text-decoration-thickness: 2px; }
180
+ /* The emphasis values added with the block variants (the Buttons block; a Button takes them from its style). Accent: solid, in
181
+ the text color that reads on the accent (--sw-on-accent, which the theme writes when white does not). Dark: the dark neutral.
182
+ Hover underlines the label and keeps the fill: the accent's text color was chosen for that fill, and a darker one could
183
+ lose it. Light and light outline are for dark bands and images: a white button with dark text (with a soft edge, so it can
184
+ still be seen where someone puts it on a light background), a white outline with white text.
185
+ Focus keeps the page's ring (.sw-page .sw-button:focus-visible): none of these sets box-shadow or outline. */
186
+ .sw-button--accent {
187
+ background: var(--sw-color-accent, var(--sw-color-primary, #1d4ed8));
188
+ border-color: var(--sw-color-accent, var(--sw-color-primary, #1d4ed8));
189
+ color: var(--sw-on-accent, #ffffff);
190
+ }
191
+ .sw-button--accent:hover { text-decoration: underline; text-underline-offset: 0.15em; }
192
+ .sw-button--dark {
193
+ background: var(--sw-color-neutral-900, #111827);
194
+ border-color: var(--sw-color-neutral-900, #111827);
195
+ color: #ffffff;
196
+ }
197
+ .sw-button--dark:hover {
198
+ background: color-mix(in srgb, var(--sw-color-neutral-900, #111827) 80%, #ffffff);
199
+ border-color: color-mix(in srgb, var(--sw-color-neutral-900, #111827) 80%, #ffffff);
200
+ }
201
+ /* Two classes on these two, so a dark Section's "buttons take the band's text color" rule does not repaint them. */
202
+ .sw-button.sw-button--light {
203
+ background: #ffffff;
204
+ border-color: color-mix(in srgb, currentColor 30%, #ffffff);
205
+ color: var(--sw-color-neutral-900, #111827);
206
+ }
207
+ .sw-button.sw-button--light:hover { background: rgba(255, 255, 255, 0.9); border-color: rgba(255, 255, 255, 0.9); }
208
+ .sw-button.sw-button--outline-light {
209
+ background: transparent;
210
+ border-color: currentColor;
211
+ color: #ffffff;
212
+ }
213
+ .sw-button.sw-button--outline-light:hover { background: rgba(255, 255, 255, 0.16); }
214
+ /* Size and width (Button and Buttons). Four classes, so they hold whatever a Button style from Brand sets (three). Only the
215
+ padding above and below changes: a text link keeps its flush sides. */
216
+ .sw-button-block.sw-button-block--small .sw-actions .sw-button { font-size: 0.875rem; min-height: 2.25rem; padding-block: 0.45em; }
217
+ .sw-button-block.sw-button-block--large .sw-actions .sw-button { font-size: 1.125rem; min-height: 3.25rem; padding-block: 0.8em; }
218
+ .sw-button-block--full .sw-actions .sw-button { flex: 1 1 12rem; }
219
+ /* A grid of buttons: one column on phones, two from 640px, the block's columns from 900px. Every button fills its cell. */
220
+ .sw-buttons--grid .sw-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
221
+ .sw-buttons--grid .sw-actions .sw-button { text-align: center; }
222
+ @media (min-width: 640px) {
223
+ .sw-buttons--grid .sw-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
224
+ }
225
+ @media (min-width: 900px) {
226
+ .sw-buttons--cols-3 .sw-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
227
+ .sw-buttons--cols-4 .sw-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
228
+ }
179
229
 
180
230
  /* ---------- Hero ---------- */
181
231
 
@@ -270,9 +320,19 @@
270
320
  /* ---------- Text ---------- */
271
321
 
272
322
  /* Text lines up with the headings and cards around it; the measure is capped, and alignment moves the column. */
273
- .sw-text .sw-prose { max-width: 36em; }
323
+ /* The brand's Text width setting writes --sw-measure (wide, or none to fill the column); with tables on the full column the cap
324
+ moves from the box (--sw-measure-box: none) to its paragraphs, headings, lists and quotes, which leaves a table the column.
325
+ --sw-measure-len is registered as a length so an em resolves once, on the text's box, not again on a larger heading. */
326
+ @property --sw-measure-len { syntax: "<length> | none"; inherits: true; initial-value: none; }
327
+ .sw-text .sw-prose, .sw-richtext.sw-prose { --sw-measure-len: var(--sw-measure-child, none); }
328
+ .sw-text .sw-prose { max-width: var(--sw-measure-box, var(--sw-measure, 36em)); }
329
+ /* The rules that are new with the setting sit in :where(), so they add no specificity: a rule a site already had in its
330
+ custom CSS (.sw-prose blockquote { max-width: ... }) still wins, and with the setting off they change nothing. */
331
+ :where(.sw-text .sw-prose, .sw-richtext.sw-prose) > :where(p, h2, h3, h4, ul, ol, blockquote, pre, hr, figure) { max-width: var(--sw-measure-len); }
274
332
  .sw-text.sw-align-center .sw-prose { margin-inline: auto; }
275
333
  .sw-text.sw-align-right .sw-prose { margin-left: auto; }
334
+ :where(.sw-text.sw-align-center .sw-prose) > :where(p, h2, h3, h4, ul, ol, pre) { margin-inline: auto; }
335
+ :where(.sw-text.sw-align-right .sw-prose) > :where(p, h2, h3, h4, ul, ol, pre) { margin-left: auto; }
276
336
  .sw-text .sw-prose > * + * { margin-top: 1em; }
277
337
  .sw-text--lead .sw-prose { font-size: 1.25rem; line-height: 1.55; }
278
338
  .sw-prose h1, .sw-prose h2, .sw-prose h3, .sw-prose h4 { margin-top: 1.5em; }
@@ -312,6 +372,65 @@
312
372
  .sw-prose pre:focus-visible,
313
373
  .sw-prose table:focus-visible { outline: 2px solid var(--sw-color-primary); outline-offset: 2px; }
314
374
  .sw-prose th, .sw-prose td { padding: 0.5em 0.75em; border-bottom: 1px solid var(--sw-color-border); text-align: left; }
375
+ /* The header row's colors, for every table: a theme's custom tokens "table-head-bg" and "table-head-color" (set both, as a
376
+ pair that reads). Unset, a plain table's header is as it was. */
377
+ :where(.sw-prose) th { background: var(--sw-table-head-bg, transparent); color: var(--sw-table-head-color, inherit); }
378
+ /* Table styles: the fixed classes a table in rich text may carry (shared TABLE_STYLES), picked in the editor; one or several.
379
+ The shading is a tint of the text color, so it reads on the page background, the surface and a dark band alike. */
380
+ .sw-prose table:is(.sw-table-striped, .sw-table-bordered) th { background: var(--sw-table-head-bg, color-mix(in srgb, currentColor 10%, transparent)); }
381
+ .sw-prose table.sw-table-striped tbody tr:nth-child(even) { background: var(--sw-table-stripe, color-mix(in srgb, currentColor 5%, transparent)); }
382
+ .sw-prose table.sw-table-bordered :is(th, td) { border: 1px solid var(--sw-table-border, var(--sw-color-border)); }
383
+ .sw-prose table.sw-table-compact :is(th, td) { padding: 0.25em 0.5em; font-size: 0.9375em; }
384
+
385
+ /* Text styles: the fixed classes rich text may carry (shared TEXT_STYLES), offered in the editor as paragraph styles. Each reads a
386
+ variable a theme can set as a custom token (eyebrow-color is --sw-eyebrow-color), with a fallback that keeps its contrast on
387
+ light and dark backgrounds. */
388
+ .sw-text-eyebrow {
389
+ font-size: var(--sw-eyebrow-size, 0.8125em);
390
+ font-weight: var(--sw-eyebrow-weight, 700);
391
+ letter-spacing: var(--sw-eyebrow-tracking, 0.08em);
392
+ text-transform: var(--sw-eyebrow-transform, uppercase);
393
+ color: var(--sw-eyebrow-color, var(--sw-color-muted));
394
+ }
395
+ .sw-prose .sw-text-eyebrow + :is(h2, h3, h4) { margin-top: 0.2em; }
396
+ .sw-text-lead { font-size: var(--sw-lead-size, 1.25em); line-height: var(--sw-lead-leading, 1.55); }
397
+ .sw-text-small { font-size: var(--sw-small-size, 0.875em); color: var(--sw-small-color, var(--sw-color-muted)); }
398
+ .sw-text-highlight {
399
+ padding: 0.05em 0.2em;
400
+ border-radius: 0.2em;
401
+ background: var(--sw-highlight-bg, color-mix(in srgb, var(--sw-color-accent, var(--sw-color-primary, #1d4ed8)) 24%, transparent));
402
+ color: var(--sw-highlight-color, inherit);
403
+ -webkit-box-decoration-break: clone;
404
+ box-decoration-break: clone;
405
+ }
406
+ @media (forced-colors: active) {
407
+ .sw-text-highlight { background: Mark; color: MarkText; }
408
+ }
409
+
410
+ /* Text styles: the fixed classes rich text may carry (shared TEXT_STYLES), offered in the editor as paragraph styles. Each reads a
411
+ variable a theme can set as a custom token (eyebrow-color is --sw-eyebrow-color), with a fallback that keeps its contrast on
412
+ light and dark backgrounds. */
413
+ .sw-text-eyebrow {
414
+ font-size: var(--sw-eyebrow-size, 0.8125em);
415
+ font-weight: var(--sw-eyebrow-weight, 700);
416
+ letter-spacing: var(--sw-eyebrow-tracking, 0.08em);
417
+ text-transform: var(--sw-eyebrow-transform, uppercase);
418
+ color: var(--sw-eyebrow-color, var(--sw-color-muted));
419
+ }
420
+ .sw-prose .sw-text-eyebrow + :is(h2, h3, h4) { margin-top: 0.2em; }
421
+ .sw-text-lead { font-size: var(--sw-lead-size, 1.25em); line-height: var(--sw-lead-leading, 1.55); }
422
+ .sw-text-small { font-size: var(--sw-small-size, 0.875em); color: var(--sw-small-color, var(--sw-color-muted)); }
423
+ .sw-text-highlight {
424
+ padding: 0.05em 0.2em;
425
+ border-radius: 0.2em;
426
+ background: var(--sw-highlight-bg, color-mix(in srgb, var(--sw-color-accent, var(--sw-color-primary, #1d4ed8)) 24%, transparent));
427
+ color: var(--sw-highlight-color, inherit);
428
+ -webkit-box-decoration-break: clone;
429
+ box-decoration-break: clone;
430
+ }
431
+ @media (forced-colors: active) {
432
+ .sw-text-highlight { background: Mark; color: MarkText; }
433
+ }
315
434
 
316
435
  /* ---------- Image ---------- */
317
436
 
@@ -322,8 +441,16 @@
322
441
  height: auto;
323
442
  }
324
443
  .sw-image--rounded .sw-image__img { border-radius: var(--sw-radius, 8px); }
325
- .sw-image--size-small .sw-image__figure { max-width: 200px; }
326
- .sw-image--size-medium .sw-image__figure { max-width: 420px; }
444
+ /* Crop: a square, or a circle (a portrait), around the focal point. Size caps the figure inside its container: a theme's custom
445
+ tokens "image-small" and "image-medium" set the two widths. */
446
+ .sw-image--crop-square .sw-image__img, .sw-image--crop-round .sw-image__img { aspect-ratio: 1 / 1; object-fit: cover; }
447
+ .sw-image.sw-image--crop-round .sw-image__img { border-radius: 50%; }
448
+ .sw-image--size-small .sw-image__figure { max-width: var(--sw-image-small, 200px); }
449
+ .sw-image--size-medium .sw-image__figure { max-width: var(--sw-image-medium, 420px); }
450
+ .sw-image--full:is(.sw-image--size-small, .sw-image--size-medium) .sw-image__figure { margin-inline: var(--sw-space-2); }
451
+ .sw-image--align-center .sw-image__figure { margin-inline: auto; }
452
+ .sw-image--align-center .sw-image__caption { text-align: center; }
453
+ .sw-image--align-right .sw-image__figure { margin-left: auto; }
327
454
  .sw-image__placeholder {
328
455
  aspect-ratio: 16 / 9;
329
456
  background: repeating-linear-gradient(45deg, var(--sw-color-surface) 0 12px, var(--sw-color-border) 12px 14px);
@@ -373,10 +500,36 @@
373
500
  .sw-section__body > .sw-block { padding-block: 0; }
374
501
  .sw-section__body > .sw-block + .sw-block { padding-top: var(--sw-space-3); }
375
502
  .sw-section__body .sw-container { max-width: none; padding-inline: 0; }
376
- .sw-block.sw-section--filled { padding-block: var(--sw-space-4); }
503
+ /* A band's own padding: --sw-section-pad (a theme's custom token "section-pad") replaces the automatic amount on every band. */
504
+ .sw-block.sw-section--filled { padding-block: var(--sw-section-pad, var(--sw-space-4)); }
377
505
  @media (min-width: 640px) {
378
- .sw-block.sw-section--filled { padding-block: var(--sw-space-5); }
506
+ .sw-block.sw-section--filled { padding-block: var(--sw-section-pad, var(--sw-space-5)); }
507
+ }
508
+ /* Shape: a band held inside the content width (inset), with the brand's radius (rounded) and its shadow too (shadow). The band
509
+ is as wide as its container would be, less the page's gutter, and keeps a band's padding even on the page background. */
510
+ .sw-block:is(.sw-section--shape-inset, .sw-section--shape-rounded, .sw-section--shape-shadow) {
511
+ width: calc(100% - 2 * var(--sw-space-2));
512
+ max-width: calc(var(--sw-max-width, 1120px) - 2 * var(--sw-space-3));
513
+ margin-inline: auto;
514
+ padding-block: var(--sw-section-pad, var(--sw-space-4));
379
515
  }
516
+ .sw-block:is(.sw-section--shape-inset, .sw-section--shape-rounded, .sw-section--shape-shadow).sw-section--w-narrow { max-width: calc(min(var(--sw-max-width, 1120px), 720px) - 2 * var(--sw-space-3)); }
517
+ .sw-block:is(.sw-section--shape-inset, .sw-section--shape-rounded, .sw-section--shape-shadow).sw-section--w-wide { max-width: calc(var(--sw-wide-width, min(calc(var(--sw-max-width, 1120px) * 1.25), 1400px)) - 2 * var(--sw-space-3)); }
518
+ @media (min-width: 640px) {
519
+ .sw-block:is(.sw-section--shape-inset, .sw-section--shape-rounded, .sw-section--shape-shadow) { width: calc(100% - 2 * var(--sw-space-3)); padding-block: var(--sw-section-pad, var(--sw-space-5)); }
520
+ }
521
+ .sw-section--shape-rounded, .sw-section--shape-shadow { border-radius: var(--sw-radius, 8px); }
522
+ .sw-section--shape-shadow { box-shadow: var(--sw-shadow, 0 1px 2px rgba(0, 0, 0, 0.08), 0 12px 28px -12px rgba(0, 0, 0, 0.3)); }
523
+ /* An inset band does not touch the block above or below it. */
524
+ .sw-block + .sw-block:is(.sw-section--shape-inset, .sw-section--shape-rounded, .sw-section--shape-shadow) { margin-top: var(--sw-block-pad, 1.5rem); }
525
+ :is(.sw-section--shape-inset, .sw-section--shape-rounded, .sw-section--shape-shadow) + .sw-block { padding-top: var(--sw-block-pad, 1.5rem); }
526
+ /* Padding: the band's own space above and below its blocks, in steps a theme can set ("section-pad-s" to "section-pad-xl").
527
+ Three classes, so a step holds on an inset band too; Space above and Space below still win over either side. */
528
+ .sw-block.sw-section.sw-section--pad-none { padding-block: 0; }
529
+ .sw-block.sw-section.sw-section--pad-s { padding-block: var(--sw-section-pad-s, var(--sw-space-2)); }
530
+ .sw-block.sw-section.sw-section--pad-m { padding-block: var(--sw-section-pad-m, var(--sw-space-4)); }
531
+ .sw-block.sw-section.sw-section--pad-l { padding-block: var(--sw-section-pad-l, var(--sw-space-5)); }
532
+ .sw-block.sw-section.sw-section--pad-xl { padding-block: var(--sw-section-pad-xl, var(--sw-space-6)); }
380
533
  .sw-section--filled + .sw-block { padding-top: var(--sw-block-pad, 1.5rem); }
381
534
  .sw-section--bg-surface { background: var(--sw-color-surface); }
382
535
  .sw-section--bg-primary { background: var(--sw-color-primary, #1d4ed8); }
@@ -480,6 +633,9 @@
480
633
  aspect-ratio: 16 / 9;
481
634
  object-fit: cover;
482
635
  }
636
+ /* Images: "Show the whole image" fits each picture inside the frame (a logo, a diagram) on the surface color. Four classes, so it
637
+ holds under any Cards style. */
638
+ .sw-block.sw-cards.sw-cards--fit-contain .sw-card .sw-card__image { object-fit: contain; object-position: center; background: var(--sw-color-surface); }
483
639
  .sw-card__body {
484
640
  flex: 1;
485
641
  display: flex;
package/dist/styles.d.ts CHANGED
@@ -13,6 +13,13 @@ import { type BlockStyle, type BlockStyleSlot, type StyledCoreBlock } from '@spi
13
13
  export declare const blockStyleSlots: Record<StyledCoreBlock, BlockStyleSlot[]>;
14
14
  /** The styles every site starts with: they can be edited and reset in Brand → Styles, never deleted. */
15
15
  export declare const builtInBlockStyles: BlockStyle[];
16
+ /**
17
+ * Blocks that got styles after pages already held them (Stats, Testimonials, Menu): their built-in default style writes no class,
18
+ * so a block saved before its styles existed renders the bytes it always did. Every other style of these blocks writes the usual
19
+ * `sw-style-<block>-<key>`; the CSS of the built-in default (which a site may edit in Brand → Styles) selects the block without
20
+ * any style class instead (see blockStyleCss), and is empty while the default keeps its shipped slot values.
21
+ */
22
+ export declare const CLASSLESS_DEFAULT_BLOCKS: readonly StyledCoreBlock[];
16
23
  /** The built-in default style key of each styled core block (renders fall back to it when nothing resolved a style). */
17
24
  export declare const builtInDefaultStyle: Record<StyledCoreBlock, string>;
18
25
  /** The class a rendered block carries for its style; an empty or malformed key falls back to the built-in default. */
@@ -24,6 +31,11 @@ export declare const BLOCK_STYLE_SAMPLE_IMAGE: string;
24
31
  * Style field and the style guide (Brand → Style guide, /brand) all render the blocks with these.
25
32
  */
26
33
  export declare const blockStyleSampleProps: Record<StyledCoreBlock, Record<string, unknown>>;
34
+ /**
35
+ * The text color that reads on each brand background: the theme writes `--sw-on-<color>` when white would not (core theme/css.ts
36
+ * readableOn), so a pale accent gets dark text; without it white, the choice for the dark brand colors blocks have always assumed.
37
+ */
38
+ export declare const ON_COLOR: Record<string, string>;
27
39
  /**
28
40
  * The CSS of one core block style, or '' when the block has no slots or the key is not a valid style key. A slot value outside
29
41
  * the block's list takes the slot's default, so stored data can never put anything but these declarations on the page.
package/dist/styles.js CHANGED
@@ -21,15 +21,27 @@ export const blockStyleSlots = {
21
21
  Cards: [
22
22
  { key: 'border', label: 'Border', options: [opt('outline', 'Outline'), opt('none', 'None')], default: 'outline' },
23
23
  { key: 'fill', label: 'Fill', options: [opt('none', 'Page background'), opt('neutral-50', 'Light neutral'), opt('primary-50', 'Light primary')], default: 'none' },
24
- { key: 'image', label: 'Image', options: [opt('top', 'Top'), opt('left', 'Left')], default: 'top', help: 'Left places the image beside the text on wide screens.' },
24
+ { key: 'image', label: 'Image', options: [opt('top', 'Top'), opt('left', 'Left'), opt('overlay', 'Behind the text')], default: 'top', help: 'Left places the image beside the text on wide screens. Behind the text lays the title and text over the image, in white on a dark gradient.' },
25
+ ],
26
+ Button: [
27
+ {
28
+ key: 'emphasis',
29
+ label: 'Emphasis',
30
+ options: [opt('primary', 'Primary'), opt('secondary', 'Secondary'), opt('text', 'Text link'), opt('accent', 'Accent'), opt('dark', 'Dark'), opt('light', 'Light (on a dark band)'), opt('outline-light', 'Light outline (on a dark band)')],
31
+ default: 'primary',
32
+ help: 'Accent and Dark are solid buttons. Light and Light outline are only for dark bands and images: on a light background a white outline with white text cannot be seen.',
33
+ },
25
34
  ],
26
- Button: [{ key: 'emphasis', label: 'Emphasis', options: [opt('primary', 'Primary'), opt('secondary', 'Secondary'), opt('text', 'Text link')], default: 'primary' }],
27
35
  CallToAction: [
28
36
  { key: 'background', label: 'Background', options: [...BRAND_BACKGROUNDS, opt('surface', 'Surface'), opt('none', 'Page background')], default: 'primary' },
29
37
  { key: 'shape', label: 'Shape', options: [opt('band', 'Full-width band'), opt('card', 'Card')], default: 'band' },
30
38
  { key: 'alignment', label: 'Alignment', options: [opt('center', 'Center'), opt('left', 'Left')], default: 'center' },
31
39
  ],
32
- Heading: [{ key: 'tone', label: 'Tone', options: [opt('default', 'Default'), opt('muted', 'Muted'), opt('accent', 'Accent')], default: 'default' }],
40
+ Heading: [
41
+ { key: 'tone', label: 'Tone', options: [opt('default', 'Default'), opt('muted', 'Muted'), opt('accent', 'Accent')], default: 'default' },
42
+ { key: 'background', label: 'Title box', options: [opt('none', 'None'), opt('surface', 'Surface'), ...BRAND_BACKGROUNDS], default: 'none', help: 'Puts the heading on a band of this color across the content. On a brand color the text takes the color that reads on it, whatever the tone.' },
43
+ { key: 'rule', label: 'Line', options: [opt('none', 'None'), opt('below', 'Accent line below')], default: 'none' },
44
+ ],
33
45
  Text: [{ key: 'tone', label: 'Tone', options: [opt('default', 'Default'), opt('muted', 'Muted'), opt('accent', 'Accent')], default: 'default' }],
34
46
  Accordion: [
35
47
  { key: 'look', label: 'Items', options: [opt('lines', 'Divided by lines'), opt('boxed', 'Boxed')], default: 'lines', help: 'Boxed puts each item in a bordered box on the surface color.' },
@@ -40,6 +52,15 @@ export const blockStyleSlots = {
40
52
  { key: 'frame', label: 'Slides', options: [opt('none', 'No frame'), opt('card', 'Card')], default: 'none', help: 'Card puts each slide in a bordered box on the surface color (not on the hero variant).' },
41
53
  { key: 'controls', label: 'Buttons', options: [opt('solid', 'Solid'), opt('outline', 'Outline')], default: 'solid' },
42
54
  ],
55
+ Stats: [
56
+ { key: 'frame', label: 'Numbers', options: [opt('none', 'Plain'), opt('cards', 'Each in a card'), opt('band', 'On one band')], default: 'none', help: 'A card frames each number; a band puts them all on one background.' },
57
+ { key: 'background', label: 'Background (cards and band)', options: [opt('surface', 'Surface'), ...BRAND_BACKGROUNDS], default: 'surface', help: 'On a brand color the numbers and labels take the color that reads on it.' },
58
+ ],
59
+ Testimonials: [
60
+ { key: 'frame', label: 'Quotes', options: [opt('card', 'Card'), opt('filled', 'Filled card'), opt('none', 'No frame')], default: 'card', help: 'Filled card: no border, on the surface color.' },
61
+ { key: 'quote', label: 'Quote text', options: [opt('normal', 'Normal'), opt('large', 'Large, with an accent mark')], default: 'normal' },
62
+ ],
63
+ Menu: [{ key: 'look', label: 'Links', options: [opt('list', 'List'), opt('pills', 'Pills'), opt('underline', 'Underlined')], default: 'list', help: 'Pills outline every link and fill the current page’s; Underlined marks the current page with a line in the primary color.' }],
43
64
  };
44
65
  const style = (block, key, label, description, tokens, isDefault = false) => ({
45
66
  block,
@@ -56,15 +77,22 @@ export const builtInBlockStyles = [
56
77
  style('Hero', 'split', 'Split', 'Text on the surface color beside the image.', { background: 'surface', text: 'auto', layout: 'split' }),
57
78
  style('Cards', 'outlined', 'Outlined', 'Cards with a thin border on the page background.', { border: 'outline', fill: 'none', image: 'top' }, true),
58
79
  style('Cards', 'filled', 'Filled', 'Borderless cards on a light neutral fill.', { border: 'none', fill: 'neutral-50', image: 'top' }),
80
+ style('Cards', 'overlay', 'Overlay', 'The title and text over the image, in white on a dark gradient.', { border: 'none', fill: 'none', image: 'overlay' }),
59
81
  style('Button', 'primary', 'Primary', 'A solid button in the primary color: the main action.', { emphasis: 'primary' }, true),
60
82
  style('Button', 'secondary', 'Secondary', 'An outlined button for a second action.', { emphasis: 'secondary' }),
61
83
  style('Button', 'text-link', 'Text link', 'An underlined link with no button shape.', { emphasis: 'text' }),
84
+ style('Button', 'accent', 'Accent', 'A solid button in the accent color, in the text color that reads on it.', { emphasis: 'accent' }),
85
+ style('Button', 'dark', 'Dark', 'A solid button in the dark neutral color.', { emphasis: 'dark' }),
86
+ style('Button', 'light', 'Light (on a dark band)', 'A white button with dark text, for a dark band or an image.', { emphasis: 'light' }),
87
+ style('Button', 'light-outline', 'Light outline (on a dark band)', 'A white outline and white text, for a dark band or an image only: it cannot be seen on a light background.', { emphasis: 'outline-light' }),
62
88
  style('CallToAction', 'band', 'Band', 'A full-width band in the primary color with light text.', { background: 'primary', shape: 'band', alignment: 'center' }, true),
63
89
  style('CallToAction', 'card', 'Card', 'A bordered card on the surface color.', { background: 'surface', shape: 'card', alignment: 'center' }),
64
90
  style('CallToAction', 'dark-band', 'Dark band', 'A full-width dark neutral band with light text.', { background: 'neutral-900', shape: 'band', alignment: 'center' }),
65
91
  style('Heading', 'default', 'Default', 'The body text color.', { tone: 'default' }, true),
66
92
  style('Heading', 'accent', 'Accent', 'The accent color (the primary color when there is no accent).', { tone: 'accent' }),
67
93
  style('Heading', 'muted', 'Muted', 'A quieter heading in the muted text color.', { tone: 'muted' }),
94
+ style('Heading', 'title-box', 'Title box', 'The heading on a band in the primary color across the content, in the text color that reads on it.', { tone: 'default', background: 'primary', rule: 'none' }),
95
+ style('Heading', 'underlined', 'Underlined', 'A short accent line under the heading.', { tone: 'default', background: 'none', rule: 'below' }),
68
96
  style('Text', 'default', 'Default', 'The body text color.', { tone: 'default' }, true),
69
97
  style('Text', 'muted', 'Muted', 'The muted text color, for secondary copy.', { tone: 'muted' }),
70
98
  style('Text', 'accent', 'Accent', 'The accent color, for a short highlighted passage.', { tone: 'accent' }),
@@ -74,12 +102,33 @@ export const builtInBlockStyles = [
74
102
  style('Tabs', 'pills', 'Pills', 'Rounded tabs; the selected one filled with the primary color.', { look: 'pills' }),
75
103
  style('Carousel', 'plain', 'Plain', 'Slides without a frame and solid buttons in the primary color.', { frame: 'none', controls: 'solid' }, true),
76
104
  style('Carousel', 'framed', 'Framed', 'Each slide in a card on the surface color and outlined buttons.', { frame: 'card', controls: 'outline' }),
105
+ style('Stats', 'plain', 'Plain', 'The numbers in the primary color on the page background.', { frame: 'none', background: 'surface' }, true),
106
+ style('Stats', 'cards', 'Cards', 'Each number in a bordered card on the surface color.', { frame: 'cards', background: 'surface' }),
107
+ style('Stats', 'band', 'Band', 'All the numbers on one band in the primary color, in the text color that reads on it.', { frame: 'band', background: 'primary' }),
108
+ style('Testimonials', 'cards', 'Cards', 'Each quote in a bordered card.', { frame: 'card', quote: 'normal' }, true),
109
+ style('Testimonials', 'plain', 'Plain', 'Quotes without a frame.', { frame: 'none', quote: 'normal' }),
110
+ style('Testimonials', 'large-quote', 'Large quote', 'Larger quote text under an accent quotation mark, without a frame.', { frame: 'none', quote: 'large' }),
111
+ style('Menu', 'list', 'List', 'Plain links; the current page in the primary color on a tint.', { look: 'list' }, true),
112
+ style('Menu', 'pills', 'Pills', 'Every link in a rounded outline; the current page filled with the primary color.', { look: 'pills' }),
113
+ style('Menu', 'underlined', 'Underlined', 'The current page marked with a line in the primary color.', { look: 'underline' }),
77
114
  ];
115
+ /**
116
+ * Blocks that got styles after pages already held them (Stats, Testimonials, Menu): their built-in default style writes no class,
117
+ * so a block saved before its styles existed renders the bytes it always did. Every other style of these blocks writes the usual
118
+ * `sw-style-<block>-<key>`; the CSS of the built-in default (which a site may edit in Brand → Styles) selects the block without
119
+ * any style class instead (see blockStyleCss), and is empty while the default keeps its shipped slot values.
120
+ */
121
+ export const CLASSLESS_DEFAULT_BLOCKS = ['Stats', 'Testimonials', 'Menu'];
122
+ /** The block's own class, which the classless default style's CSS selects. */
123
+ const BLOCK_ROOT_CLASS = { Stats: 'sw-stats', Testimonials: 'sw-testimonials', Menu: 'sw-menu-block' };
78
124
  /** The built-in default style key of each styled core block (renders fall back to it when nothing resolved a style). */
79
125
  export const builtInDefaultStyle = Object.fromEntries(builtInBlockStyles.filter((s) => s.isDefault).map((s) => [s.block, s.key]));
80
126
  /** The class a rendered block carries for its style; an empty or malformed key falls back to the built-in default. */
81
127
  export function styleClassFor(block, key) {
82
128
  const k = typeof key === 'string' && BLOCK_STYLE_KEY_RE.test(key) ? key : builtInDefaultStyle[block];
129
+ // Stats, Testimonials and Menu: no class for the built-in default (and so for an empty or malformed key).
130
+ if (CLASSLESS_DEFAULT_BLOCKS.includes(block) && k === builtInDefaultStyle[block])
131
+ return '';
83
132
  return blockStyleClass(block, k);
84
133
  }
85
134
  // ---------- sample props ----------
@@ -136,6 +185,18 @@ export const blockStyleSampleProps = {
136
185
  { label: 'Third', thumbnail: '', content: [sampleText('A third slide.')] },
137
186
  ],
138
187
  },
188
+ Stats: { title: '', align: 'center', items: [{ value: '94%', label: 'employed in six months' }, { value: '40', label: 'majors' }, { value: '14:1', label: 'students to faculty' }] },
189
+ Testimonials: { title: '', columns: 2, items: [{ quote: 'It changed how we work.', name: 'Ada Reyes', role: 'Director', imageUrl: '' }, { quote: 'We were up and running in a week.', name: 'Sam Okafor', role: 'Editor', imageUrl: '' }] },
190
+ Menu: {
191
+ source: 'menu',
192
+ menuKey: 'main',
193
+ show: 'all',
194
+ depth: 1,
195
+ heading: '',
196
+ layout: 'horizontal',
197
+ menuLabel: 'Sample menu',
198
+ items: [{ label: 'Overview', href: '#', current: true }, { label: 'Programs', href: '#' }, { label: 'Admissions', href: '#' }],
199
+ },
139
200
  };
140
201
  // ---------- tokens ----------
141
202
  const PRIMARY = 'var(--sw-color-primary, #1d4ed8)';
@@ -157,6 +218,10 @@ const BRAND = new Set(['primary', 'secondary', 'accent']);
157
218
  const DARK = new Set(['primary', 'secondary', 'accent', 'neutral-900']);
158
219
  // 0.92, not lower: muted text on the primary color has to keep 4.5:1 on a mid-blue such as #2B59FF.
159
220
  const LIGHT_MUTED = 'rgba(255, 255, 255, 0.92)';
221
+ /** A surface-colored box inside a dark Section (white text): a tint of white with a light hairline, the look Cards take there. */
222
+ const ON_DARK_BOX = 'background:rgba(255, 255, 255, 0.08);border-color:rgba(255, 255, 255, 0.28)';
223
+ /** The text of a white button: the dark neutral, 17:1 on white whatever the brand colors are. */
224
+ const LIGHT_BUTTON_INK = 'var(--sw-color-neutral-900, #111827)';
160
225
  const css = (rules) => rules.map(([sel, decl, media]) => (media ? `@media ${media}{${sel}{${decl}}}` : `${sel}{${decl}}`)).join('');
161
226
  const WIDE = '(min-width: 900px)';
162
227
  const NARROW = '(max-width: 899.98px)';
@@ -206,6 +271,12 @@ function cardsRules(s, t) {
206
271
  ];
207
272
  if (t.image === 'left')
208
273
  rules.push([`${s} .sw-card`, 'flex-direction:row', MEDIUM], [`${s} .sw-card__image`, 'width:40%;flex:none;aspect-ratio:auto;align-self:stretch', MEDIUM]);
274
+ if (t.image === 'overlay') {
275
+ // The label over the image: the picture fills the card and the title and text sit at its foot, white on a dark gradient
276
+ // (at least 82% of the dark neutral behind every line, so white text keeps well over 4.5:1 on any picture). A card without
277
+ // an image is the dark neutral itself, so its white text reads too; the fill and border slots do not apply.
278
+ rules.push([`${s} .sw-card`, `position:relative;justify-content:flex-end;min-height:16rem;border-color:transparent;background:${COLOR['neutral-900']};color:#ffffff;--sw-color-text:#ffffff;--sw-color-muted:${LIGHT_MUTED}`], [`${s} .sw-card__image`, 'position:absolute;inset:0;width:100%;height:100%;aspect-ratio:auto'], [`${s} .sw-card__body`, 'position:relative;flex:none;padding-top:3.5rem;background:linear-gradient(180deg, rgba(17, 24, 39, 0) 0, rgba(17, 24, 39, 0.82) 3rem, rgba(17, 24, 39, 0.9) 100%)'], [`${s} .sw-card .sw-card__text,${s} .sw-card .sw-card__more,${s} .sw-card .sw-card__icon`, 'color:inherit'], [`${s} .sw-card--link:hover`, 'border-color:#ffffff']);
279
+ }
209
280
  return rules;
210
281
  }
211
282
  function buttonRules(s, t) {
@@ -222,11 +293,97 @@ function buttonRules(s, t) {
222
293
  [`${b}:hover`, 'background:transparent;border-color:transparent;text-decoration-thickness:2px'],
223
294
  ];
224
295
  }
296
+ // The solid and light looks added with the block variants. Each writes the properties the three older looks write, so a style
297
+ // fully replaces another; the text color is the one that reads on the fill (ON_COLOR for the accent).
298
+ const solid = (fill, ink, hover) => [
299
+ [b, `background:${fill};border-color:${fill};color:${ink};padding:0.65em 1.35em;text-decoration:none`],
300
+ [`${b}:hover`, `background:${hover};border-color:${hover}`],
301
+ ];
302
+ // The accent keeps its fill on hover and underlines the label: its text color was chosen for that fill.
303
+ if (t.emphasis === 'accent')
304
+ return [[b, `background:${COLOR.accent};border-color:${COLOR.accent};color:${ON_COLOR.accent};padding:0.65em 1.35em;text-decoration:none`], [`${b}:hover`, `background:${COLOR.accent};border-color:${COLOR.accent};text-decoration:underline;text-underline-offset:0.15em`]];
305
+ if (t.emphasis === 'dark')
306
+ return solid(COLOR['neutral-900'], '#ffffff', `color-mix(in srgb, ${COLOR['neutral-900']} 80%, #ffffff)`);
307
+ // The two light looks are for dark bands. `--sw-preview-backdrop` is read only by the previews of a style (Brand → Styles, the
308
+ // page builder's Style field, the style guide), which show these on the dark neutral; a page never reads it.
309
+ const backdrop = [s, `--sw-preview-backdrop:${COLOR['neutral-900']}`];
310
+ // A soft edge in the text's color, so a light button can still be seen where someone puts it on a light background.
311
+ if (t.emphasis === 'light')
312
+ return [[b, `background:#ffffff;border-color:color-mix(in srgb, currentColor 30%, #ffffff);color:${LIGHT_BUTTON_INK};padding:0.65em 1.35em;text-decoration:none`], [`${b}:hover`, 'background:rgba(255, 255, 255, 0.9);border-color:color-mix(in srgb, currentColor 30%, #ffffff)'], backdrop];
313
+ if (t.emphasis === 'outline-light') {
314
+ return [
315
+ [b, 'background:transparent;border-color:currentColor;color:#ffffff;padding:0.65em 1.35em;text-decoration:none'],
316
+ [`${b}:hover`, 'background:rgba(255, 255, 255, 0.16);border-color:currentColor'],
317
+ backdrop,
318
+ ];
319
+ }
225
320
  return [
226
321
  [b, `background:${PRIMARY};border-color:${PRIMARY};color:${CONTRAST};padding:0.65em 1.35em;text-decoration:none`],
227
322
  [`${b}:hover`, `background:${DARKER};border-color:${DARKER}`],
228
323
  ];
229
324
  }
325
+ /**
326
+ * Stats: plain numbers, each number in a card, or all of them on one band. On a brand color or the dark neutral the numbers, the
327
+ * labels and the icons take the color that reads on it (ON_COLOR), not the primary color. Nothing at the shipped default.
328
+ */
329
+ function statsRules(s, t) {
330
+ if (t.frame === 'none')
331
+ return [];
332
+ const bg = t.background;
333
+ const ink = ON_COLOR[bg];
334
+ const fill = `background:${COLOR[bg]}`;
335
+ const onFill = ink ? `;color:${ink};--sw-color-text:${ink};--sw-color-muted:${ink}` : '';
336
+ const box = t.frame === 'cards' ? `${s} .sw-stat` : `${s} .sw-stats__grid`;
337
+ const rules = [
338
+ [box, `${fill}${onFill};border:1px solid ${ink ? 'transparent' : 'var(--sw-color-border)'};border-radius:var(--sw-radius, 8px);padding:var(--sw-space-3)`],
339
+ ...(t.frame === 'band' ? [[`${s} .sw-stats__grid`, 'gap:var(--sw-space-3) var(--sw-space-4)']] : []),
340
+ ];
341
+ if (ink)
342
+ rules.push([`${s} .sw-stat__value,${s} .sw-stat__icon,${s} .sw-stat__label`, 'color:inherit']);
343
+ // The surface color stays light inside a dark Section, where the text is white: there the box is a tint of white, as Cards are.
344
+ else
345
+ rules.push([`.sw-section--on-dark ${box}`, ON_DARK_BOX]);
346
+ return rules;
347
+ }
348
+ /** Testimonials: a bordered card (the shipped look), a filled card or no frame; normal quotes, or large ones under an accent mark. */
349
+ function testimonialsRules(s, t) {
350
+ const rules = [];
351
+ const fig = `${s} .sw-testimonial figure`;
352
+ if (t.frame === 'filled')
353
+ rules.push([fig, `border-color:transparent;background:${SURFACE}`], [`.sw-section--on-dark ${fig}`, ON_DARK_BOX]);
354
+ else if (t.frame === 'none')
355
+ rules.push([fig, 'border-color:transparent;background:transparent;padding:0']);
356
+ if (t.quote === 'large') {
357
+ rules.push([`${s} .sw-testimonial__quote`, 'font-size:clamp(1.25rem, 2.2vw, 1.5rem);line-height:1.4'],
358
+ // The mark is decoration: the quotation marks around the text stay, so the quote reads the same without CSS.
359
+ [`${s} .sw-testimonial__quote::before`, `content:"\\201C";display:block;height:0.55em;font-size:3.5em;line-height:1;font-weight:700;color:var(--sw-color-accent, ${PRIMARY})`]);
360
+ }
361
+ return rules;
362
+ }
363
+ /** Menu: plain links (the shipped look), outlined pills with the current page filled, or the current page under a line. */
364
+ function menuRules(s, t) {
365
+ const link = `${s} .sw-menu-block__item > a`;
366
+ const current = `${s} .sw-menu-block__item.is-current > a`;
367
+ if (t.look === 'pills') {
368
+ return [
369
+ [`${s} .sw-menu-block__list`, 'display:flex;flex-direction:column;gap:0.4rem'],
370
+ [`${s}.sw-menu-block--horizontal .sw-menu-block__list`, 'flex-direction:row;flex-wrap:wrap;gap:0.5rem'],
371
+ [link, 'border:1px solid var(--sw-color-border);border-radius:999px;padding:0.4rem 0.95rem'],
372
+ // The text of the filled pill is the color that reads on the primary color (white unless the theme wrote another).
373
+ [current, `background:${PRIMARY};border-color:${PRIMARY};color:${ON_COLOR.primary}`],
374
+ ];
375
+ }
376
+ if (t.look === 'underline') {
377
+ return [
378
+ [link, 'border-radius:0;border-inline-start:3px solid transparent;border-bottom:0'],
379
+ [current, `background:transparent;border-inline-start-color:${PRIMARY}`],
380
+ [`${s}.sw-menu-block--horizontal .sw-menu-block__item > a`, 'border-inline-start:0;border-bottom:3px solid transparent;padding-inline:0.2rem'],
381
+ [`${s}.sw-menu-block--horizontal .sw-menu-block__item.is-current > a`, `border-bottom-color:${PRIMARY}`],
382
+ [`${s}.sw-menu-block--horizontal .sw-menu-block__list`, 'gap:0.25rem 1.25rem'],
383
+ ];
384
+ }
385
+ return [];
386
+ }
230
387
  function ctaRules(s, t) {
231
388
  const bg = t.background;
232
389
  const card = t.shape === 'card';
@@ -277,6 +434,31 @@ function carouselRules(s, t) {
277
434
  [s, outline ? `--sw-carousel-fill:${PAGE_BG};--sw-carousel-ink:${PRIMARY};--sw-carousel-edge:currentColor` : `--sw-carousel-fill:${PRIMARY};--sw-carousel-ink:${CONTRAST};--sw-carousel-edge:${PRIMARY}`],
278
435
  ];
279
436
  }
437
+ /**
438
+ * The text color that reads on each brand background: the theme writes `--sw-on-<color>` when white would not (core theme/css.ts
439
+ * readableOn), so a pale accent gets dark text; without it white, the choice for the dark brand colors blocks have always assumed.
440
+ */
441
+ export const ON_COLOR = {
442
+ primary: `var(--sw-on-primary, ${CONTRAST})`,
443
+ secondary: 'var(--sw-on-secondary, #ffffff)',
444
+ accent: 'var(--sw-on-accent, #ffffff)',
445
+ 'neutral-900': '#ffffff',
446
+ };
447
+ /**
448
+ * A heading's tone, its title box (a band behind the heading, with the text color that reads on it) and the accent line under
449
+ * it. A style without a box or a line writes only the tone, as Heading styles always did: a block carries one style class, so
450
+ * nothing needs resetting, and a site's own rule for a heading's background or padding keeps applying.
451
+ */
452
+ function headingRules(s, t) {
453
+ const bg = t.background;
454
+ const boxed = bg !== 'none';
455
+ const text = `${s} .sw-heading__text`;
456
+ const rules = [[text, boxed ? `color:${ON_COLOR[bg] ?? TONE[t.tone]};background:${COLOR[bg]};padding:0.5em 0.75em;border-radius:var(--sw-radius, 8px)` : `color:${TONE[t.tone]}`]];
457
+ if (t.rule === 'below') {
458
+ rules.push([`${text}::after`, `content:"";display:block;width:3rem;height:0.2rem;margin-top:0.4em;border-radius:999px;background:${boxed ? 'currentColor' : `var(--sw-color-accent, ${PRIMARY})`}`], [`${s}.sw-align-center .sw-heading__text::after`, 'margin-inline:auto'], [`${s}.sw-align-right .sw-heading__text::after`, 'margin-left:auto']);
459
+ }
460
+ return rules;
461
+ }
280
462
  const TONE = { default: 'inherit', muted: 'var(--sw-color-muted)', accent: `var(--sw-color-accent, ${PRIMARY})` };
281
463
  /**
282
464
  * The CSS of one core block style, or '' when the block has no slots or the key is not a valid style key. A slot value outside
@@ -287,7 +469,14 @@ export function blockStyleCss(s) {
287
469
  if (!slots || !BLOCK_STYLE_KEY_RE.test(s.key))
288
470
  return '';
289
471
  const t = fillStyleTokens(slots, s.tokens);
290
- const sel = `:is(.sw-block, .sw-module-block).${blockStyleClass(s.block, s.key)}`;
472
+ // The built-in default of Stats, Testimonials and Menu has no class on the page: its CSS selects the block that carries no
473
+ // style class at all. `root` is a literal from BLOCK_ROOT_CLASS, never stored text.
474
+ const root = BLOCK_ROOT_CLASS[s.block];
475
+ const classless = root && CLASSLESS_DEFAULT_BLOCKS.includes(s.block) && s.key === builtInDefaultStyle[s.block];
476
+ // (A module block that uses the set always carries the class, so the selector takes that too.)
477
+ const sel = classless
478
+ ? `:is(.sw-block, .sw-module-block):is(.${root}:not([class*="${blockStyleClass(s.block, '')}"]), .${blockStyleClass(s.block, s.key)})`
479
+ : `:is(.sw-block, .sw-module-block).${blockStyleClass(s.block, s.key)}`;
291
480
  let rules;
292
481
  switch (s.block) {
293
482
  case 'Hero':
@@ -303,7 +492,7 @@ export function blockStyleCss(s) {
303
492
  rules = ctaRules(sel, t);
304
493
  break;
305
494
  case 'Heading':
306
- rules = [[`${sel} .sw-heading__text`, `color:${TONE[t.tone]}`]];
495
+ rules = headingRules(sel, t);
307
496
  break;
308
497
  case 'Text':
309
498
  rules = [[`${sel} .sw-prose`, `color:${TONE[t.tone]}`]];
@@ -317,6 +506,15 @@ export function blockStyleCss(s) {
317
506
  case 'Carousel':
318
507
  rules = carouselRules(sel, t);
319
508
  break;
509
+ case 'Stats':
510
+ rules = statsRules(sel, t);
511
+ break;
512
+ case 'Testimonials':
513
+ rules = testimonialsRules(sel, t);
514
+ break;
515
+ case 'Menu':
516
+ rules = menuRules(sel, t);
517
+ break;
320
518
  default:
321
519
  rules = [];
322
520
  }