maverick-wave-astro 1.11.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.
Files changed (43) hide show
  1. package/README.md +4 -3
  2. package/components/Accordion.astro +4 -5
  3. package/components/AppShell.astro +12 -7
  4. package/components/BlogPost.astro +2 -2
  5. package/components/Calendar.astro +10 -3
  6. package/components/Chat.astro +2 -4
  7. package/components/DateStamp.astro +2 -1
  8. package/components/DeckBlock.astro +2 -2
  9. package/components/Feed.astro +2 -2
  10. package/components/Modal.astro +2 -1
  11. package/components/Pagination.astro +16 -11
  12. package/components/Parallax.astro +80 -0
  13. package/components/PortraitGallery.astro +6 -1
  14. package/components/Price.astro +8 -4
  15. package/components/PrivacyCard.astro +7 -2
  16. package/components/PromoBar.astro +13 -2
  17. package/components/Rating.astro +43 -0
  18. package/components/Schedule.astro +5 -9
  19. package/components/SplitHero.astro +134 -0
  20. package/components/Stories.astro +1 -1
  21. package/components/StoryCards.astro +41 -15
  22. package/components/Testimonial.astro +3 -1
  23. package/dist/config.d.ts +1 -0
  24. package/dist/config.js +2 -0
  25. package/dist/deck.js +4 -0
  26. package/dist/design.d.ts +6 -0
  27. package/dist/design.js +2 -0
  28. package/dist/icons.d.ts +1 -0
  29. package/dist/icons.js +1 -0
  30. package/dist/integration.js +3 -0
  31. package/dist/schedule.d.ts +4 -0
  32. package/dist/schedule.js +14 -4
  33. package/dist/story/base.d.ts +66 -21
  34. package/dist/story/base.js +372 -90
  35. package/dist/story/cards.d.ts +12 -1
  36. package/dist/story/cards.js +26 -9
  37. package/dist/story/event.js +127 -105
  38. package/dist/story/promo.d.ts +1 -1
  39. package/dist/story/promo.js +126 -94
  40. package/dist/text.d.ts +4 -0
  41. package/dist/text.js +16 -0
  42. package/package.json +3 -3
  43. package/schemas/design.schema.json +11 -0
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'