@moonbase.sh/storefront 3.13.0 → 3.14.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
@@ -155,6 +155,35 @@ A redirected buyer is always brought back to your page once they've paid, so
155
155
  The hosted checkout stays anonymous for the trip — it prefills from the order rather
156
156
  than signing the buyer into a Moonbase account, matching the overlay's behavior.
157
157
 
158
+ `checkout.backdrop` sets what the overlay draws behind the checkout:
159
+
160
+ ```ts
161
+ Moonbase.configure({
162
+ checkout: {
163
+ backdrop: { color: 'brand', opacity: 'strong', blur: true },
164
+ },
165
+ })
166
+ ```
167
+
168
+ | Part | Values |
169
+ | --- | --- |
170
+ | `color` | `'dark'`, `'light'`, or `'brand'`, a dark shade of your brand color. |
171
+ | `opacity` | `'subtle'`, `'standard'` or `'strong'`: how much of your page it covers. |
172
+ | `blur` | `true` blurs your page behind the checkout. |
173
+
174
+ Leave the option out, or any part of it, and that part follows the theme in your
175
+ Moonbase account, which draws a dark backdrop at standard opacity with no blur until
176
+ you change it there. A later `configure` changes only the parts it names; pass
177
+ `backdrop: null` to hand all of it back to the account's theme.
178
+
179
+ The blur happens on your page itself. The checkout runs in a frame of its own and can't
180
+ reach outside it, so the widget blurs the page behind the frame and clears it again as
181
+ the checkout closes. The loading state shown while the checkout opens draws the same
182
+ backdrop, taking `'brand'` from the 900 shade of `theme.colors.primary`.
183
+
184
+ The popup for updating a subscription's payment method draws the same color and opacity,
185
+ but never blurs your page.
186
+
158
187
  ### Customer groups
159
188
 
160
189
  If you keep customer lists in Moonbase and have opened one to public sign-ups,
@@ -211,7 +240,7 @@ success. Joining a list twice is not an error.
211
240
  | `{ family, stylesheet }` | The stylesheet you name, from wherever you host it. |
212
241
 
213
242
  The built-in families are `Inter`, `Roboto`, `EB Garamond`, `Merriweather`, `Poppins`,
214
- `PT Serif`, `Montserrat` and `Aleo`. Either slot accepts any of them.
243
+ `PT Serif`, `Montserrat`, `Aleo` and `Space Mono`. Either slot accepts any of them.
215
244
 
216
245
  They are served from Moonbase's own asset host — the same origin that serves the widget
217
246
  itself, and the same payload the hosted checkout uses, so the two share a cache entry.
@@ -336,6 +365,96 @@ you pass replaces the previous one; pass `{}` to remove it. No minimum by defaul
336
365
 
337
366
  You can also control where the widget mounts by providing `target`.
338
367
 
368
+ ### Typography, spacing and buttons
369
+
370
+ A few more `theme` options tune how the widget reads. Each takes one of a fixed set of
371
+ values, and the first of each is the default, which is how the widget has always looked:
372
+
373
+ | Option | Values | What it does |
374
+ | --- | --- | --- |
375
+ | `headingWeight` | `'standard'`, `'light'`, `'regular'`, `'medium'`, `'semibold'`, `'bold'`, `'extrabold'` | One weight for every heading, from 300 to 800. `'standard'` keeps each heading's own. |
376
+ | `bodyWeight` | `'regular'`, `'light'` | Running text at 400 or at 300. Bold text stays bold. |
377
+ | `headingLetterSpacing` | `'standard'`, `'tight'`, `'wide'` | Letter spacing for headings only, `-0.02em` or `0.04em`. |
378
+ | `spacing` | `'standard'`, `'compact'`, `'relaxed'` | The room around and between blocks in the drawer, at 0.75 or 1.25 times the standard. |
379
+ | `buttonLabels` | `'normal'`, `'uppercase'` | Button labels in capitals, a size smaller and spaced out. |
380
+ | `colors.button` | `{ background, text, hover? }` | The fill, label and hover of primary buttons, as CSS colors. |
381
+
382
+ ```ts
383
+ Moonbase.configure({
384
+ theme: {
385
+ headingWeight: 'semibold',
386
+ spacing: 'relaxed',
387
+ buttonLabels: 'uppercase',
388
+ colors: {
389
+ button: { background: '#E5A000', text: '#000000' },
390
+ },
391
+ },
392
+ })
393
+ ```
394
+
395
+ `spacing` never reaches inside a control: buttons and fields keep their height, and icons
396
+ and text keep their size. `'relaxed'` only applies from 640px wide, so a phone keeps its
397
+ width. Uppercase labels keep the button's height too, and subtle buttons, which read as
398
+ links, keep their case.
399
+
400
+ Without `colors.button`, primary buttons are drawn from `colors.primary` as before. Leave
401
+ out `hover` and the widget works one out, moving the fill a tenth of the way towards white
402
+ under a dark label or towards black under a light one, so the label never loses contrast.
403
+ A `colors.button` you pass replaces the previous one as a whole, so give `background` and
404
+ `text` together; pass `null` to go back to `colors.primary`.
405
+
406
+ ### Match your Moonbase theme
407
+
408
+ The theme in your Moonbase account styles the hosted storefront and the checkout. The
409
+ widget is styled from your own code instead, so to make it match, open Account settings >
410
+ Storefront > Theme in Moonbase and copy the ready-made `Moonbase.configure` snippet under
411
+ "Match your storefront widget". It is generated from your account's theme, and looks
412
+ like this:
413
+
414
+ ```js
415
+ Moonbase.configure({
416
+ theme: {
417
+ colors: {
418
+ primary: { 50: '#EEF2FF', 100: '#E0E7FF', /* ... */ 900: '#312E81' },
419
+ button: { background: '#4F46E5', text: '#FFFFFF', hover: '#4338CA' },
420
+ },
421
+ fonts: { heading: 'Montserrat', body: 'Inter' },
422
+ corners: 'soft',
423
+ buttons: 'light',
424
+ cards: 'outlined',
425
+ buttonLabels: 'normal',
426
+ headingWeight: 'standard',
427
+ bodyWeight: 'regular',
428
+ headingLetterSpacing: 'standard',
429
+ spacing: 'standard',
430
+ },
431
+ checkout: {
432
+ backdrop: { color: 'dark', opacity: 'standard', blur: false },
433
+ },
434
+ })
435
+ ```
436
+
437
+ Paste it as is, or keep only the parts you want. Each theme setting maps onto one widget
438
+ option:
439
+
440
+ | Theme setting | Widget option |
441
+ | --- | --- |
442
+ | Brand color, as its shades | `theme.colors.primary` |
443
+ | Brand and contrast color, as checkout draws primary buttons | `theme.colors.button` |
444
+ | Heading font, body font | `theme.fonts.heading`, `theme.fonts.body` |
445
+ | Corner style | `theme.corners` |
446
+ | Button style | `theme.buttons` |
447
+ | Button labels | `theme.buttonLabels` |
448
+ | Heading weight | `theme.headingWeight` |
449
+ | Body weight | `theme.bodyWeight` |
450
+ | Heading letter spacing | `theme.headingLetterSpacing` |
451
+ | Spacing | `theme.spacing` |
452
+ | Overlay checkout backdrop | `checkout.backdrop` |
453
+
454
+ Change the theme later and the snippet changes with it, so copy it again. The snippet
455
+ spells out the backdrop too, which the overlay checkout then keeps over the account's
456
+ theme; leave `checkout.backdrop` out if you would rather it followed the theme on its own.
457
+
339
458
  ## Promotions
340
459
 
341
460
  When you run a sale across your catalogue, the widget surfaces it on its own — as a
@@ -1,5 +1,7 @@
1
1
  import { ActivationRequestFulfillmentType } from '@moonbase.sh/vue';
2
2
  import { CartItem } from '@moonbase.sh/vue';
3
+ import { CheckoutBackdropColor } from '@moonbase.sh/vue';
4
+ import { CheckoutBackdropOpacity } from '@moonbase.sh/vue';
3
5
  import { CheckoutPaymentFailure } from '@moonbase.sh/vue';
4
6
  import { CheckoutRedirectMode } from '@moonbase.sh/vue';
5
7
  import { CurrencyDisplay } from '@moonbase.sh/vue';
@@ -55,7 +57,29 @@ declare const Moonbase_2: MoonbaseImpl;
55
57
  export default Moonbase_2;
56
58
 
57
59
  /** Families the widget ships with, served from Moonbase's own asset host. */
58
- export declare type MoonbaseBuiltInFont = 'Inter' | 'Roboto' | 'EB Garamond' | 'Merriweather' | 'Poppins' | 'PT Serif' | 'Montserrat' | 'Aleo';
60
+ export declare type MoonbaseBuiltInFont = 'Inter' | 'Roboto' | 'EB Garamond' | 'Merriweather' | 'Poppins' | 'PT Serif' | 'Montserrat' | 'Aleo' | 'Space Mono';
61
+
62
+ /** Primary button colours, as any CSS colour. */
63
+ export declare interface MoonbaseButtonColors {
64
+ background: string;
65
+ /** The label, on `background`. */
66
+ text: string;
67
+ /**
68
+ * The fill on hover. Left out, it is `background` moved 10% towards white under a dark label, or
69
+ * towards black under a light one, so the label never loses contrast.
70
+ */
71
+ hover?: string;
72
+ }
73
+
74
+ /** What the popup checkout draws behind it. A part left out follows the account's theme in Moonbase. */
75
+ export declare interface MoonbaseCheckoutBackdrop {
76
+ /** `'dark'`, `'light'`, or `'brand'`: a tint of the darkest shade of the brand colour. */
77
+ color?: CheckoutBackdropColor;
78
+ /** How much of the page shows through: `'subtle'` (50% cover), `'standard'` (75%) or `'strong'` (90%). */
79
+ opacity?: CheckoutBackdropOpacity;
80
+ /** Blur the page behind the checkout. */
81
+ blur?: boolean;
82
+ }
59
83
 
60
84
  export declare interface MoonbaseCustomFont {
61
85
  /**
@@ -508,6 +532,12 @@ export declare interface MoonbaseOptions {
508
532
  * - `'never'` / `false`: always the overlay, which can't offer Apple Pay or Google Pay.
509
533
  */
510
534
  redirect: boolean | CheckoutRedirectMode;
535
+ /**
536
+ * What the popup checkout draws behind it, e.g. `{ color: 'brand', opacity: 'strong', blur: true }`.
537
+ * Left out, and for any part left out, the account's theme in Moonbase decides. Parts merge one at
538
+ * a time across `configure()` calls; pass `null` to hand all of it back to the theme.
539
+ */
540
+ backdrop?: MoonbaseCheckoutBackdrop | null;
511
541
  };
512
542
  cart: {
513
543
  quantity: 'selectable' | 'single';
@@ -570,6 +600,12 @@ export declare interface MoonbaseOptions {
570
600
  colors: {
571
601
  primary: Record<number, string> | string;
572
602
  background: 'white' | 'gray';
603
+ /**
604
+ * The fill, label and hover of primary buttons, e.g. `{ background: '#E5A000', text: '#000000' }`.
605
+ * Left out, primary buttons are drawn from `primary` as before. Replaced as a whole by each
606
+ * `configure()` that names it; pass `null` to go back to `primary`.
607
+ */
608
+ button?: MoonbaseButtonColors | null;
573
609
  };
574
610
  fonts: {
575
611
  /**
@@ -583,6 +619,27 @@ export declare interface MoonbaseOptions {
583
619
  corners: 'sharp' | 'soft' | 'round';
584
620
  buttons: 'outlined' | 'light';
585
621
  cards: 'outlined' | 'shadow' | 'white';
622
+ /**
623
+ * `'uppercase'` sets button labels in capitals: a size smaller, bold and spaced out, at the same
624
+ * button height. Subtle, link-like buttons keep their case. `'normal'` (default) leaves them as
625
+ * written.
626
+ */
627
+ buttonLabels: 'normal' | 'uppercase';
628
+ /**
629
+ * One weight for every heading: 300, 400, 500, 600, 700 or 800. `'standard'` (default) keeps each
630
+ * heading's own, which differ by level.
631
+ */
632
+ headingWeight: 'standard' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'extrabold';
633
+ /** `'light'` sets running text at 300 rather than the default `'regular'` 400. Bold text stays bold. */
634
+ bodyWeight: 'regular' | 'light';
635
+ /** Letter spacing for headings: `'tight'` `-0.02em`, `'wide'` `0.04em`. `'standard'` (default) keeps each heading's own. */
636
+ headingLetterSpacing: 'standard' | 'tight' | 'wide';
637
+ /**
638
+ * The room around and between blocks in the drawer: `'compact'` is three quarters of the
639
+ * default, `'relaxed'` a quarter more from 640px wide (and the default below, so a phone keeps its
640
+ * width). Buttons, fields, icons and text keep their size either way.
641
+ */
642
+ spacing: 'standard' | 'compact' | 'relaxed';
586
643
  };
587
644
  pricing: {
588
645
  /** Whole prices: `'auto'` (default) shows `$10`, `'always'` shows `$10.00`. */