maverick-wave-astro 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,6 +48,8 @@ The site wraps `BaseLayout` once and imports its stylesheet there:
48
48
  ```
49
49
 
50
50
  Slot `banner` sits below the header; `htmlData` puts `data-*` on `<html>`.
51
+ `bodyClass` adds to `site.bodyClass`; `bare` renders only the default slot into
52
+ `<body>` - no skip link, no `<main>`, no header or footer.
51
53
 
52
54
  ## Components
53
55
 
@@ -62,18 +64,73 @@ Slot `banner` sits below the header; `htmlData` puts `data-*` on `<html>`.
62
64
 
63
65
  Helpers live in `src/` and import as `maverick-wave-astro/<file>`.
64
66
 
67
+ ## Presentations
68
+
69
+ A presentation is one JSON object typed `Deck` (`maverick-wave-astro/deck`):
70
+ `format` (`landscape` | `portrait`), brand, and `slides` with `layout`, `tone`,
71
+ `image` or `drawing`, head texts and `blocks` (facts, figures, list, chips,
72
+ steps, notes, jumps, table, packages, images, quote, price, text, actions,
73
+ swipe, chart). `Deck` renders it as a page of its own; the site wraps it once to
74
+ bring its stylesheet, like `BaseLayout`:
75
+
76
+ ```astro
77
+ ---
78
+ import "@/styles/main.scss";
79
+ import Frame from "maverick-wave-astro/Deck.astro";
80
+ ---
81
+
82
+ <Frame deck={Astro.props.deck}><slot /></Frame>
83
+ ```
84
+
85
+ `DeckFrame` embeds such a page in an iframe (slot = text beside it), `DeckCard`
86
+ links to it. SCSS: `components/deck` and `components/deck-frame`.
87
+
88
+ `Deck` checks the JSON while building (`validateDeck`) and stops with the path
89
+ of every problem - an unknown block type, a jump to a missing slide id, a
90
+ drawing not in `public/`. The chrome over the slides wears the second colour;
91
+ `accent: 'primary'` keeps it to the first, `design.accent: 'single'` does so
92
+ site-wide.
93
+
94
+ ## Occasions
95
+
96
+ Seasonal decoration on the cards, panels and testimonials - snow, a garland,
97
+ leaves, bunting. Drawn by MaverickWave (`components/occasions`), switched on by
98
+ a file: with `src/content/occasions.json` the integration sets
99
+ `data-mw-occasions` on `<html>` and serves `/occasions.js`, MaverickWave's head
100
+ script, as the first script in `<head>`. It picks today's entry before the first
101
+ paint.
102
+
103
+ ```json
104
+ {
105
+ "motion": "dynamic",
106
+ "size": "sm",
107
+ "entries": [
108
+ {
109
+ "effect": "christmas",
110
+ "from": "2026-12-18",
111
+ "until": "2026-12-26",
112
+ "yearly": true
113
+ }
114
+ ]
115
+ }
116
+ ```
117
+
118
+ `motion` (`static` | `dynamic`) and the optional `size` (`sm` | `lg`) hold for
119
+ every entry. Needs maverick-wave 5.34 or later.
120
+
65
121
  ## Contentmanager
66
122
 
67
123
  `contentmanager/sections.json` lists the editable files and their schemas;
68
- `schemas/design.schema.json` and `schemas/promo.schema.json` ship with the
69
- package. Put `mwa-check && astro build` in the build script so a broken file
70
- stops the build - it knows the formats `date`, `email`, `uri` and the keywords
71
- `x-widget`, `x-item-title`, `x-labels`, `x-empty`, `x-not-before`, `x-groups`.
72
- Photos uploaded in the contentmanager land in `public/images/uploads/`; the
73
- integration derives their sizes before the build
74
- (`maverick-wave-astro/uploads`), skips a file sharp cannot read and removes the
75
- originals from `dist/`, since they still carry EXIF and GPS. Tooling: re-export
76
- `maverick-wave-astro/eslint` and `/prettier`.
124
+ `schemas/design.schema.json`, `schemas/promo.schema.json` and
125
+ `schemas/occasions.schema.json` ship with the package. Put
126
+ `mwa-check && astro build` in the build script so a broken file stops the
127
+ build - it knows the formats `date`, `email`, `uri` and the keywords `x-widget`,
128
+ `x-item-title`, `x-labels`, `x-empty`, `x-not-before`, `x-groups`. Photos
129
+ uploaded in the contentmanager land in `public/images/uploads/`; the integration
130
+ derives their sizes before the build (`maverick-wave-astro/uploads`), skips a
131
+ file sharp cannot read and removes the originals from `dist/`, since they still
132
+ carry EXIF and GPS. Tooling: re-export `maverick-wave-astro/eslint` and
133
+ `/prettier`.
77
134
 
78
135
  ## Releasing
79
136
 
@@ -19,9 +19,14 @@ type Props = {
19
19
  // Ends up as data-* on <html>, e.g. { 'promo-until': ... } for the
20
20
  // schedule. null and undefined leave the attribute out.
21
21
  htmlData?: Record<string, string | null | undefined>;
22
+ // Next to site.bodyClass, e.g. mw-deck for a presentation
23
+ bodyClass?: string;
24
+ // The page brings its own body: no skip link, no <main>, no header or
25
+ // footer slot - a presentation is one.
26
+ bare?: boolean;
22
27
  };
23
28
 
24
- const { site, ogImage: OG_IMAGE, htmlClasses, designCss } = config;
29
+ const { site, ogImage: OG_IMAGE, htmlClasses, designCss, occasions } = config;
25
30
 
26
31
  const {
27
32
  title,
@@ -36,6 +41,8 @@ const {
36
41
  alternates = [],
37
42
  skipLabel = lang.startsWith('de') ? 'Zum Inhalt springen' : 'Skip to content',
38
43
  htmlData = {},
44
+ bodyClass,
45
+ bare = false,
39
46
  } = Astro.props;
40
47
 
41
48
  const canonicalUrl = new URL(Astro.url.pathname, Astro.site);
@@ -51,11 +58,12 @@ const robots =
51
58
  ? 'noindex, nofollow'
52
59
  : 'index, follow, max-image-preview:large, max-snippet:-1';
53
60
 
61
+ // A site that sets mw-occasions itself keeps its own.
54
62
  const dataAttributes = Object.fromEntries(
55
- Object.entries(htmlData).map(([name, value]) => [
56
- `data-${name}`,
57
- value ?? undefined,
58
- ])
63
+ Object.entries({
64
+ 'mw-occasions': occasions.length ? JSON.stringify(occasions) : null,
65
+ ...htmlData,
66
+ }).map(([name, value]) => [`data-${name}`, value ?? undefined])
59
67
  );
60
68
  ---
61
69
 
@@ -127,16 +135,33 @@ const dataAttributes = Object.fromEntries(
127
135
  <slot name="head" />
128
136
  {designCss && <link rel="stylesheet" href={withBase('/design.css')} />}
129
137
  {site.themeToggle && <script is:inline src={withBase('/theme.js')} />}
138
+ {
139
+ occasions.length > 0 && (
140
+ <script is:inline src={withBase('/occasions.js')} />
141
+ )
142
+ }
130
143
  </head>
131
144
 
132
- <body class={site.bodyClass || undefined}>
133
- <a class="mw-skip-link" href="#content">{skipLabel}</a>
134
- <slot name="header" />
135
- <slot name="banner" />
136
- <main id="content" class="mw-main" tabindex="-1">
137
- <slot />
138
- </main>
139
- <slot name="footer" />
145
+ <body
146
+ class={[site.bodyClass, bodyClass].filter(Boolean).join(' ') || undefined}
147
+ >
148
+ {
149
+ bare ? (
150
+ <slot />
151
+ ) : (
152
+ <Fragment>
153
+ <a class="mw-skip-link" href="#content">
154
+ {skipLabel}
155
+ </a>
156
+ <slot name="header" />
157
+ <slot name="banner" />
158
+ <main id="content" class="mw-main" tabindex="-1">
159
+ <slot />
160
+ </main>
161
+ <slot name="footer" />
162
+ </Fragment>
163
+ )
164
+ }
140
165
  <slot name="scripts" />
141
166
  </body>
142
167
  </html>
@@ -0,0 +1,195 @@
1
+ ---
2
+ // A presentation as a page of its own, built from one data object: the
3
+ // mw-deck frame of MaverickWave around its slides. Like BaseLayout, the site
4
+ // wraps it once to bring its stylesheet. Slides in the default slot come
5
+ // after the ones from the data.
6
+ import { config } from '../dist/config.js';
7
+ import { counter, type Deck, validateDeck } from '../dist/deck.js';
8
+ import { linkTo, withBase } from '../dist/path.js';
9
+ import BaseLayout from './BaseLayout.astro';
10
+ import DeckSlide from './DeckSlide.astro';
11
+
12
+ interface Props {
13
+ deck: Deck;
14
+ // On <body> next to mw-deck, e.g. a class that retunes the colours
15
+ class?: string;
16
+ previousLabel?: string;
17
+ nextLabel?: string;
18
+ fullscreenLabel?: string;
19
+ }
20
+
21
+ const german = config.site.lang.startsWith('de');
22
+
23
+ const {
24
+ deck,
25
+ class: className,
26
+ previousLabel = german ? 'Vorherige Folie' : 'Previous slide',
27
+ nextLabel = german ? 'Nächste Folie' : 'Next slide',
28
+ fullscreenLabel = german ? 'Vollbild an oder aus' : 'Toggle fullscreen',
29
+ } = Astro.props;
30
+
31
+ // A broken JSON stops the build with its paths instead of shipping a gap
32
+ validateDeck(deck);
33
+
34
+ const portrait = deck.format === 'portrait';
35
+ const rotate = {
36
+ title: german ? 'Bitte quer halten' : 'Please turn your phone',
37
+ text: german
38
+ ? 'Diese Präsentation ist für Tablet und Computer gemacht. Drehen Sie Ihr Handy ins Querformat oder öffnen Sie sie auf einem größeren Bildschirm.'
39
+ : 'This presentation is made for tablets and computers. Turn your phone sideways or open it on a larger screen.',
40
+ ...deck.rotate,
41
+ };
42
+
43
+ // The same head and slides either way; portrait puts them on the phone stage
44
+ const Stage = portrait ? 'div' : Fragment;
45
+ ---
46
+
47
+ <BaseLayout
48
+ title={deck.title}
49
+ description={deck.description}
50
+ ogImage={deck.ogImage ? withBase(deck.ogImage) : null}
51
+ noIndex={deck.noIndex ?? true}
52
+ bodyClass={[
53
+ 'mw-deck',
54
+ portrait ? 'mw-deck-portrait' : 'mw-deck-landscape',
55
+ deck.accent === 'primary' && 'mw-deck-accent-primary',
56
+ className,
57
+ ]
58
+ .filter(Boolean)
59
+ .join(' ')}
60
+ bare
61
+ >
62
+ <slot name="head" slot="head" />
63
+
64
+ {
65
+ portrait && deck.aside && (
66
+ <aside class="mw-deck-aside">
67
+ {deck.aside.kicker && <p class="mw-deck-kicker">{deck.aside.kicker}</p>}
68
+ <p class="mw-deck-aside-title">{deck.aside.title}</p>
69
+ {deck.aside.text && <p>{deck.aside.text}</p>}
70
+ <div class="mw-deck-arrows">
71
+ <button
72
+ type="button"
73
+ class="mw-deck-btn"
74
+ data-deck-prev
75
+ aria-label={previousLabel}
76
+ >
77
+ <svg viewBox="0 0 24 24" aria-hidden="true">
78
+ <path d="M5 15l7-7 7 7" />
79
+ </svg>
80
+ </button>
81
+ <button
82
+ type="button"
83
+ class="mw-deck-btn"
84
+ data-deck-next
85
+ aria-label={nextLabel}
86
+ >
87
+ <svg viewBox="0 0 24 24" aria-hidden="true">
88
+ <path d="M5 9l7 7 7-7" />
89
+ </svg>
90
+ </button>
91
+ </div>
92
+ {deck.aside.link && (
93
+ <a href={linkTo(deck.aside.link.href)} target="_top">
94
+ {deck.aside.link.label}
95
+ </a>
96
+ )}
97
+ </aside>
98
+ )
99
+ }
100
+
101
+ <Stage {...portrait ? { class: 'mw-deck-stage' } : {}}>
102
+ {portrait && <div class="mw-deck-segments" />}
103
+ <header class="mw-deck-head">
104
+ <span class="mw-deck-brand">
105
+ {deck.brand}
106
+ {deck.brandNote && <small>{deck.brandNote}</small>}
107
+ </span>
108
+ <div class="mw-deck-tools">
109
+ <span class="mw-deck-counter">
110
+ {counter(0, deck.slides.length)}
111
+ </span>
112
+ <button
113
+ type="button"
114
+ class="mw-deck-btn"
115
+ data-deck-fullscreen
116
+ aria-label={fullscreenLabel}
117
+ >
118
+ <svg
119
+ class="mw-deck-icon-expand"
120
+ viewBox="0 0 24 24"
121
+ aria-hidden="true"
122
+ >
123
+ <path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"></path>
124
+ </svg>
125
+ <svg
126
+ class="mw-deck-icon-collapse"
127
+ viewBox="0 0 24 24"
128
+ aria-hidden="true"
129
+ >
130
+ <path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"></path>
131
+ </svg>
132
+ </button>
133
+ </div>
134
+ </header>
135
+
136
+ <main class="mw-deck-slides">
137
+ {
138
+ deck.slides.map((slide, index) => (
139
+ <DeckSlide
140
+ slide={slide}
141
+ format={deck.format}
142
+ heading={index === 0 ? 'h1' : 'h2'}
143
+ />
144
+ ))
145
+ }
146
+ <slot />
147
+ </main>
148
+ </Stage>
149
+
150
+ {
151
+ !portrait && (
152
+ <Fragment>
153
+ <footer class="mw-deck-foot">
154
+ <div class="mw-deck-progress" />
155
+ <div class="mw-deck-arrows">
156
+ <button
157
+ type="button"
158
+ class="mw-deck-btn"
159
+ data-deck-prev
160
+ aria-label={previousLabel}
161
+ >
162
+ <svg viewBox="0 0 24 24" aria-hidden="true">
163
+ <path d="M15 5l-7 7 7 7" />
164
+ </svg>
165
+ </button>
166
+ <button
167
+ type="button"
168
+ class="mw-deck-btn"
169
+ data-deck-next
170
+ aria-label={nextLabel}
171
+ >
172
+ <svg viewBox="0 0 24 24" aria-hidden="true">
173
+ <path d="M9 5l7 7-7 7" />
174
+ </svg>
175
+ </button>
176
+ </div>
177
+ </footer>
178
+
179
+ <div class="mw-deck-rotate" role="note">
180
+ <svg viewBox="0 0 24 24" aria-hidden="true">
181
+ <rect x="7" y="2" width="10" height="20" rx="2" />
182
+ <path d="M11 18h2" />
183
+ </svg>
184
+ <h2 class="mw-deck-title">{rotate.title}</h2>
185
+ <p>{rotate.text}</p>
186
+ {rotate.link && (
187
+ <a href={linkTo(rotate.link.href)} target="_top">
188
+ {rotate.link.label}
189
+ </a>
190
+ )}
191
+ </div>
192
+ </Fragment>
193
+ )
194
+ }
195
+ </BaseLayout>