maverick-wave-astro 1.12.0 → 1.13.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
@@ -68,12 +68,13 @@ The toggles come from the MaverickWave script.
68
68
  - Frame: `Header`, `Footer` (social links and notes above a bar with copyright,
69
69
  credit and the legal `links`; `dark`, `compact`), `ThemeToggle`,
70
70
  `LanguageSwitch`, `Announcement`, `PromoBar`
71
- - Sections: `Hero` (`variant` start | fade), `SectionHead`, `IconCard`,
72
- `ValueList`, `OpeningHours`, `Address`, `Accordion`, `Calendar`,
71
+ - Sections: `Hero` (`variant` start | fade), `SplitHero` (text beside a photo,
72
+ no parallax), `Parallax` (a picture band between sections), `SectionHead`,
73
+ `IconCard`, `ValueList`, `OpeningHours`, `Address`, `Accordion`, `Calendar`,
73
74
  `CalendarLegend`, `EmptyState` (`inline`)
74
75
  - Blocks: `Bento` with `BentoItem` (`size` wide | tall | lg | full), `ActionBar`
75
76
  (call, route, booking), `Marquee`, `Compare`, `Stat` in a `StatGroup`,
76
- `Meter`, `ProgressRing`, `Chat`, `Pagination`
77
+ `Meter`, `ProgressRing`, `Rating`, `Chat`, `Pagination`
77
78
  - Options: `Modal` `drawer` (end | start), `Progress` without `value` runs
78
79
  indeterminate, `Timeline` `variant="compact"`, `Picture` `shape` (arch |
79
80
  signature | leaf), `Table` `hover` and `stickyFirst`
@@ -1,8 +1,10 @@
1
1
  ---
2
2
  // Questions and answers. The icon comes as a slot, rendered once and placed in
3
3
  // every row - the site decides whether it gets its own wrapper.
4
+ import { answerParagraphs, type Question } from '../dist/faq.js';
5
+
4
6
  interface Props {
5
- items: readonly { question: string; answer: string | readonly string[] }[];
7
+ items: readonly Question[];
6
8
  idPrefix: string;
7
9
  firstOpen?: boolean;
8
10
  class?: string;
@@ -32,10 +34,7 @@ const icon = await Astro.slots.render('icon');
32
34
  id={`${idPrefix}${index}`}
33
35
  >
34
36
  <div class="mw-accordion-content-inner">
35
- {(typeof item.answer === 'string'
36
- ? [item.answer]
37
- : item.answer
38
- ).map(paragraph => (
37
+ {answerParagraphs(item.answer).map(paragraph => (
39
38
  <p>{paragraph}</p>
40
39
  ))}
41
40
  </div>
@@ -36,6 +36,7 @@ interface Props {
36
36
  // Prefix for the ids the toggles point at.
37
37
  id?: string;
38
38
  navLabel?: string;
39
+ labels?: { skip?: string; menu?: string; close?: string; tabbar?: string };
39
40
  class?: string;
40
41
  }
41
42
 
@@ -53,19 +54,26 @@ const {
53
54
  flush = false,
54
55
  id = 'app',
55
56
  navLabel = german ? 'Hauptnavigation' : 'Main',
57
+ labels = {},
56
58
  class: className,
57
59
  } = Astro.props;
58
60
 
61
+ const {
62
+ skip = german ? 'Zum Inhalt springen' : 'Skip to content',
63
+ menu = 'Navigation',
64
+ close: closeLabel = german ? 'Schließen' : 'Close',
65
+ tabbar: tabbarLabel = german ? 'Hauptbereiche' : 'Primary',
66
+ } = labels;
67
+
59
68
  const path = (href: string) => href.replace(/\/$/, '') || '/';
60
69
  const here = path(Astro.url.pathname);
61
70
  const isCurrent = (link: AppLink) =>
62
71
  link.current ?? path(linkTo(link.href)) === here;
63
72
  const hasAside = Boolean(aside) && Astro.slots.has('aside');
64
- const closeLabel = german ? 'Schließen' : 'Close';
65
73
  ---
66
74
 
67
75
  <a class="mw-skip-link" href={`#${id}-content`}>
68
- {german ? 'Zum Inhalt springen' : 'Skip to content'}
76
+ {skip}
69
77
  </a>
70
78
  <div
71
79
  class:list={['mw-app', collapsed && 'mw-app-collapsed', className]}
@@ -129,7 +137,7 @@ const closeLabel = german ? 'Schließen' : 'Close';
129
137
  class="mw-app-toggle"
130
138
  data-mw-app-toggle
131
139
  aria-controls={`${id}-nav`}
132
- aria-label="Navigation"
140
+ aria-label={menu}
133
141
  >
134
142
  <span class="mw-app-toggle-icon"></span>
135
143
  </button>
@@ -184,10 +192,7 @@ const closeLabel = german ? 'Schließen' : 'Close';
184
192
 
185
193
  {
186
194
  tabbar.length > 0 && (
187
- <nav
188
- class="mw-app-tabbar"
189
- aria-label={german ? 'Hauptbereiche' : 'Primary'}
190
- >
195
+ <nav class="mw-app-tabbar" aria-label={tabbarLabel}>
191
196
  {tabbar.map(link => (
192
197
  <a
193
198
  class="mw-app-tabbar-item"
@@ -3,7 +3,7 @@
3
3
  // picture, the text as Markdown in the slot, and a way on at the end - older,
4
4
  // back to the list, newer. A missing neighbour keeps its place empty, so the
5
5
  // three parts stay where they are.
6
- import { config } from '../dist/config.js';
6
+ import { siteLocale } from '../dist/config.js';
7
7
  import { longDate, parseIsoDate } from '../dist/date.js';
8
8
  import { PACKAGE_ICONS } from '../dist/icons.js';
9
9
  import { publicImage } from '../dist/image-size.js';
@@ -41,7 +41,7 @@ const {
41
41
  back,
42
42
  newer,
43
43
  level = 'h1',
44
- locale = config.site.locale.replace('_', '-'),
44
+ locale = siteLocale,
45
45
  class: className,
46
46
  } = Astro.props;
47
47
  const Title = level;
@@ -2,6 +2,7 @@
2
2
  // One month as mw-calendar: weekday row starting on Monday, six rows of days,
3
3
  // optionally a legend. What a day shows - dots, a link, disabled - comes from
4
4
  // the site through `view`.
5
+ import { siteLocale } from '../dist/config.js';
5
6
  import type { CalendarDay, CalendarMonth } from '../dist/date.js';
6
7
  import { fullDate } from '../dist/date.js';
7
8
  import CalendarLegend from './CalendarLegend.astro';
@@ -23,7 +24,7 @@ interface Props<T extends object = object> {
23
24
 
24
25
  const {
25
26
  month,
26
- locale = 'de-DE',
27
+ locale = siteLocale,
27
28
  view = () => ({}),
28
29
  legend,
29
30
  class: className,
@@ -77,16 +78,22 @@ const weekdays = Array.from({ length: 7 }, (_, index) =>
77
78
  .filter(Boolean)
78
79
  .join(' ');
79
80
  const Element = disabled ? 'button' : href ? 'a' : 'div';
81
+ const name = label ?? fullDate(day.iso, locale);
82
+ // aria-label on a plain div is not read - the name goes in as text
83
+ const plain = Element === 'div';
80
84
  return (
81
85
  <Element
82
86
  type={disabled ? 'button' : undefined}
83
87
  class={className}
84
88
  data-day={day.iso}
85
89
  href={disabled ? undefined : href}
86
- aria-label={label ?? fullDate(day.iso, locale)}
90
+ aria-label={plain ? undefined : name}
87
91
  disabled={disabled || undefined}
88
92
  >
89
- <span class="mw-calendar-date">{day.day}</span>
93
+ <span class="mw-calendar-date" aria-hidden={plain || undefined}>
94
+ {day.day}
95
+ </span>
96
+ {plain && <span class="mw-sr-only">{name}</span>}
90
97
  {dots.length > 0 && (
91
98
  <span class="mw-calendar-dots">
92
99
  {dots.map(dot => (
@@ -3,6 +3,7 @@
3
3
  // Nothing is sent from here: the bubbles, a note between them and the typing
4
4
  // or thinking state are all static.
5
5
  import { config } from '../dist/config.js';
6
+ import { answerParagraphs } from '../dist/faq.js';
6
7
 
7
8
  interface Props {
8
9
  // Names the log for screen readers.
@@ -41,9 +42,6 @@ const {
41
42
  thinking,
42
43
  class: className,
43
44
  } = Astro.props;
44
-
45
- const paragraphs = (text: string | readonly string[]) =>
46
- typeof text === 'string' ? [text] : text;
47
45
  ---
48
46
 
49
47
  <div class:list={['mw-chat', className]} role="log" aria-label={label}>
@@ -80,7 +78,7 @@ const paragraphs = (text: string | readonly string[]) =>
80
78
  </div>
81
79
  )}
82
80
  <div class="mw-chat-bubble">
83
- {paragraphs(message.text).map(paragraph => (
81
+ {answerParagraphs(message.text).map(paragraph => (
84
82
  <p>{paragraph}</p>
85
83
  ))}
86
84
  </div>
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  // Weekday above, date below - the stamp in front of an mw-date-stamp-body.
3
3
  // "today" is set by the build and moved along by Schedule via data-day.
4
+ import { siteLocale } from '../dist/config.js';
4
5
  import { dateStamp, isoDate, parseIsoDate } from '../dist/date.js';
5
6
 
6
7
  interface Props {
@@ -10,7 +11,7 @@ interface Props {
10
11
  class?: string;
11
12
  }
12
13
 
13
- const { date, locale = 'de-DE', class: className } = Astro.props;
14
+ const { date, locale = siteLocale, class: className } = Astro.props;
14
15
  const stamp = dateStamp(parseIsoDate(date), locale);
15
16
  const today = stamp.iso === isoDate(new Date());
16
17
  ---
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  // One block of a DeckSlide. Lists whose entries enter one by one take the
3
3
  // step for their first entry; everything else enters as a whole.
4
- import { config } from '../dist/config.js';
4
+ import { siteLocale } from '../dist/config.js';
5
5
  import { chartGeometry, type DeckBlock, entrance } from '../dist/deck.js';
6
6
  import { publicImage } from '../dist/image-size.js';
7
7
  import { linkTo } from '../dist/path.js';
@@ -14,7 +14,7 @@ interface Props {
14
14
  const { block, step } = Astro.props;
15
15
 
16
16
  const at = (offset = 0) => entrance(step + offset);
17
- const number = new Intl.NumberFormat(config.site.locale.replace('_', '-'));
17
+ const number = new Intl.NumberFormat(siteLocale);
18
18
  const chart = block.type === 'chart' ? chartGeometry(block) : undefined;
19
19
  const unit = block.type === 'chart' && block.unit ? ` ${block.unit}` : '';
20
20
  const columnTitle = (index: number) => {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  // Photos in the grid everyone knows from their phone, in a box that scrolls.
3
3
  // Each tile opens its post as a popover - the browser does that, no script.
4
- import { config } from '../dist/config.js';
4
+ import { config, siteLocale } from '../dist/config.js';
5
5
  import { longDate, parseIsoDate } from '../dist/date.js';
6
6
  import { publicImage } from '../dist/image-size.js';
7
7
 
@@ -34,7 +34,7 @@ const {
34
34
  square = false,
35
35
  plain = false,
36
36
  closeLabel = german ? 'Schließen' : 'Close',
37
- locale = 'de-DE',
37
+ locale = siteLocale,
38
38
  class: className,
39
39
  } = Astro.props;
40
40
  ---
@@ -36,9 +36,10 @@ const {
36
36
  className,
37
37
  ]}
38
38
  closedby="any"
39
+ aria-labelledby={`${id}-title`}
39
40
  >
40
41
  <div class="mw-modal-header">
41
- <h4 class="mw-modal-title">{title}</h4>
42
+ <h4 id={`${id}-title`} class="mw-modal-title">{title}</h4>
42
43
  <button type="button" class="mw-modal-close" aria-label={closeLabel}>
43
44
  &#120299;
44
45
  </button>
@@ -13,6 +13,8 @@ interface Props {
13
13
  // The address of a page, e.g. page => page === 1 ? '/blog' : `/blog/${page}`
14
14
  href: (page: number) => string;
15
15
  label?: string;
16
+ // `status` replaces {current} and {total}: "Seite {current} von {total}"
17
+ labels?: { previous?: string; next?: string; status?: string };
16
18
  class?: string;
17
19
  }
18
20
 
@@ -23,9 +25,16 @@ const {
23
25
  total,
24
26
  href,
25
27
  label = german ? 'Seiten' : 'Pages',
28
+ labels = {},
26
29
  class: className,
27
30
  } = Astro.props;
28
31
 
32
+ const {
33
+ previous: previousLabel = german ? 'Vorherige Seite' : 'Previous page',
34
+ next: nextLabel = german ? 'Nächste Seite' : 'Next page',
35
+ status = german ? 'Seite {current} von {total}' : 'Page {current} of {total}',
36
+ } = labels;
37
+
29
38
  const shown = [
30
39
  ...new Set([1, current - 1, current, current + 1, total]),
31
40
  ].filter(page => page >= 1 && page <= total);
@@ -38,16 +47,8 @@ const arrow = (page: number, arrowLabel: string, icon: string) => ({
38
47
  label: arrowLabel,
39
48
  icon,
40
49
  });
41
- const previous = arrow(
42
- current - 1,
43
- german ? 'Vorherige Seite' : 'Previous page',
44
- PACKAGE_ICONS['arrow-left']
45
- );
46
- const next = arrow(
47
- current + 1,
48
- german ? 'Nächste Seite' : 'Next page',
49
- PACKAGE_ICONS['arrow-right']
50
- );
50
+ const previous = arrow(current - 1, previousLabel, PACKAGE_ICONS['arrow-left']);
51
+ const next = arrow(current + 1, nextLabel, PACKAGE_ICONS['arrow-right']);
51
52
  ---
52
53
 
53
54
  <nav class:list={['mw-pagination-pages', className]} aria-label={label}>
@@ -60,7 +61,11 @@ const next = arrow(
60
61
  <Icon svg={previous.icon} size={16} />
61
62
  </a>
62
63
  <span class="mw-pagination-status">
63
- {german ? `Seite ${current} von ${total}` : `Page ${current} of ${total}`}
64
+ {
65
+ status
66
+ .replace('{current}', String(current))
67
+ .replace('{total}', String(total))
68
+ }
64
69
  </span>
65
70
  {
66
71
  pages.map(page =>
@@ -0,0 +1,80 @@
1
+ ---
2
+ // A picture band between two sections: the photo drifts slower than the page
3
+ // (mw-parallax), turned down when text stands on it. The browser's scroll
4
+ // timeline does the work - without one, or with reduced motion, the picture
5
+ // stands still. Deliberately without mw-parallax-slow: on a band flatter than
6
+ // the screen it opens a gap at the top.
7
+ //
8
+ // A bare <img> and not Picture: the framework styles mw-parallax-media as a
9
+ // direct child, which an <img> inside <picture> is not. WebP is safe in the
10
+ // srcset, every browser MaverickWave supports reads it.
11
+ import { withBase } from '../dist/path.js';
12
+
13
+ interface Props {
14
+ // As for Picture: without width and extension. Or the `media` slot with an
15
+ // element carrying mw-parallax-media.
16
+ image?: { src: string; alt?: string; widths?: readonly number[] };
17
+ title?: string;
18
+ text?: string;
19
+ level?: 'h2' | 'h3';
20
+ // On by default as soon as there is text - light text on a darkened photo
21
+ dimmed?: boolean;
22
+ align?: 'start' | 'center';
23
+ id?: string;
24
+ class?: string;
25
+ }
26
+
27
+ const {
28
+ image,
29
+ title,
30
+ text,
31
+ level: Heading = 'h2',
32
+ align = 'center',
33
+ id,
34
+ class: className,
35
+ } = Astro.props;
36
+
37
+ const hasContent = Boolean(title || text) || Astro.slots.has('default');
38
+ const { dimmed = hasContent } = Astro.props;
39
+ const widths = image?.widths ?? [800, 1200];
40
+ const file = (width: number, type: string) =>
41
+ withBase(`${image?.src}-${width}.${type}`);
42
+ ---
43
+
44
+ <section id={id} class={className}>
45
+ <div class:list={['mw-parallax', dimmed && 'mw-parallax-dimmed']}>
46
+ {
47
+ image ? (
48
+ <img
49
+ class="mw-parallax-media"
50
+ src={file(Math.max(...widths), 'jpg')}
51
+ srcset={widths
52
+ .map(width => `${file(width, 'webp')} ${width}w`)
53
+ .join(', ')}
54
+ sizes="100vw"
55
+ alt={image.alt ?? ''}
56
+ loading="lazy"
57
+ decoding="async"
58
+ />
59
+ ) : (
60
+ <slot name="media" />
61
+ )
62
+ }
63
+ {
64
+ hasContent && (
65
+ <div
66
+ class:list={[
67
+ 'mw-parallax-content',
68
+ align === 'center' && 'mw-text-center',
69
+ ]}
70
+ >
71
+ <div class="mw-container">
72
+ {title && <Heading class="mw-text-balance">{title}</Heading>}
73
+ {text && <p class="mw-text-measure mw-mx-auto">{text}</p>}
74
+ <slot />
75
+ </div>
76
+ </div>
77
+ )
78
+ }
79
+ </div>
80
+ </section>
@@ -33,7 +33,12 @@ const { slides, label, tall = false, gap, class: className } = Astro.props;
33
33
  className,
34
34
  ]}
35
35
  >
36
- <div class="mw-portrait-gallery-track" tabindex="0" aria-label={label}>
36
+ <div
37
+ class="mw-portrait-gallery-track"
38
+ tabindex="0"
39
+ role="region"
40
+ aria-label={label}
41
+ >
37
42
  {
38
43
  slides.map(slide => (
39
44
  <figure class="mw-portrait-gallery-slide">
@@ -2,13 +2,14 @@
2
2
  // A price, optionally with the discount of the promotion. Both amounts are in
3
3
  // the HTML and Schedule decides which one shows - without JavaScript the
4
4
  // regular price applies. 0 reads as free, any other text stays a word.
5
- import { config } from '../dist/config.js';
5
+ import { config, siteLocale } from '../dist/config.js';
6
6
  import type { Promo } from '../dist/schedule.js';
7
7
  import {
8
8
  discountedPrice,
9
9
  discountText,
10
10
  promoInHtml,
11
11
  } from '../dist/schedule.js';
12
+ import { priceParts } from '../dist/text.js';
12
13
 
13
14
  interface Props {
14
15
  amount: string | number;
@@ -45,6 +46,7 @@ const isNumber = String(amount).trim() !== '' && Number.isFinite(value);
45
46
  const isAmount = isNumber && value > 0;
46
47
  const word = isNumber ? free : amount;
47
48
  const withDiscount = isAmount && promoInHtml(promo);
49
+ const { whole, fraction } = priceParts(value, siteLocale);
48
50
  ---
49
51
 
50
52
  <p class:list={['mw-price', size && `mw-price-${size}`, className]}>
@@ -52,7 +54,8 @@ const withDiscount = isAmount && promoInHtml(promo);
52
54
  withDiscount && (
53
55
  <span class="mw-price-original mwa-promo-only">
54
56
  <span class="mw-sr-only">{regular}</span>
55
- {value} {currency}
57
+ {whole}
58
+ {fraction} {currency}
56
59
  </span>
57
60
  )
58
61
  }
@@ -60,14 +63,15 @@ const withDiscount = isAmount && promoInHtml(promo);
60
63
  {
61
64
  isAmount && (
62
65
  <span class:list={['mw-price-amount', withDiscount && 'mwa-no-promo']}>
63
- {value}
66
+ {whole}
67
+ {fraction && <span class="mw-price-fraction">{fraction}</span>}
64
68
  </span>
65
69
  )
66
70
  }
67
71
  {
68
72
  withDiscount && (
69
73
  <span class="mw-price-amount mwa-promo-only">
70
- {discountedPrice(promo, value)}
74
+ {priceParts(discountedPrice(promo, value), siteLocale).whole}
71
75
  </span>
72
76
  )
73
77
  }
@@ -2,6 +2,7 @@
2
2
  // Privacy policy from privacy.json: notice on top, then the controller and the
3
3
  // sections. A paragraph given as an object is one that has to stand out (right
4
4
  // to object under Art. 21 GDPR).
5
+ import { config } from '../dist/config.js';
5
6
  import PostalAddress from './PostalAddress.astro';
6
7
 
7
8
  type Paragraph = string | { text: string };
@@ -17,14 +18,18 @@ interface Props {
17
18
  address: { company?: string; name: string; street: string; city: string };
18
19
  mail: { href: string; text: string };
19
20
  updatedLabel?: string;
21
+ mailLabel?: string;
20
22
  classes?: { card?: string; highlight?: string };
21
23
  }
22
24
 
25
+ const german = config.site.lang.startsWith('de');
26
+
23
27
  const {
24
28
  privacy,
25
29
  address,
26
30
  mail,
27
- updatedLabel = 'Stand',
31
+ updatedLabel = german ? 'Stand' : 'Last updated',
32
+ mailLabel = german ? 'E-Mail' : 'Email',
28
33
  classes = {},
29
34
  } = Astro.props;
30
35
  const { controller } = privacy;
@@ -41,7 +46,7 @@ const { controller } = privacy;
41
46
  <h2>{controller.title}</h2>
42
47
  <p>{controller.intro}</p>
43
48
  <PostalAddress address={address} />
44
- <p>E-Mail: <a href={mail.href}>{mail.text}</a></p>
49
+ <p>{mailLabel}: <a href={mail.href}>{mail.text}</a></p>
45
50
  <p>{controller.explanation}</p>
46
51
 
47
52
  {
@@ -1,4 +1,5 @@
1
1
  ---
2
+ import { config, siteLocale } from '../dist/config.js';
2
3
  import type { Promo } from '../dist/schedule.js';
3
4
  import { discountText, promoInHtml, promoText } from '../dist/schedule.js';
4
5
  import Announcement from './Announcement.astro';
@@ -8,16 +9,26 @@ interface Props {
8
9
  href: string;
9
10
  // Append "bis DD.MM.YYYY" to the text.
10
11
  withEndDate?: boolean;
12
+ untilWord?: string;
11
13
  }
12
14
 
13
- const { promo, href, withEndDate = false } = Astro.props;
15
+ const {
16
+ promo,
17
+ href,
18
+ withEndDate = false,
19
+ untilWord = config.site.lang.startsWith('de') ? 'bis' : 'until',
20
+ } = Astro.props;
14
21
  ---
15
22
 
16
23
  {
17
24
  promoInHtml(promo) && (
18
25
  <Announcement
19
26
  highlight={discountText(promo)}
20
- text={withEndDate ? promoText(promo) : promo.text}
27
+ text={
28
+ withEndDate
29
+ ? promoText(promo, { locale: siteLocale, untilWord })
30
+ : promo.text
31
+ }
21
32
  href={href}
22
33
  class="mwa-promo-only"
23
34
  />
@@ -0,0 +1,43 @@
1
+ ---
2
+ // A read-only 0 to 5 on mw-rating - the markup of mw-rating in
3
+ // maverick-wave-angular. The figure is read out, the icons are decoration.
4
+ import { config } from '../dist/config.js';
5
+ import { PACKAGE_ICONS } from '../dist/icons.js';
6
+ import Icon from './Icon.astro';
7
+
8
+ interface Props {
9
+ value: number;
10
+ // {value} is replaced: "{value} von 5 Sternen"
11
+ label?: string;
12
+ size?: 'sm' | 'lg';
13
+ // Inner SVG on a 24 grid, a star unless given
14
+ icon?: string;
15
+ class?: string;
16
+ }
17
+
18
+ const german = config.site.lang.startsWith('de');
19
+
20
+ const {
21
+ value,
22
+ label = german ? '{value} von 5' : '{value} of 5',
23
+ size,
24
+ icon = PACKAGE_ICONS.star,
25
+ class: className,
26
+ } = Astro.props;
27
+
28
+ const rounded = Math.min(5, Math.max(0, Math.round(value)));
29
+ const iconSize = size === 'sm' ? 14 : size === 'lg' ? 26 : 20;
30
+ ---
31
+
32
+ <div
33
+ class:list={['mw-rating', size && `mw-rating-${size}`, className]}
34
+ data-rating={rounded}
35
+ role="img"
36
+ aria-label={label.replace('{value}', String(rounded))}
37
+ >
38
+ {
39
+ [1, 2, 3, 4, 5].map(() => (
40
+ <Icon svg={icon} size={iconSize} class="mw-rating-icon" />
41
+ ))
42
+ }
43
+ </div>
@@ -6,6 +6,9 @@ import '../styles/schedule.css';
6
6
  ---
7
7
 
8
8
  <script>
9
+ import { isoDate } from '../dist/date.js';
10
+ import { outOfSchedule } from '../dist/schedule.js';
11
+
9
12
  const html = document.documentElement;
10
13
  const now = new Date();
11
14
 
@@ -23,13 +26,7 @@ import '../styles/schedule.css';
23
26
  document
24
27
  .querySelectorAll<HTMLElement>('[data-starts], [data-expires]')
25
28
  .forEach(element => {
26
- const { starts, expires } = element.dataset;
27
- if (
28
- (expires && new Date(expires) < now) ||
29
- (starts && new Date(starts) > now)
30
- ) {
31
- element.remove();
32
- }
29
+ if (outOfSchedule(element.dataset, now)) element.remove();
33
30
  });
34
31
 
35
32
  // A list without remaining entries is replaced by the template right after
@@ -49,8 +46,7 @@ import '../styles/schedule.css';
49
46
 
50
47
  // The build only knows its own day - "today" in a calendar or on a date
51
48
  // stamp moves along here.
52
- const pad = (value: number) => String(value).padStart(2, '0');
53
- const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
49
+ const today = isoDate(now);
54
50
  document.querySelectorAll<HTMLElement>('[data-day]').forEach(day => {
55
51
  const mark = day.classList.contains('mw-date-stamp')
56
52
  ? 'mw-date-stamp-today'
@@ -0,0 +1,134 @@
1
+ ---
2
+ // The start page without parallax: text on one side, a photo on the other -
3
+ // for a person, a workshop, a product that should be seen at once. Below md
4
+ // the two stack, text first. `reverse` puts the photo first, which on a phone
5
+ // also means on top. With level h2 the same split works further down a page.
6
+ // The badge is mw-badge-status - the hero's glass pill needs a dark picture.
7
+ import Picture from './Picture.astro';
8
+
9
+ interface Link {
10
+ href: string;
11
+ label: string;
12
+ }
13
+
14
+ interface Props {
15
+ id?: string;
16
+ titleStart?: string;
17
+ titleAccent?: string;
18
+ accent?: 'bold' | 'primary' | 'secondary';
19
+ text?: string;
20
+ features?: string;
21
+ badge?: { text: string; pulse?: boolean };
22
+ cta?: Link;
23
+ secondaryCta?: Link;
24
+ // As for Picture, loaded at once - it is the first thing on the page. Or the
25
+ // `media` slot.
26
+ image?: {
27
+ src: string;
28
+ alt: string;
29
+ widths?: readonly number[];
30
+ shape?: 'arch' | 'signature' | 'leaf';
31
+ };
32
+ reverse?: boolean;
33
+ level?: 'h1' | 'h2';
34
+ class?: string;
35
+ }
36
+
37
+ const {
38
+ id,
39
+ titleStart,
40
+ titleAccent,
41
+ accent = 'primary',
42
+ text,
43
+ features,
44
+ badge,
45
+ cta,
46
+ secondaryCta,
47
+ image,
48
+ reverse = false,
49
+ level: Heading = 'h1',
50
+ class: className,
51
+ } = Astro.props;
52
+
53
+ const order = reverse ? ['media', 'text'] : ['text', 'media'];
54
+ ---
55
+
56
+ <section id={id} class:list={['mw-section', className]}>
57
+ <div class="mw-container">
58
+ <div class="mw-grid-2-lg mw-grid-from-md mw-items-center">
59
+ {
60
+ order.map(part =>
61
+ part === 'media' ? (
62
+ <div>
63
+ {image ? (
64
+ <Picture
65
+ src={image.src}
66
+ alt={image.alt}
67
+ sizes="(min-width: 768px) 50vw, 100vw"
68
+ widths={image.widths ?? [500, 1000]}
69
+ shape={image.shape ?? 'signature'}
70
+ eager
71
+ />
72
+ ) : (
73
+ <slot name="media" />
74
+ )}
75
+ </div>
76
+ ) : (
77
+ <div>
78
+ {badge && (
79
+ <p class="mw-badge-status mw-badge-status-secondary mw-mb-6">
80
+ <span
81
+ class:list={[
82
+ 'mw-badge-dot',
83
+ badge.pulse && 'mw-badge-pulse',
84
+ ]}
85
+ />
86
+ {badge.text}
87
+ </p>
88
+ )}
89
+ <slot name="kicker" />
90
+ {Astro.slots.has('title') ? (
91
+ <Heading class="mw-mb-6">
92
+ <slot name="title" />
93
+ </Heading>
94
+ ) : (
95
+ <Heading class="mw-mb-6 mw-text-balance">
96
+ {titleStart}
97
+ {titleAccent && (
98
+ <>
99
+ {' '}
100
+ <span class={`mw-text-${accent}`}>{titleAccent}</span>
101
+ </>
102
+ )}
103
+ </Heading>
104
+ )}
105
+ {text && (
106
+ <p class="mw-text-lg mw-text-measure mw-text-pretty">{text}</p>
107
+ )}
108
+ {features && <p class="mw-text-muted">{features}</p>}
109
+ {(cta || secondaryCta) && (
110
+ <div class="mw-d-flex mw-flex-wrap mw-gap-4 mw-mt-7">
111
+ {cta && (
112
+ <a class="mw-btn mw-btn-primary mw-btn-lg" href={cta.href}>
113
+ <slot name="cta-icon" />
114
+ {cta.label}
115
+ </a>
116
+ )}
117
+ {secondaryCta && (
118
+ <a
119
+ class="mw-btn mw-btn-outline mw-btn-lg"
120
+ href={secondaryCta.href}
121
+ >
122
+ {secondaryCta.label}
123
+ <slot name="secondary-icon" />
124
+ </a>
125
+ )}
126
+ </div>
127
+ )}
128
+ </div>
129
+ )
130
+ )
131
+ }
132
+ </div>
133
+ </div>
134
+ </section>
@@ -32,7 +32,7 @@ const {
32
32
  } = Astro.props;
33
33
  ---
34
34
 
35
- <div class:list={['mw-stories', className]} aria-label={label}>
35
+ <div class:list={['mw-stories', className]} role="group" aria-label={label}>
36
36
  {
37
37
  stories.map(story => (
38
38
  <>
@@ -5,7 +5,7 @@
5
5
  // owner's tool, not a page of the homepage.
6
6
  import '../styles/story-cards.css';
7
7
 
8
- import { config } from '../dist/config.js';
8
+ import { config, siteLocale } from '../dist/config.js';
9
9
  import { PACKAGE_ICONS } from '../dist/icons.js';
10
10
  import { withBase } from '../dist/path.js';
11
11
  import {
@@ -108,8 +108,8 @@ const eventStories = upcomingEvents(events).map((entry): Story => ({
108
108
  card: {
109
109
  kind: 'event',
110
110
  title: entry.title,
111
- date: eventDateText(entry),
112
- stamp: storyDate(entry.date),
111
+ date: eventDateText(entry, siteLocale),
112
+ stamp: storyDate(entry.date, siteLocale),
113
113
  time: entry.time,
114
114
  location: entry.location,
115
115
  price: entry.price !== undefined ? String(entry.price) : undefined,
@@ -132,11 +132,14 @@ const promoStories: Story[] =
132
132
  kind: 'promo',
133
133
  percent: discountText(promo),
134
134
  title: promo.text,
135
- until: promoEndDate(promo),
135
+ until: promoEndDate(promo, siteLocale),
136
136
  untilIso: promo.until,
137
137
  offers: discounted,
138
138
  },
139
- label: promoText(promo),
139
+ label: promoText(promo, {
140
+ locale: siteLocale,
141
+ untilWord: german ? 'bis' : 'until',
142
+ }),
140
143
  file: storyFileName(
141
144
  site,
142
145
  german ? 'rabatt' : 'promo',
@@ -208,6 +211,7 @@ const look: LookOptions = {
208
211
  </div>
209
212
 
210
213
  <script>
214
+ import { outOfSchedule } from '../dist/schedule.js';
211
215
  import {
212
216
  HEIGHT,
213
217
  loadLook,
@@ -226,15 +230,9 @@ const look: LookOptions = {
226
230
  // As on the start page: expired events and promotions drop out in the
227
231
  // browser, promotions that have not started yet as well - no deployment
228
232
  // needed for that.
229
- const { starts, expires } = el.dataset;
230
- if (
231
- (expires && new Date(expires) < now) ||
232
- (starts && new Date(starts) > now)
233
- ) {
234
- el.remove();
235
- return false;
236
- }
237
- return true;
233
+ if (!outOfSchedule(el.dataset, now)) return true;
234
+ el.remove();
235
+ return false;
238
236
  });
239
237
 
240
238
  if (root && stories.length === 0) {
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  // A quote with its source. featured stands above the grid, the rest go into
3
3
  // mw-columns-3. A date ages the quote - only where the voices stay fresh.
4
+ import { siteLocale } from '../dist/config.js';
5
+
4
6
  interface Props {
5
7
  quote: string;
6
8
  name: string;
@@ -17,7 +19,7 @@ const {
17
19
  name,
18
20
  detail,
19
21
  date,
20
- locale = 'de-DE',
22
+ locale = siteLocale,
21
23
  featured = false,
22
24
  class: className,
23
25
  } = Astro.props;
package/dist/config.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import config from 'virtual:maverick-wave-astro/config';
2
2
  export { config };
3
+ export declare const siteLocale: any;
3
4
  export declare const headerReveals: () => boolean;
package/dist/config.js CHANGED
@@ -3,4 +3,6 @@
3
3
  import config from 'virtual:maverick-wave-astro/config';
4
4
  import { headerReveals as reveals } from "./design.js";
5
5
  export { config };
6
+ // "de-DE" for Intl - the config carries Open Graph's "de_DE".
7
+ export const siteLocale = config.site.locale.replace('_', '-');
6
8
  export const headerReveals = () => reveals(config.design);
package/dist/deck.js CHANGED
@@ -39,6 +39,10 @@ export const inlineSvg = (publicPath, { className, label }) => {
39
39
  if (!/<svg\b/.test(source)) {
40
40
  throw new Error(`Deck: drawing ${publicPath} holds no <svg>`);
41
41
  }
42
+ // The CSP drops both, and the drawing would lose its colours without a word
43
+ if (/<style\b|\sstyle\s*=/i.test(source)) {
44
+ throw new Error(`Deck: drawing ${publicPath} carries CSS - set fill and stroke as attributes`);
45
+ }
42
46
  const quote = (value) => value.replace(/&/g, '&amp;').replace(/"/g, '&quot;');
43
47
  return source.replace(/<svg\b([^>]*)>/, (_, attributes) => {
44
48
  const kept = attributes
package/dist/design.d.ts CHANGED
@@ -117,6 +117,11 @@ export declare const VARIANTS: {
117
117
  readonly className: "mw-motion-off";
118
118
  };
119
119
  };
120
+ readonly headerShape: {
121
+ readonly bar: {
122
+ readonly className: "mw-header-bar";
123
+ };
124
+ };
120
125
  readonly sections: {
121
126
  readonly plain: {
122
127
  readonly className: "mw-sections-plain";
@@ -158,6 +163,7 @@ export declare const DEFAULTS: {
158
163
  readonly width: "default";
159
164
  readonly hover: "animated";
160
165
  readonly motion: "default";
166
+ readonly headerShape: "island";
161
167
  readonly sections: "patterned";
162
168
  readonly scrollEffects: "on";
163
169
  readonly spacing: "default";
package/dist/design.js CHANGED
@@ -54,6 +54,7 @@ export const VARIANTS = {
54
54
  relaxed: { property: '--mw-motion-scale', value: '1.6' },
55
55
  off: { className: 'mw-motion-off' },
56
56
  },
57
+ headerShape: { bar: { className: 'mw-header-bar' } },
57
58
  sections: { plain: { className: 'mw-sections-plain' } },
58
59
  scrollEffects: { off: { className: 'mw-scroll-static' } },
59
60
  spacing: {
@@ -88,6 +89,7 @@ export const DEFAULTS = {
88
89
  width: 'default',
89
90
  hover: 'animated',
90
91
  motion: 'default',
92
+ headerShape: 'island',
91
93
  sections: 'patterned',
92
94
  scrollEffects: 'on',
93
95
  spacing: 'default',
package/dist/icons.d.ts CHANGED
@@ -16,5 +16,6 @@ export declare const PACKAGE_ICONS: {
16
16
  readonly mail: "<rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2.4\"/><path d=\"m3.5 6.5 8.5 6.5 8.5-6.5\"/>";
17
17
  readonly 'calendar-check': "<rect x=\"3\" y=\"5\" width=\"18\" height=\"16\" rx=\"2.4\"/><path d=\"M3 10h18M8 3v4M16 3v4M9 15.5l2 2 4-4\"/>";
18
18
  readonly sparkle: "<path d=\"M12 2.8 13.9 9l6.2 1.9-6.2 1.9L12 19l-1.9-6.2L3.9 10.9 10.1 9 12 2.8Z\"/><path d=\"M19 16.5l.7 2.2 2.2.7-2.2.7-.7 2.2-.7-2.2-2.2-.7 2.2-.7.7-2.2Z\"/>";
19
+ readonly star: "<path d=\"m12 3.8 2.5 5.1 5.6.8-4 4 .9 5.6L12 16.6l-5 2.7.9-5.6-4-4 5.6-.8Z\"/>";
19
20
  readonly 'panel-right': "<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\" rx=\"2.4\"/><path d=\"M15 4v16\"/>";
20
21
  };
package/dist/icons.js CHANGED
@@ -18,5 +18,6 @@ export const PACKAGE_ICONS = {
18
18
  mail: '<rect x="3" y="5" width="18" height="14" rx="2.4"/><path d="m3.5 6.5 8.5 6.5 8.5-6.5"/>',
19
19
  'calendar-check': '<rect x="3" y="5" width="18" height="16" rx="2.4"/><path d="M3 10h18M8 3v4M16 3v4M9 15.5l2 2 4-4"/>',
20
20
  sparkle: '<path d="M12 2.8 13.9 9l6.2 1.9-6.2 1.9L12 19l-1.9-6.2L3.9 10.9 10.1 9 12 2.8Z"/><path d="M19 16.5l.7 2.2 2.2.7-2.2.7-.7 2.2-.7-2.2-2.2-.7 2.2-.7.7-2.2Z"/>',
21
+ star: '<path d="m12 3.8 2.5 5.1 5.6.8-4 4 .9 5.6L12 16.6l-5 2.7.9-5.6-4-4 5.6-.8Z"/>',
21
22
  'panel-right': '<rect x="3" y="4" width="18" height="16" rx="2.4"/><path d="M15 4v16"/>',
22
23
  };
@@ -95,6 +95,9 @@ export default function homepage(options) {
95
95
  name: 'maverick-wave-astro',
96
96
  hooks: {
97
97
  'astro:config:setup': async ({ config: astroConfig, updateConfig, injectRoute, injectScript, addWatchFile, logger, }) => {
98
+ // The schedule works in local time (schedule.ts) - on a build box in
99
+ // UTC a promotion would start at two in the morning.
100
+ process.env.TZ ??= 'Europe/Berlin';
98
101
  const root = fileURLToPath(astroConfig.root);
99
102
  // Before any page renders: Picture reads the sizes from public/.
100
103
  const publicDir = fileURLToPath(astroConfig.publicDir);
@@ -5,6 +5,10 @@ export type ScheduledEvent = {
5
5
  date: string;
6
6
  time?: string;
7
7
  };
8
+ export declare const outOfSchedule: ({ starts, expires }: {
9
+ starts?: string;
10
+ expires?: string;
11
+ }, now?: Date) => boolean;
8
12
  export declare const upcomingEvents: <T extends ScheduledEvent>(entries: readonly T[], now?: Date) => T[];
9
13
  export declare const eventExpiry: (entry: ScheduledEvent) => string;
10
14
  export declare const eventDateText: (entry: ScheduledEvent, locale?: string) => string;
package/dist/schedule.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // The build picks events and promotions, the browser checks them again
2
2
  // (components/Schedule.astro) - so both disappear on time instead of with the
3
3
  // next build. All calculations run in local time, so the build needs
4
- // TZ=Europe/Berlin.
4
+ // TZ=Europe/Berlin - the integration sets it unless the environment does.
5
+ import { addDays, isoDate, parseIsoDate } from "./date.js";
5
6
  // End of the given day, because an event is valid until its day is over.
6
7
  export const endOfDay = (date) => {
7
8
  const day = new Date(`${date}T23:59:59`);
@@ -17,6 +18,9 @@ export const visibleUntil = (date) => {
17
18
  day.setHours(day.getHours() + GRACE_HOURS);
18
19
  return day;
19
20
  };
21
+ // The browser's half: data-starts and data-expires on an element, read by
22
+ // Schedule and StoryCards.
23
+ export const outOfSchedule = ({ starts, expires }, now = new Date()) => Boolean((expires && new Date(expires) < now) || (starts && new Date(starts) > now));
20
24
  // Free text instead of a date stays - an unusual format beats a swallowed
21
25
  // event.
22
26
  export const upcomingEvents = (entries, now = new Date()) => entries
@@ -75,8 +79,9 @@ export const promoStart = (promo, now = new Date()) => {
75
79
  // Thin space between number and percent sign, as typesetting wants it.
76
80
  export const discountText = (promo) => `-${Number(promo.percent)}\u2009%`;
77
81
  // Always rounded down: rounding up would give customers less than the
78
- // promised percentage.
79
- export const discountedPrice = (promo, amount) => Math.floor(amount * (1 - Number(promo.percent) / 100));
82
+ // promised percentage. In whole cents, because 90 * 0.7 is 62.999... in
83
+ // floating point.
84
+ export const discountedPrice = (promo, amount) => Math.floor((Math.round(amount * 100) * (100 - Number(promo.percent))) / 10_000);
80
85
  // Last day of the promotion, formatted. Null means open-ended.
81
86
  export const promoEndDate = (promo, locale = 'de-DE') => {
82
87
  const end = promo.until ? endOfDay(promo.until) : null;
@@ -112,6 +117,11 @@ export const eventTimeRange = (entry) => {
112
117
  const zone = offset(entry.date);
113
118
  return {
114
119
  start: `${entry.date}T${times[0]}:00${zone}`,
115
- end: times[1] ? `${entry.date}T${times[1]}:00${zone}` : null,
120
+ end: times[1] ? eventEnd(entry.date, times[0], times[1]) : null,
116
121
  };
117
122
  };
123
+ // "20:00 - 02:00" ends on the next day.
124
+ const eventEnd = (date, start, end) => {
125
+ const day = end > start ? date : isoDate(addDays(parseIsoDate(date), 1));
126
+ return `${day}T${end}:00${offset(day)}`;
127
+ };
@@ -3,6 +3,7 @@
3
3
  // promotion turns into a story without a field of its own.
4
4
  import { parseIsoDate } from "../date.js";
5
5
  import { discountedPrice, } from "../schedule.js";
6
+ import { slug } from "../text.js";
6
7
  const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
7
8
  // Day, month and weekday for the calendar tile. A date like "Frühjahr 2027"
8
9
  // gets none and keeps its text.
@@ -39,14 +40,6 @@ export const promoOffers = (promo, offers) => offers
39
40
  // chat, so it says whose it is and what it shows. Each part stops at 50
40
41
  // characters, so a long title still leaves the date in view.
41
42
  export const storyFileName = (...parts) => parts
42
- .map(part => part
43
- .toLowerCase()
44
- .replace(/ä/g, 'ae')
45
- .replace(/ö/g, 'oe')
46
- .replace(/ü/g, 'ue')
47
- .replace(/ß/g, 'ss')
48
- .replace(/[^a-z0-9]+/g, '-')
49
- .slice(0, 50)
50
- .replace(/^-+|-+$/g, ''))
43
+ .map(part => slug(part).slice(0, 50).replace(/-+$/, ''))
51
44
  .filter(Boolean)
52
45
  .join('-');
package/dist/text.d.ts CHANGED
@@ -3,3 +3,7 @@ export declare const markdown: (value: string | undefined) => string;
3
3
  /** A title as a URL segment: "Über den Tellerrand" becomes "ueber-den-tellerrand". */
4
4
  export declare const slug: (value: string) => string;
5
5
  export declare const readingTime: (body: string | undefined) => number;
6
+ export declare const priceParts: (amount: number, locale: string) => {
7
+ whole: string;
8
+ fraction: string;
9
+ };
package/dist/text.js CHANGED
@@ -83,3 +83,19 @@ export const readingTime = (body) => {
83
83
  const words = (body ?? '').trim().split(/\s+/).length;
84
84
  return Math.max(1, Math.round(words / WORDS_PER_MINUTE));
85
85
  };
86
+ // "1.290" or "129" and ",90" apart - MaverickWave sets the cents a step down.
87
+ // A whole amount keeps no ",00".
88
+ export const priceParts = (amount, locale) => {
89
+ const parts = new Intl.NumberFormat(locale, {
90
+ minimumFractionDigits: Number.isInteger(amount) ? 0 : 2,
91
+ maximumFractionDigits: 2,
92
+ }).formatToParts(amount);
93
+ const decimal = parts.findIndex(part => part.type === 'decimal');
94
+ const join = (list) => list.map(part => part.value).join('');
95
+ return decimal === -1
96
+ ? { whole: join(parts), fraction: '' }
97
+ : {
98
+ whole: join(parts.slice(0, decimal)),
99
+ fraction: join(parts.slice(decimal)),
100
+ };
101
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maverick-wave-astro",
3
- "version": "1.12.0",
3
+ "version": "1.13.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",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "peerDependencies": {
54
54
  "astro": "^7.2.0",
55
- "maverick-wave": "^6.6.0"
55
+ "maverick-wave": "^6.7.0"
56
56
  },
57
57
  "dependencies": {
58
58
  "@astrojs/sitemap": "^3.7.3",
@@ -67,7 +67,7 @@
67
67
  "eslint-plugin-astro": "^1.5.0",
68
68
  "eslint-plugin-simple-import-sort": "^12.1.1",
69
69
  "globals": "^16.5.0",
70
- "maverick-wave": "^6.6.0",
70
+ "maverick-wave": "^6.7.0",
71
71
  "prettier": "^3.6.2",
72
72
  "prettier-plugin-astro": "^0.14.1",
73
73
  "typescript": "^6.0.3",
@@ -190,6 +190,17 @@
190
190
  },
191
191
  "x-empty": "Wie eingerichtet"
192
192
  },
193
+ "headerShape": {
194
+ "title": "Form der Kopfzeile",
195
+ "description": "Insel: die Kopfzeile schwebt abgerundet über der Seite. Leiste: über die volle Breite oben fest, sie blendet sich nie ein.",
196
+ "type": "string",
197
+ "enum": ["island", "bar"],
198
+ "x-labels": {
199
+ "island": "Schwebende Insel",
200
+ "bar": "Leiste"
201
+ },
202
+ "x-empty": "Wie eingerichtet"
203
+ },
193
204
  "sections": {
194
205
  "title": "Abschnitte",
195
206
  "description": "Das feine Streifenmuster hinter jedem zweiten Abschnitt.",