maverick-wave-astro 1.47.0 → 1.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -159,13 +159,16 @@ build - it knows the formats `date`, `email`, `uri` and the keywords `x-widget`,
159
159
  `x-newest-first`, `x-translate`, `x-show-if` (the werkbank shows a field only
160
160
  while a neighbour has one of the given values), `x-width` (`narrow` |
161
161
  `medium` | `wide`: how wide a field stands next to other short ones) and
162
- `x-story-for` (filled, the field stands in stories for the neighbour named). A
162
+ `x-story-for` (filled, the field stands in stories for the neighbour named, and
163
+ whole - a block's `sentences` only cuts the neighbour). A
163
164
  group in `x-groups` with `"advanced": true` folds away under "Feinschliff". Photos
164
165
  uploaded in the werkbank land in `public/images/uploads/`; the integration
165
166
  derives their sizes before the build (`maverick-wave-astro/uploads`), skips a
166
167
  file sharp cannot read and removes the originals from `dist/`, since they still
167
- carry EXIF and GPS. Tooling: re-export `maverick-wave-astro/eslint` and
168
- `/prettier`.
168
+ carry EXIF and GPS. In a story series an entry with `showFooter: false` or
169
+ `showReply: false` leaves the call to action or the note out of its own story -
170
+ fixed names, since the werkbank takes no `x-` keyword on a boolean. Tooling:
171
+ re-export `maverick-wave-astro/eslint` and `/prettier`.
169
172
 
170
173
  Pages read sections and the texts of the code through
171
174
  `maverick-wave-astro/werkbank`:
package/dist/design.d.ts CHANGED
@@ -177,6 +177,7 @@ export type Design = {
177
177
  customProperties?: Record<string, string>;
178
178
  };
179
179
  export declare const designClasses: (design: Design) => string[];
180
+ export declare const designProperties: (design: Design) => [string, string][];
180
181
  export declare const designCss: (design: Design) => string;
181
182
  export declare const ELEMENT_KEYS: {
182
183
  readonly header: readonly ["reveal", "sticky"];
@@ -186,5 +187,13 @@ export declare const headerReveals: (design: Design) => boolean;
186
187
  export declare const actionBarFloats: (design: Design) => boolean;
187
188
  export declare const mergeDesigns: (...layers: (Design | undefined)[]) => Design;
188
189
  export declare const validateDesign: (design: Design) => Design;
190
+ export declare const knownDesign: (input: unknown) => Design;
191
+ export declare const DESIGN_CLASSES: string[];
192
+ export declare const previewDesign: (base: Design, sent: unknown) => {
193
+ classes: string[];
194
+ properties: [string, string][];
195
+ headerReveals: boolean;
196
+ actionBarFloats: boolean;
197
+ };
189
198
  export declare const designFromSetup: (setup: string) => Design;
190
199
  export {};
package/dist/design.js CHANGED
@@ -101,13 +101,16 @@ const effects = (design) => Object.entries(VARIANTS).flatMap(([key, values]) =>
101
101
  : [];
102
102
  });
103
103
  export const designClasses = (design) => effects(design).flatMap(effect => 'className' in effect ? [effect.className] : []);
104
+ export const designProperties = (design) => [
105
+ ...effects(design).flatMap(effect => 'property' in effect
106
+ ? [[effect.property, effect.value]]
107
+ : []),
108
+ ...Object.entries(design.customProperties ?? {}),
109
+ ];
104
110
  // Doubled selector on purpose: design.css comes before the site CSS, a plain
105
111
  // :root would lose against the :root block in main.scss.
106
112
  export const designCss = (design) => {
107
- const properties = [
108
- ...effects(design).flatMap(effect => 'property' in effect ? [[effect.property, effect.value]] : []),
109
- ...Object.entries(design.customProperties ?? {}),
110
- ];
113
+ const properties = designProperties(design);
111
114
  return properties.length
112
115
  ? `:root:root{${properties.map(([name, value]) => `${name}:${value};`).join('')}}`
113
116
  : '';
@@ -150,6 +153,32 @@ export const validateDesign = (design) => {
150
153
  }
151
154
  return design;
152
155
  };
156
+ const allowedValues = (key) => {
157
+ if (Object.hasOwn(ELEMENT_KEYS, key)) {
158
+ return ELEMENT_KEYS[key];
159
+ }
160
+ if (!Object.hasOwn(VARIANTS, key))
161
+ return [];
162
+ const variant = key;
163
+ return [DEFAULTS[variant], ...Object.keys(VARIANTS[variant])];
164
+ };
165
+ // Drops instead of throwing: a page on an older package skips a key the
166
+ // werkbank already knows.
167
+ export const knownDesign = (input) => input && typeof input === 'object'
168
+ ? Object.fromEntries(Object.entries(input).filter(([key, value]) => typeof value === 'string' && allowedValues(key).includes(value)))
169
+ : {};
170
+ export const DESIGN_CLASSES = Object.values(VARIANTS).flatMap(values => Object.values(values).flatMap(effect => 'className' in effect ? [effect.className] : []));
171
+ // The werkbank sends the section Design as it would be saved - the base from
172
+ // site.ts stays underneath, as in the build.
173
+ export const previewDesign = (base, sent) => {
174
+ const design = mergeDesigns(base, knownDesign(sent));
175
+ return {
176
+ classes: designClasses(design),
177
+ properties: designProperties(design),
178
+ headerReveals: headerReveals(design),
179
+ actionBarFloats: actionBarFloats(design),
180
+ };
181
+ };
153
182
  // Class names never contain a colon - one table serves both kinds of effect.
154
183
  const REVERSE = new Map(Object.entries(VARIANTS).flatMap(([key, values]) => Object.entries(values).map(([value, effect]) => [
155
184
  'className' in effect
@@ -16,7 +16,8 @@ const FORMS_MODULE = 'virtual:maverick-wave-astro/forms';
16
16
  // Page counter: same origin to nginx, which passes it on to vestigia
17
17
  // internally. No cookie, no identifier, no IP, no third party.
18
18
  const COUNTER = `const isLocal = ['localhost', '127.0.0.1'].includes(window.location.hostname);
19
- if (!isLocal && navigator.sendBeacon) {
19
+ const uncounted = document.documentElement.hasAttribute('data-mwa-uncounted');
20
+ if (!isLocal && !uncounted && navigator.sendBeacon) {
20
21
  const page = window.location.pathname.replace(/^\\/+|\\/+$/g, '') || 'home';
21
22
  navigator.sendBeacon(\`/_c/\${page}\`);
22
23
  }`;
@@ -44,9 +45,13 @@ const withoutSlash = (url) => {
44
45
  target.pathname = withoutTrailingSlash(target.pathname);
45
46
  return target.href;
46
47
  };
48
+ // The werkbank shows it in a frame next to the section Design.
49
+ const DESIGN_PREVIEW = '/werkbank/design';
47
50
  // The sitemap names a page the way its canonical does.
48
51
  const sitemapOptions = (own = {}) => ({
49
52
  ...own,
53
+ filter: page => !new URL(page).pathname.includes(DESIGN_PREVIEW) &&
54
+ (own.filter?.(page) ?? true),
50
55
  serialize: async (item) => {
51
56
  const entry = own.serialize ? await own.serialize(item) : item;
52
57
  if (!entry)
@@ -84,13 +89,15 @@ export const buildConfig = (options, root, werkbank = loadWerkbank(root), now =
84
89
  const base = typeof site.design === 'string'
85
90
  ? designFromSetup(site.design)
86
91
  : site.design;
87
- const design = validateDesign(mergeDesigns(base, fromWerkbank(werkbank, schema => schema === DESIGN_SCHEMA) ??
92
+ const baseDesign = validateDesign(mergeDesigns(base));
93
+ const design = validateDesign(mergeDesigns(baseDesign, fromWerkbank(werkbank, schema => schema === DESIGN_SCHEMA) ??
88
94
  readJson(designPath(options, root))));
89
95
  const occasions = fromWerkbank(werkbank, schema => schema.endsWith(OCCASIONS_SCHEMA)) ?? readJson(occasionsPath(options, root));
90
96
  return {
91
97
  site: { ...site, lang: site.lang ?? 'de', locale: site.locale ?? 'de_DE' },
92
98
  ogImage,
93
99
  design,
100
+ baseDesign,
94
101
  htmlClasses: designClasses(design),
95
102
  designCss: designCss(design),
96
103
  occasion: occasions ? todaysOccasion(occasions, now) : null,
@@ -226,6 +233,17 @@ export default function homepage(options) {
226
233
  prerender: true,
227
234
  });
228
235
  }
236
+ // The page imports the site's styles the way every BaseLayout does.
237
+ const hasDesignSection = werkbank !== undefined &&
238
+ Object.values(werkbank.schemas).includes(DESIGN_SCHEMA);
239
+ if (hasDesignSection &&
240
+ existsSync(path.join(root, 'src/styles/main.scss'))) {
241
+ injectRoute({
242
+ pattern: DESIGN_PREVIEW,
243
+ entrypoint: new URL('../routes/design-preview.astro', import.meta.url),
244
+ prerender: true,
245
+ });
246
+ }
229
247
  },
230
248
  'astro:build:done': ({ dir, logger }) => {
231
249
  const out = fileURLToPath(dir);
@@ -78,7 +78,7 @@ export interface Stage {
78
78
  bottom: number;
79
79
  height: number;
80
80
  }
81
- export declare const loadLook: (options: LookOptions) => Promise<{
81
+ export declare const loadLook: (options: LookOptions, source?: Element) => Promise<{
82
82
  colors: {
83
83
  primary: string;
84
84
  secondary: string;
@@ -219,14 +219,14 @@ const readableOn = (fill, ...candidates) => {
219
219
  };
220
220
  // Inside a light theme box: the image is seen on other phones and does not
221
221
  // follow the dark mode of the one it was made on.
222
- const readPage = () => {
222
+ const readPage = (source) => {
223
223
  const box = document.createElement('div');
224
224
  box.className = 'mw-theme-light';
225
225
  box.hidden = true;
226
226
  const probe = document.createElement('span');
227
227
  const heading = document.createElement('h2');
228
228
  box.append(probe, heading);
229
- document.body.append(box);
229
+ source.append(box);
230
230
  const color = (token) => {
231
231
  probe.style.color = `var(${token})`;
232
232
  return getComputedStyle(probe).color;
@@ -244,7 +244,7 @@ const readPage = () => {
244
244
  shadowNear: color('--mw-shadow-near'),
245
245
  shadowFar: color('--mw-shadow-far'),
246
246
  headingFamily: getComputedStyle(heading).fontFamily,
247
- bodyFamily: getComputedStyle(document.body).fontFamily,
247
+ bodyFamily: getComputedStyle(box).fontFamily,
248
248
  };
249
249
  box.remove();
250
250
  return page;
@@ -278,8 +278,8 @@ const readColors = (page) => ({
278
278
  // that off, in the story the silhouette stays on purpose. As in the framework:
279
279
  // radius-sharp() takes the scale squared, radius('xl') linearly, both with
280
280
  // radius('xs') as the floor.
281
- const cardRadii = () => {
282
- const raw = getComputedStyle(document.documentElement)
281
+ const cardRadii = (source) => {
282
+ const raw = getComputedStyle(source)
283
283
  .getPropertyValue('--mw-radius-scale')
284
284
  .trim();
285
285
  const scale = raw === '' || !Number.isFinite(Number(raw)) ? 1 : Number(raw);
@@ -359,13 +359,15 @@ const settled = async (promise) => {
359
359
  return null;
360
360
  }
361
361
  };
362
- export const loadLook = async (options) => {
362
+ // A page can show a brand other than its own in one element - that one is the
363
+ // source then.
364
+ export const loadLook = async (options, source = document.body) => {
363
365
  // Safari runs module scripts before slow stylesheets have arrived - read
364
366
  // that early, the brand colours come out black and the fonts as Times.
365
367
  if (document.readyState !== 'complete') {
366
368
  await new Promise(resolve => addEventListener('load', resolve, { once: true }));
367
369
  }
368
- const page = readPage();
370
+ const page = readPage(source);
369
371
  const font = (size, weight = 400) => `${weight} ${size}px ${page.bodyFamily}`;
370
372
  const heading = (size, weight = 700) => `${weight} ${size}px ${page.headingFamily}`;
371
373
  // Without the wait the canvas draws the fallback font - it knows no
@@ -388,7 +390,7 @@ export const loadLook = async (options) => {
388
390
  colors,
389
391
  font,
390
392
  heading,
391
- radii: cardRadii(),
393
+ radii: cardRadii(source),
392
394
  logo,
393
395
  icons: onCard,
394
396
  whiteIcons: onDark,
package/dist/types.d.ts CHANGED
@@ -38,6 +38,7 @@ export type Config = {
38
38
  };
39
39
  ogImage: OgImage;
40
40
  design: Design;
41
+ baseDesign: Design;
41
42
  htmlClasses: string[];
42
43
  designCss: string;
43
44
  occasion: Occasion | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maverick-wave-astro",
3
- "version": "1.47.0",
3
+ "version": "1.49.0",
4
4
  "description": "Shared frame for static Astro homepages built with MaverickWave: layout, SEO, design variants, schedule, building blocks.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -70,7 +70,7 @@
70
70
  "eslint-plugin-astro": "^1.5.0",
71
71
  "eslint-plugin-simple-import-sort": "^12.1.1",
72
72
  "globals": "^16.5.0",
73
- "maverick-wave": "^6.33.0",
73
+ "maverick-wave": "^6.34.0",
74
74
  "playwright-core": "^1.64.0",
75
75
  "prettier": "^3.6.2",
76
76
  "prettier-plugin-astro": "^0.14.1",
@@ -0,0 +1,208 @@
1
+ ---
2
+ // A small page in the site's own colours and fonts. The werkbank frames it
3
+ // next to the section Design and sends every choice before it is saved.
4
+ import '@/styles/main.scss';
5
+
6
+ import config from 'virtual:maverick-wave-astro/config';
7
+
8
+ import ActionBar from '../components/ActionBar.astro';
9
+ import Footer from '../components/Footer.astro';
10
+ import Header from '../components/Header.astro';
11
+ import { designClasses } from '../dist/design.js';
12
+ import { withBase } from '../dist/path.js';
13
+
14
+ const { site, ogImage, baseDesign } = config;
15
+
16
+ const OFFERS = [
17
+ {
18
+ title: 'Erstes Angebot',
19
+ text: 'So steht ein Angebot auf deiner Homepage: ein Bild, ein paar Sätze und ein Link.',
20
+ },
21
+ {
22
+ title: 'Zweites Angebot',
23
+ text: 'Ecken, Schatten und Abstände kommen aus dem Design, Farben und Schrift bleiben deine.',
24
+ },
25
+ {
26
+ title: 'Drittes Angebot',
27
+ text: 'Zeig mit der Maus auf eine Karte, dann siehst du, wie sie sich bewegt.',
28
+ },
29
+ ];
30
+ ---
31
+
32
+ <!doctype html>
33
+ <html
34
+ lang={site.lang}
35
+ class:list={designClasses(baseDesign)}
36
+ data-mwa-design-base={JSON.stringify(baseDesign)}
37
+ data-mwa-uncounted
38
+ >
39
+ <head>
40
+ <meta charset="UTF-8" />
41
+ <meta
42
+ name="viewport"
43
+ content="width=device-width, minimum-scale=1, initial-scale=1, viewport-fit=cover"
44
+ />
45
+ {
46
+ site.colorScheme && (
47
+ <meta name="color-scheme" content={site.colorScheme} />
48
+ )
49
+ }
50
+ <meta name="robots" content="noindex, nofollow" />
51
+ <title>{`Design-Vorschau · ${site.name}`}</title>
52
+ {site.themeToggle && <script is:inline src={withBase('/theme.js')} />}
53
+ </head>
54
+
55
+ <body class={site.bodyClass}>
56
+ <Header
57
+ navigation={[
58
+ { label: 'Angebot', href: '#angebot' },
59
+ { label: 'Kontakt', href: '#kontakt' },
60
+ ]}
61
+ reveal
62
+ >
63
+ <a slot="brand" class="mw-text-lg mw-font-bold" href="#content">
64
+ {site.name}
65
+ </a>
66
+ </Header>
67
+
68
+ <main id="content" class="mw-main" tabindex="-1">
69
+ <section class="mw-section">
70
+ <div class="mw-container">
71
+ <p class="mw-text-eyebrow">Willkommen</p>
72
+ <h1>So wirkt deine Homepage</h1>
73
+ <p class="mw-text-lg mw-text-measure">
74
+ Alles, was du links auswählst, siehst du hier sofort. Ein{' '}
75
+ <a class="mw-link" href="#angebot">Link im Text</a> ist immer unterstrichen.
76
+ </p>
77
+ <div class="mw-d-flex mw-flex-wrap mw-items-center mw-gap-3 mw-mt-6">
78
+ <a class="mw-btn mw-btn-primary" href="#kontakt">Termin buchen</a>
79
+ <a class="mw-btn mw-btn-outline" href="#angebot">Mehr erfahren</a>
80
+ </div>
81
+ </div>
82
+ </section>
83
+
84
+ <section id="angebot" class="mw-section mw-section-alternate">
85
+ <div class="mw-container">
86
+ <div class="mw-section-head mw-reveal">
87
+ <p class="mw-text-eyebrow">Angebot</p>
88
+ <h2 class="mw-section-head-title">Unsere Angebote</h2>
89
+ <p class="mw-section-head-intro">
90
+ Karten, wie sie auf deiner Homepage stehen.
91
+ </p>
92
+ </div>
93
+ <div class="mw-grid-3-lg mw-reveal-stagger">
94
+ {
95
+ OFFERS.map(offer => (
96
+ <article class="mw-card">
97
+ <div class="mw-card-img">
98
+ <img
99
+ src={withBase(ogImage.path)}
100
+ width={ogImage.width}
101
+ height={ogImage.height}
102
+ alt=""
103
+ loading="lazy"
104
+ decoding="async"
105
+ />
106
+ </div>
107
+ <div class="mw-card-body">
108
+ <h3 class="mw-card-title">{offer.title}</h3>
109
+ <p class="mw-card-text">{offer.text}</p>
110
+ </div>
111
+ <div class="mw-card-footer">
112
+ <a class="mw-btn mw-btn-link" href="#kontakt">
113
+ Mehr dazu
114
+ </a>
115
+ </div>
116
+ </article>
117
+ ))
118
+ }
119
+ </div>
120
+ </div>
121
+ </section>
122
+
123
+ <section id="kontakt" class="mw-section">
124
+ <div class="mw-container">
125
+ <div class="mw-section-head mw-reveal">
126
+ <p class="mw-text-eyebrow">Kontakt</p>
127
+ <h2 class="mw-section-head-title">Schreib uns</h2>
128
+ </div>
129
+ <article class="mw-card mw-reveal">
130
+ <div class="mw-card-body">
131
+ <h3 class="mw-card-title">Wir freuen uns auf dich</h3>
132
+ <p class="mw-card-text">
133
+ Der zweite Button trägt die zweite Farbe deiner Homepage.
134
+ </p>
135
+ <div class="mw-d-flex mw-flex-wrap mw-items-center mw-gap-3">
136
+ <a class="mw-btn mw-btn-primary" href="#kontakt">Anfragen</a>
137
+ <a class="mw-btn mw-btn-secondary" href="#kontakt">Anrufen</a>
138
+ <a class="mw-btn mw-btn-link" href="#angebot">Preise ansehen</a>
139
+ </div>
140
+ </div>
141
+ </article>
142
+ </div>
143
+ </section>
144
+ </main>
145
+
146
+ <Footer
147
+ owner={site.name}
148
+ columns={[
149
+ { title: 'Adresse', lines: ['Musterstraße 1', '12345 Musterstadt'] },
150
+ {
151
+ title: 'Öffnungszeiten',
152
+ lines: ['Montag bis Freitag', '9 bis 18 Uhr'],
153
+ },
154
+ ]}
155
+ />
156
+ <ActionBar
157
+ label="Schnellkontakt"
158
+ items={[
159
+ { href: '#kontakt', kind: 'call', primary: true },
160
+ { href: '#kontakt', kind: 'route' },
161
+ { href: '#kontakt', kind: 'mail' },
162
+ ]}
163
+ />
164
+
165
+ <script>
166
+ import { DESIGN_CLASSES, previewDesign } from '../dist/design.js';
167
+
168
+ const root = document.documentElement;
169
+ const base = JSON.parse(root.dataset.mwaDesignBase ?? '{}');
170
+ // A site without the action-bar module would show it as a bare list -
171
+ // and the werkbank hides the choice that only changes the bar.
172
+ const bar = document.querySelector('.mw-action-bar');
173
+ const actionBar =
174
+ bar && getComputedStyle(bar).position !== 'static' ? bar : null;
175
+ if (!actionBar) bar?.remove();
176
+
177
+ let properties: string[] = [];
178
+
179
+ const show = (sent: unknown) => {
180
+ const preview = previewDesign(base, sent);
181
+ root.classList.remove(...DESIGN_CLASSES);
182
+ root.classList.add(...preview.classes);
183
+ for (const name of properties) root.style.removeProperty(name);
184
+ for (const [name, value] of preview.properties) {
185
+ root.style.setProperty(name, value);
186
+ }
187
+ properties = preview.properties.map(([name]) => name);
188
+ document
189
+ .querySelector('.mw-header')
190
+ ?.classList.toggle('mw-header-reveal', preview.headerReveals);
191
+ actionBar?.classList.toggle(
192
+ 'mw-action-bar-island',
193
+ preview.actionBarFloats
194
+ );
195
+ };
196
+
197
+ show({});
198
+ addEventListener('message', event => {
199
+ if (event.source !== parent || event.data?.type !== 'mw-design') return;
200
+ show(event.data.design);
201
+ });
202
+ parent.postMessage(
203
+ { type: 'mw-design-bereit', actionBar: actionBar !== null },
204
+ '*'
205
+ );
206
+ </script>
207
+ </body>
208
+ </html>
@@ -7,7 +7,7 @@
7
7
  "properties": {
8
8
  "corners": {
9
9
  "title": "Ecken der Karten",
10
- "description": "Zwei spitze und zwei runde Ecken sind das Markenzeichen von MaverickWave. Gleichmäßig rundet alle vier Ecken gleich.",
10
+ "description": "Zwei spitze und zwei runde Ecken sind das Markenzeichen von MaverickWave. Gleichmäßig rundet alle vier Ecken gleich, nur eine kleine Bogenmarke bleibt in einer Ecke.",
11
11
  "type": "string",
12
12
  "enum": ["signature", "even"],
13
13
  "x-labels": {
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "labelColor": {
67
67
  "title": "Schrift auf Farbflächen",
68
- "description": "Automatisch nimmt je Farbe Schwarz oder Weiß, was besser lesbar ist. Braucht einen Browser mit contrast-color(), sonst bleibt die eingestellte Farbe.",
68
+ "description": "Automatisch nimmt je Farbe Schwarz oder Weiß, was besser lesbar ist. Braucht einen Browser mit contrast-color(), sonst bleibt die eingestellte Farbe. Wirkungslos für jede Farbe, deren Schrift die Seite selbst festlegt.",
69
69
  "type": "string",
70
70
  "enum": ["palette", "auto"],
71
71
  "x-labels": {
@@ -158,7 +158,7 @@
158
158
  },
159
159
  "hover": {
160
160
  "title": "Bewegung unter der Maus",
161
- "description": "Ruhig: nichts hebt sich oder zoomt. Farben reagieren weiter.",
161
+ "description": "Ruhig: nichts bewegt sich unter der Maus - kein Bild-Zoom, kein nachziehender Eckbogen. Farben reagieren weiter.",
162
162
  "type": "string",
163
163
  "enum": ["animated", "static"],
164
164
  "x-labels": {
@@ -159,7 +159,7 @@
159
159
  "style": ["h2", "h3", "h4", "p"]
160
160
  },
161
161
  "title": "Nur die ersten Sätze",
162
- "description": "Wie viele Sätze stehen bleiben. 0 zeigt den ganzen Text. Praktisch für den Anfang eines Blogartikels.",
162
+ "description": "Wie viele Sätze stehen bleiben. 0 zeigt den ganzen Text. Praktisch für den Anfang eines Blogartikels. Ein eigener Text für die Story bleibt immer ganz.",
163
163
  "type": "integer",
164
164
  "minimum": 0,
165
165
  "maximum": 5,