@semics-tech/emdash-events 1.0.0-rc.2 → 1.0.0-rc.22

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.
@@ -6,6 +6,7 @@
6
6
  import { pluginId } from "virtual:semics-events/config";
7
7
 
8
8
  import { pickLocale, translator } from "../i18n/index";
9
+ import { bookAnchor, presetTicketType, presetVoucher } from "./lib/book-link";
9
10
  import { callPublicRoute } from "./lib/call";
10
11
  import { CHECKOUT_PATH, QTY_PREFIX } from "./lib/checkout-form";
11
12
  import { pickerFetchFrom, pickerHref, pickerParam, pickerView, usesPicker } from "./lib/picker";
@@ -20,6 +21,7 @@ import {
20
21
  newIdempotencyKey,
21
22
  type PublicEvent,
22
23
  readWidgetState,
24
+ requestDates,
23
25
  safeReturnTo,
24
26
  type WidgetField,
25
27
  } from "./lib/widget";
@@ -61,6 +63,9 @@ const id = anchorId(eventId);
61
63
  // Promo codes are Events Pro's (T078): the field shows only when the core says it takes them. An
62
64
  // applied code lives in an HttpOnly cookie (`/_events/promo`), never the URL, and is checked again here.
63
65
  const takesCodes = data?.promoCodes === true;
66
+ // Gift vouchers (T166): only Events Pro paired with Vouchers says so. The code goes with the order; the
67
+ // checkout holds it with Vouchers between reserve and continue, and never puts it in a URL.
68
+ const takesVouchers = data?.vouchers === true;
64
69
  let promo: PromoView | null = Astro.props.promo ?? null;
65
70
  if (takesCodes && Astro.props.promo === undefined) {
66
71
  let code = "";
@@ -82,13 +87,37 @@ const ticketTypes = [
82
87
  ...(data?.ticketTypes ?? []),
83
88
  ...(takesCodes ? (promo?.hiddenTypes ?? []) : []).filter((t) => !listed.has(t.id)),
84
89
  ] as PublicEvent["ticketTypes"];
85
- const onSale = data?.status === "on_sale" && ticketTypes.length > 0;
90
+ // Per-person add-ons (Events Pro, T174d) are not places: listed under the tickets, capped by the places chosen.
91
+ const placeTypes = ticketTypes.filter((t) => !t.addon);
92
+ const addonTypes = ticketTypes.filter((t) => t.addon);
93
+ const onSale = data?.status === "on_sale" && placeTypes.length > 0;
94
+ // "Book with this voucher" (T171): the voucher page left the code in an HttpOnly cookie (never a URL) and may
95
+ // name a ticket type, which starts at one ticket. A page that filled in a code must not be cached.
96
+ let presetCode = "";
97
+ if (takesVouchers) {
98
+ presetCode = presetVoucher(Astro.cookies);
99
+ if (presetCode) {
100
+ try {
101
+ Astro.response.headers.set("Cache-Control", "private, no-store");
102
+ } catch {
103
+ // Headers already sent: the cookie only reaches the buyer who has it.
104
+ }
105
+ }
106
+ }
107
+ const presetType = presetTicketType(
108
+ Astro.url,
109
+ ticketTypes.filter((t) => t.available !== 0).map((t) => t.id),
110
+ );
86
111
  // Many dates a day, or a slot schedule (T130): a month calendar of days, then the day's times. Without
87
112
  // JavaScript the same month's dates show as a select grouped by day.
88
113
  const zone = data?.timezone ?? "UTC";
89
114
  const picker = usesPicker(data, zone)
90
115
  ? pickerView(occurrences, { zone, locale, start: pickerStart, now: Date.now(), more: data?.more === true })
91
116
  : null;
117
+ // Booking requests (T174a): the dates the event takes (allowed weekdays, notice, days ahead, not closed) as a
118
+ // select that works without JavaScript, then the time windows as radios; the form posts `request`.
119
+ const requests = data?.requests;
120
+ const requestDays = requests ? requestDates(requests, zone, Date.now(), locale) : [];
92
121
  const pickerIds = new Set(picker?.days.flatMap((d) => d.slots.map((s) => s.id)));
93
122
  const monthId = `${id}-month`;
94
123
  // The waitlist (T081): offered when the core takes one and the tickets, or some dates, are sold out.
@@ -96,8 +125,8 @@ const fullDates = occurrences.filter((o) => o.available === 0 && (!picker || pic
96
125
  const waitlist =
97
126
  onSale &&
98
127
  data?.waitlist === true &&
99
- (ticketTypes.every((t) => t.available === 0) || fullDates.length > 0);
100
- const waitlistDates = ticketTypes.every((t) => t.available === 0)
128
+ (placeTypes.every((t) => t.available === 0) || fullDates.length > 0);
129
+ const waitlistDates = placeTypes.every((t) => t.available === 0)
101
130
  ? occurrences.filter((o) => !picker || pickerIds.has(o.id))
102
131
  : fullDates;
103
132
  const waitlistOutcome = readWaitlistState(Astro.url, eventId);
@@ -130,6 +159,7 @@ const when = (iso: string) => {
130
159
  </form>
131
160
  )}
132
161
  <form
162
+ id={bookAnchor(eventId)}
133
163
  method="post"
134
164
  action={CHECKOUT_PATH}
135
165
  data-semics-booking
@@ -140,6 +170,11 @@ const when = (iso: string) => {
140
170
  data-turnstile-message={siteKey ? t("widget.turnstile") : undefined}
141
171
  >
142
172
  <p class="semics-form-alert" role="alert" data-form-alert hidden={!formAlert}>{formAlert}</p>
173
+ {takesVouchers && (
174
+ <p class="semics-have-voucher">
175
+ <a href={`#${id}-voucher`} data-testid="have-voucher">{t("widget.voucher.have")}</a>
176
+ </p>
177
+ )}
143
178
  <input type="hidden" name="eventId" value={eventId} />
144
179
  <input type="hidden" name="returnTo" value={returnTo} />
145
180
  <input type="hidden" name="idempotencyKey" value={newIdempotencyKey()} />
@@ -181,7 +216,7 @@ const when = (iso: string) => {
181
216
  aria-invalid={invalid("occurrence")}
182
217
  aria-describedby={errId("occurrence")}
183
218
  >
184
- <legend>{t("widget.date")}</legend>
219
+ <legend class="semics-visually-hidden">{t("widget.date")}</legend>
185
220
  <table role="grid" class="semics-calendar" aria-labelledby={monthId}>
186
221
  <thead>
187
222
  <tr>
@@ -267,6 +302,38 @@ const when = (iso: string) => {
267
302
  </div>
268
303
  )}
269
304
 
305
+ {requests && (
306
+ <>
307
+ <div class="semics-field">
308
+ <input type="hidden" name="needsRequest" value="1" />
309
+ <label for={`${id}-occurrence`}>{t("widget.date")}</label>
310
+ <select
311
+ id={`${id}-occurrence`}
312
+ name="requestDate"
313
+ required
314
+ data-field="occurrence"
315
+ aria-invalid={invalid("occurrence")}
316
+ aria-describedby={errId("occurrence")}
317
+ >
318
+ <option value="">{t("widget.chooseDate")}</option>
319
+ {requestDays.map((d) => <option value={d.value}>{d.label}</option>)}
320
+ </select>
321
+ <p class="semics-field-error" id={errId("occurrence")} data-error-for="occurrence" data-message={fieldText("occurrence")}>
322
+ {bad("occurrence") ? fieldText("occurrence") : ""}
323
+ </p>
324
+ </div>
325
+ <fieldset class="semics-windows" data-testid="booking-windows">
326
+ <legend>{t("widget.window")}</legend>
327
+ {requests.windows.map((w) => (
328
+ <div class="semics-field semics-check">
329
+ <input id={`${id}-window-${w.id}`} type="radio" name="requestWindow" value={w.id} required checked={requests.windows.length === 1} />
330
+ <label for={`${id}-window-${w.id}`}>{w.label} ({w.start}–{w.end})</label>
331
+ </div>
332
+ ))}
333
+ </fieldset>
334
+ </>
335
+ )}
336
+
270
337
  {takesCodes && (
271
338
  <div class="semics-field semics-promo">
272
339
  {promo && <input type="hidden" name="promoCode" value={promo.code} />}
@@ -301,9 +368,31 @@ const when = (iso: string) => {
301
368
  </div>
302
369
  )}
303
370
 
371
+ {takesVouchers && (
372
+ <div class="semics-field semics-voucher">
373
+ <label for={`${id}-voucher`}>{t("widget.voucher.label")}</label>
374
+ <input
375
+ id={`${id}-voucher`}
376
+ name="voucherCode"
377
+ type="text"
378
+ autocomplete="off"
379
+ autocapitalize="characters"
380
+ spellcheck="false"
381
+ maxlength="64"
382
+ value={presetCode || undefined}
383
+ data-field="voucher"
384
+ aria-invalid={invalid("voucher")}
385
+ aria-describedby={errId("voucher")}
386
+ />
387
+ <p class="semics-field-error" id={errId("voucher")} data-error-for="voucher" data-message={fieldText("voucher")}>
388
+ {bad("voucher") ? fieldText("voucher") : ""}
389
+ </p>
390
+ </div>
391
+ )}
392
+
304
393
  <fieldset class="semics-tickets" data-field="tickets" aria-invalid={invalid("tickets")} aria-describedby={errId("tickets")}>
305
394
  <legend>{t("widget.tickets")}</legend>
306
- {ticketTypes.map((type) => {
395
+ {placeTypes.map((type) => {
307
396
  const soldOut = type.available === 0;
308
397
  const max = Math.min(type.maxPerOrder ?? 50, type.available ?? 50, 50);
309
398
  return (
@@ -318,7 +407,7 @@ const when = (iso: string) => {
318
407
  type="number"
319
408
  inputmode="numeric"
320
409
  name={`${QTY_PREFIX}${type.id}`}
321
- value="0"
410
+ value={type.id === presetType ? "1" : "0"}
322
411
  min="0"
323
412
  max={String(max)}
324
413
  disabled={soldOut}
@@ -332,6 +421,39 @@ const when = (iso: string) => {
332
421
  </p>
333
422
  </fieldset>
334
423
 
424
+ {addonTypes.length > 0 && (
425
+ <fieldset class="semics-tickets" data-testid="booking-addons">
426
+ <legend>{t("widget.addons")}</legend>
427
+ <p class="semics-hint">{t("widget.addonsHint")}</p>
428
+ {addonTypes.map((type) => {
429
+ const soldOut = type.available === 0;
430
+ const max = Math.min(type.maxPerOrder ?? 50, type.available ?? 50, 50);
431
+ return (
432
+ <div class="semics-ticket">
433
+ <label for={`${id}-qty-${type.id}`}>
434
+ <span class="semics-ticket-name">{type.name}</span>
435
+ <span class="semics-ticket-price">{t("widget.addonPrice", { price: formatMoney(type.priceMinor, data?.currency ?? "GBP", locale) })}</span>
436
+ {soldOut && <span class="semics-ticket-soldout">{t("widget.soldOut")}</span>}
437
+ </label>
438
+ <input
439
+ id={`${id}-qty-${type.id}`}
440
+ type="number"
441
+ inputmode="numeric"
442
+ name={`${QTY_PREFIX}${type.id}`}
443
+ value="0"
444
+ min="0"
445
+ max={String(max)}
446
+ disabled={soldOut}
447
+ data-addon=""
448
+ data-max={String(max)}
449
+ data-price-minor={String(type.priceMinor)}
450
+ />
451
+ </div>
452
+ );
453
+ })}
454
+ </fieldset>
455
+ )}
456
+
335
457
  <div class="semics-field">
336
458
  <label for={`${id}-name`}>{t("widget.name")}</label>
337
459
  <input
@@ -439,9 +561,9 @@ const when = (iso: string) => {
439
561
 
440
562
  {siteKey && (
441
563
  <>
442
- <div class="cf-turnstile" data-sitekey={siteKey}></div>
443
- {/* Turnstile is 300 px wide; in a narrower widget use its compact size so a 320 px screen never scrolls sideways (WCAG 1.4.10). */}
444
- <script is:inline>(function (s) { var t = s && s.previousElementSibling; if (t && t.clientWidth < 300) t.setAttribute("data-size", "compact"); })(document.currentScript);</script>
564
+ <div class="cf-turnstile" data-sitekey={siteKey} data-theme="light"></div>
565
+ {/* Turnstile is 300 px wide: compact when the form has less room, so a 320 px screen never scrolls sideways (WCAG 1.4.10). The form is measured, not the empty box; a form not laid out yet (0 px) falls back to the screen less the card's padding (T158). Light, like the card. */}
566
+ <script is:inline>(function (s) { var t = s && s.previousElementSibling, f = t && t.closest("form"), w = f ? f.clientWidth : 0; if (!w) w = document.documentElement.clientWidth - 48; if (t && w < 300) t.setAttribute("data-size", "compact"); })(document.currentScript);</script>
445
567
  <noscript>
446
568
  <p class="semics-needs-js" data-testid="booking-needs-js">{t("widget.needsJs")}</p>
447
569
  </noscript>
@@ -470,12 +592,12 @@ const when = (iso: string) => {
470
592
  </select>
471
593
  </div>
472
594
  )}
473
- {ticketTypes.length > 1 && (
595
+ {placeTypes.length > 1 && (
474
596
  <div class="semics-field">
475
597
  <label for={`${id}-wl-type`}>{t("waitlist.ticket")}</label>
476
598
  <select id={`${id}-wl-type`} name="ticketTypeId">
477
599
  <option value="">{t("waitlist.anyTicket")}</option>
478
- {ticketTypes.map((type) => <option value={type.id}>{type.name}</option>)}
600
+ {placeTypes.map((type) => <option value={type.id}>{type.name}</option>)}
479
601
  </select>
480
602
  </div>
481
603
  )}
@@ -493,8 +615,8 @@ const when = (iso: string) => {
493
615
  </div>
494
616
  {siteKey && (
495
617
  <>
496
- <div class="cf-turnstile" data-sitekey={siteKey}></div>
497
- <script is:inline>(function (s) { var t = s && s.previousElementSibling; if (t && t.clientWidth < 300) t.setAttribute("data-size", "compact"); })(document.currentScript);</script>
618
+ <div class="cf-turnstile" data-sitekey={siteKey} data-theme="light"></div>
619
+ <script is:inline>(function (s) { var t = s && s.previousElementSibling, f = t && t.closest("form"), w = f ? f.clientWidth : 0; if (!w) w = document.documentElement.clientWidth - 48; if (t && w < 300) t.setAttribute("data-size", "compact"); })(document.currentScript);</script>
498
620
  </>
499
621
  )}
500
622
  <button type="submit" class="semics-secondary">{t("waitlist.button")}</button>
@@ -510,23 +632,31 @@ const when = (iso: string) => {
510
632
  import "../client/picker.ts";
511
633
  </script>
512
634
 
635
+
513
636
  <style>
637
+ /* One card with even, generous padding; groups read as sections with small headings, not boxes (T157). */
514
638
  .semics-booking-widget {
515
639
  --_fg: var(--events-fg, #1a1a1a);
516
640
  --_muted: var(--events-muted, #4a4a4a);
517
641
  --_bg: var(--events-bg, #ffffff);
518
642
  --_border: var(--events-border, #6b6b6b);
643
+ --_line: color-mix(in srgb, var(--_border) 30%, transparent);
644
+ --_tint: color-mix(in srgb, var(--_accent) 7%, var(--_bg));
519
645
  --_accent: var(--events-accent, #0b57d0);
520
646
  --_accent-fg: var(--events-accent-fg, #ffffff);
521
647
  --_error: var(--events-error, #b3261e);
522
648
  --_radius: var(--events-radius, 6px);
649
+ --_pad: clamp(1.25rem, 0.75rem + 2.5vw, 2rem);
523
650
  box-sizing: border-box;
524
- max-inline-size: 36rem;
525
- padding: 1rem;
526
- border: 1px solid var(--_border);
527
- border-radius: var(--_radius);
651
+ /* The host sets the width: the widget fills its column, up to `--events-widget-max` when set (T158). */
652
+ max-inline-size: var(--events-widget-max, none);
653
+ padding: var(--_pad);
654
+ border: 1px solid var(--_line);
655
+ border-radius: calc(var(--_radius) + 6px);
528
656
  background: var(--_bg);
657
+ box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 6px 24px rgb(0 0 0 / 0.06);
529
658
  color: var(--_fg);
659
+ line-height: 1.5;
530
660
  overflow-wrap: anywhere;
531
661
  }
532
662
  .semics-booking-widget *,
@@ -535,37 +665,41 @@ const when = (iso: string) => {
535
665
  box-sizing: border-box;
536
666
  }
537
667
  .semics-booking-widget h2 {
538
- margin: 0 0 0.75rem;
539
- font-size: 1.25rem;
668
+ margin: 0 0 1.25rem;
669
+ font-size: 1.375rem;
670
+ line-height: 1.25;
540
671
  }
541
672
  .semics-booking-widget form {
542
673
  display: grid;
543
674
  grid-template-columns: minmax(0, 1fr);
544
- gap: 0.75rem;
675
+ gap: 1.25rem;
545
676
  }
546
677
  .semics-booking-widget .semics-waitlist {
547
- margin-block-start: 1.25rem;
548
- padding-block-start: 1rem;
549
- border-block-start: 1px solid var(--_border);
678
+ margin-block-start: 1.5rem;
679
+ padding-block-start: 1.5rem;
680
+ border-block-start: 1px solid var(--_line);
550
681
  }
551
682
  .semics-waitlist h3,
552
683
  .semics-waitlist p {
553
684
  margin: 0;
554
685
  }
555
- .semics-tickets {
556
- margin: 0;
557
- padding: 0.5rem 0.75rem;
558
- border: 1px solid var(--_border);
559
- border-radius: var(--_radius);
560
- min-inline-size: 0;
686
+ .semics-booking-widget legend {
687
+ margin: 0 0 0.5rem;
688
+ padding: 0;
689
+ font-size: 0.8125rem;
690
+ font-weight: 700;
691
+ letter-spacing: 0.06em;
692
+ text-transform: uppercase;
693
+ color: var(--_muted);
561
694
  }
695
+ .semics-tickets,
696
+ .semics-windows,
562
697
  .semics-questions {
563
698
  display: grid;
564
699
  gap: 0.75rem;
565
700
  margin: 0;
566
- padding: 0.5rem 0.75rem 0.75rem;
567
- border: 1px solid var(--_border);
568
- border-radius: var(--_radius);
701
+ padding: 0;
702
+ border: 0;
569
703
  min-inline-size: 0;
570
704
  }
571
705
  .semics-check {
@@ -580,51 +714,70 @@ const when = (iso: string) => {
580
714
  min-block-size: 1.25rem;
581
715
  inline-size: 1.25rem;
582
716
  margin: 0;
717
+ accent-color: var(--_accent);
583
718
  }
584
719
  .semics-hint {
585
720
  color: var(--_muted);
586
721
  }
722
+ .semics-picker-field {
723
+ gap: 0.75rem;
724
+ }
587
725
  .semics-picker-nav {
726
+ max-inline-size: var(--events-calendar-max, 26rem);
588
727
  display: flex;
589
728
  flex-wrap: wrap;
590
- align-items: baseline;
591
- gap: 0.25rem 1rem;
729
+ align-items: center;
730
+ gap: 0.5rem;
592
731
  }
593
732
  .semics-picker-month {
594
733
  margin: 0;
595
734
  margin-inline-end: auto;
596
- font-weight: 600;
735
+ font-size: 1.125rem;
736
+ font-weight: 700;
597
737
  }
598
738
  .semics-picker-nav a {
739
+ display: inline-flex;
740
+ align-items: center;
741
+ min-block-size: 2.25rem;
742
+ padding: 0.25rem 0.875rem;
743
+ border: 1px solid var(--_line);
744
+ border-radius: 999px;
599
745
  color: var(--_accent);
600
- min-block-size: 1.5rem;
746
+ font-size: 0.9375rem;
747
+ text-decoration: none;
748
+ }
749
+ .semics-picker-nav a:hover {
750
+ border-color: var(--_accent);
601
751
  }
602
752
  .semics-picker {
603
753
  display: grid;
604
- gap: 0.5rem;
754
+ gap: 1rem;
605
755
  margin: 0;
606
- padding: 0.5rem 0.75rem 0.75rem;
607
- border: 1px solid var(--_border);
608
- border-radius: var(--_radius);
756
+ padding: 0;
757
+ border: 0;
609
758
  min-inline-size: 0;
610
759
  }
611
760
  .semics-picker p {
612
761
  margin: 0;
613
762
  }
763
+ /* Room between the days: cells 6px apart, buttons at least 44px tall. The calendar keeps its size in a wide host column:
764
+ at most `--events-calendar-max` (26rem, days about 54px) while the rest of the widget fills the column (T159). */
614
765
  .semics-calendar {
615
- inline-size: 100%;
616
- border-collapse: collapse;
766
+ inline-size: calc(min(100%, var(--events-calendar-max, 26rem)) + 0.75rem);
767
+ margin: -0.375rem;
768
+ border-collapse: separate;
769
+ border-spacing: 0.375rem;
617
770
  table-layout: fixed;
618
771
  text-align: center;
619
772
  }
620
773
  .semics-calendar th {
621
- padding-block: 0.25rem;
622
- font-weight: 400;
623
- font-size: 0.875rem;
774
+ padding-block: 0 0.25rem;
775
+ font-weight: 600;
776
+ font-size: 0.8125rem;
624
777
  color: var(--_muted);
625
778
  }
626
779
  .semics-calendar td {
627
- padding: 1px;
780
+ padding: 0;
628
781
  }
629
782
  .semics-booking-widget .semics-calendar button,
630
783
  .semics-booking-widget .semics-times button {
@@ -633,11 +786,24 @@ const when = (iso: string) => {
633
786
  border: 1px solid var(--_accent);
634
787
  background: var(--_bg);
635
788
  color: var(--_accent);
789
+ font-weight: 600;
790
+ }
791
+ .semics-booking-widget .semics-calendar button {
792
+ block-size: clamp(2.75rem, 2rem + 2vw, 3.25rem);
793
+ }
794
+ /* Hover is its own, lighter state: a tint and a ring, the text stays the accent; only the chosen day or time
795
+ is filled (T158). */
796
+ .semics-booking-widget .semics-calendar button:not([aria-pressed="true"], .semics-day-full):hover,
797
+ .semics-booking-widget .semics-times button:not([aria-disabled="true"], [aria-checked="true"]):hover {
798
+ background: var(--_tint);
799
+ box-shadow: inset 0 0 0 1px var(--_accent);
800
+ color: var(--_accent);
636
801
  }
637
802
  .semics-booking-widget .semics-calendar button.semics-day-full,
638
803
  .semics-booking-widget .semics-times button[aria-disabled="true"] {
639
- border-color: var(--_border);
804
+ border-color: var(--_line);
640
805
  color: var(--_muted);
806
+ font-weight: 400;
641
807
  text-decoration: line-through;
642
808
  }
643
809
  .semics-booking-widget .semics-times button[aria-disabled="true"] {
@@ -647,39 +813,50 @@ const when = (iso: string) => {
647
813
  .semics-booking-widget .semics-times button[aria-checked="true"] {
648
814
  background: var(--_accent);
649
815
  color: var(--_accent-fg);
816
+ box-shadow: none;
650
817
  }
651
818
  .semics-day-none {
652
- display: block;
653
- padding-block: 0.75rem;
819
+ display: grid;
820
+ place-items: center;
821
+ block-size: clamp(2.75rem, 2rem + 2vw, 3.25rem);
654
822
  color: var(--_muted);
655
823
  }
656
824
  .semics-times {
657
825
  display: grid;
658
- grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
826
+ grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
659
827
  gap: 0.5rem;
660
828
  }
661
829
  .semics-booking-widget .semics-times button {
662
830
  display: grid;
663
831
  justify-items: center;
832
+ padding: 0.5rem;
664
833
  }
665
834
  .semics-places {
666
- font-size: 0.875rem;
835
+ font-size: 0.8125rem;
836
+ font-weight: 400;
667
837
  }
668
838
  .semics-ticket {
669
839
  display: flex;
670
840
  flex-wrap: wrap;
671
841
  align-items: center;
672
842
  justify-content: space-between;
673
- gap: 0.5rem;
674
- padding-block: 0.25rem;
843
+ gap: 0.5rem 1rem;
844
+ padding-block: 0.5rem;
845
+ border-block-end: 1px solid var(--_line);
846
+ }
847
+ .semics-ticket:last-of-type {
848
+ border-block-end: 0;
675
849
  }
676
850
  .semics-ticket label {
677
851
  display: flex;
678
852
  flex-wrap: wrap;
679
- gap: 0 0.5rem;
853
+ gap: 0 0.75rem;
680
854
  flex: 1 1 10rem;
681
855
  min-inline-size: 0;
682
856
  }
857
+ .semics-ticket-name {
858
+ font-weight: 600;
859
+ }
683
860
  .semics-ticket-price,
684
861
  .semics-ticket-soldout {
685
862
  color: var(--_muted);
@@ -690,7 +867,10 @@ const when = (iso: string) => {
690
867
  .semics-field {
691
868
  display: grid;
692
869
  grid-template-columns: minmax(0, 1fr);
693
- gap: 0.25rem;
870
+ gap: 0.375rem;
871
+ }
872
+ .semics-field > label {
873
+ font-weight: 500;
694
874
  }
695
875
  .semics-field select {
696
876
  inline-size: 100%;
@@ -704,7 +884,7 @@ const when = (iso: string) => {
704
884
  }
705
885
  .semics-booking-widget input,
706
886
  .semics-booking-widget select {
707
- padding: 0.375rem 0.5rem;
887
+ padding: 0.5rem 0.75rem;
708
888
  border: 1px solid var(--_border);
709
889
  border-radius: var(--_radius);
710
890
  background: var(--_bg);
@@ -723,7 +903,7 @@ const when = (iso: string) => {
723
903
  display: none;
724
904
  }
725
905
  .semics-form-alert {
726
- padding: 0.5rem 0.75rem;
906
+ padding: 0.75rem 1rem;
727
907
  border: 1px solid var(--_error);
728
908
  border-radius: var(--_radius);
729
909
  }
@@ -731,16 +911,28 @@ const when = (iso: string) => {
731
911
  margin: 0;
732
912
  font-weight: 600;
733
913
  }
914
+ /* The summary above Book. */
734
915
  .semics-total {
916
+ display: flex;
917
+ flex-wrap: wrap;
918
+ justify-content: space-between;
919
+ gap: 0.25rem 1rem;
735
920
  margin: 0;
921
+ padding: 1rem 1.25rem;
922
+ border-radius: var(--_radius);
923
+ background: var(--_tint);
924
+ }
925
+ .semics-total strong {
926
+ font-size: 1.125rem;
736
927
  }
737
928
  .semics-booking-widget button {
738
929
  justify-self: start;
739
- padding: 0.5rem 1.5rem;
930
+ padding: 0.75rem 2rem;
740
931
  border: 0;
741
932
  border-radius: var(--_radius);
742
933
  background: var(--_accent);
743
934
  color: var(--_accent-fg);
935
+ font-weight: 600;
744
936
  cursor: pointer;
745
937
  }
746
938
  .semics-promo-row {
@@ -758,6 +950,16 @@ const when = (iso: string) => {
758
950
  background: var(--_bg);
759
951
  color: var(--_accent);
760
952
  }
953
+ .semics-have-voucher {
954
+ margin: 0;
955
+ }
956
+ .semics-have-voucher a {
957
+ color: var(--_accent);
958
+ }
959
+ .semics-booking-widget input:target {
960
+ outline: 3px solid var(--_accent);
961
+ outline-offset: 2px;
962
+ }
761
963
  .semics-promo-note {
762
964
  margin: 0;
763
965
  color: var(--_muted);
@@ -770,6 +972,14 @@ const when = (iso: string) => {
770
972
  outline: 3px solid var(--_accent);
771
973
  outline-offset: 2px;
772
974
  }
975
+ .semics-visually-hidden {
976
+ position: absolute;
977
+ inline-size: 1px;
978
+ block-size: 1px;
979
+ overflow: hidden;
980
+ clip-path: inset(50%);
981
+ white-space: nowrap;
982
+ }
773
983
  [hidden] {
774
984
  display: none !important;
775
985
  }
@@ -0,0 +1,80 @@
1
+ ---
2
+ // <CancelBooking>: the quiet "Cancel booking" action at the foot of the booking page (T157). The button only
3
+ // opens a confirmation (a `<details>`, no JavaScript needed); the form posts `intent=cancel` back to the page.
4
+ import { around, pickLocale, translator } from "../i18n/index";
5
+ import { zonedAt } from "./lib/list";
6
+
7
+ interface Props {
8
+ /** Where the cancel form posts. */
9
+ action: string;
10
+ /** The last moment to cancel, when there is one. */
11
+ cancelBy?: string | undefined;
12
+ /** The event's zone, for `cancelBy`. */
13
+ zone?: string | null | undefined;
14
+ locale?: string;
15
+ }
16
+
17
+ const { action, cancelBy, zone } = Astro.props;
18
+ const locale = pickLocale(Astro.props.locale, Astro.currentLocale);
19
+ const { t, lang, dir } = translator(locale);
20
+ const [cancelBefore, cancelAfter] = around(t("booking.cancelUntil"), "time");
21
+ ---
22
+ <details class="semics-events semics-cancel" lang={lang} dir={dir} data-testid="booking-cancel">
23
+ <summary>{t("booking.cancel")}</summary>
24
+ <form method="post" action={action}>
25
+ <input type="hidden" name="intent" value="cancel" />
26
+ {cancelBy && (
27
+ <p>
28
+ {cancelBefore}<time datetime={cancelBy}>{zonedAt(cancelBy, zone, locale)}</time>{cancelAfter}
29
+ </p>
30
+ )}
31
+ <p>{t("booking.cancelConfirm")}</p>
32
+ <button type="submit">{t("booking.cancelYes")}</button>
33
+ </form>
34
+ </details>
35
+
36
+ <style>
37
+ .semics-cancel {
38
+ margin-block: 1.5rem 0;
39
+ color: var(--events-fg, #1a1a1a);
40
+ }
41
+ .semics-cancel summary {
42
+ display: inline-flex;
43
+ align-items: center;
44
+ min-block-size: 2.75rem;
45
+ color: var(--events-muted, #4a4a4a);
46
+ text-decoration: underline;
47
+ text-underline-offset: 0.2em;
48
+ cursor: pointer;
49
+ }
50
+ .semics-cancel form {
51
+ margin-block-start: 0.5rem;
52
+ padding: 1rem 1.25rem;
53
+ border: 1px solid var(--events-error, #b3261e);
54
+ border-radius: var(--events-radius, 6px);
55
+ background: var(--events-bg, #ffffff);
56
+ }
57
+ .semics-cancel p {
58
+ margin: 0 0 0.75rem;
59
+ }
60
+ .semics-cancel button {
61
+ font: inherit;
62
+ min-block-size: 2.75rem;
63
+ padding: 0.5rem 1.25rem;
64
+ border: 1px solid var(--events-error, #b3261e);
65
+ border-radius: var(--events-radius, 6px);
66
+ background: var(--events-bg, #ffffff);
67
+ color: var(--events-error, #b3261e);
68
+ font-weight: 600;
69
+ cursor: pointer;
70
+ }
71
+ .semics-cancel :focus-visible {
72
+ outline: 3px solid var(--events-accent, #0b57d0);
73
+ outline-offset: 2px;
74
+ }
75
+ @media print {
76
+ .semics-cancel {
77
+ display: none;
78
+ }
79
+ }
80
+ </style>