@tansy/theme-storefront 0.1.0 → 0.1.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ What changed in each release of `@tansy/theme-storefront`. Releases up to 0.1.0 went out with every other package
4
+ on one version and are described in [tansy's changelog](../../CHANGELOG.md).
5
+
6
+ ## 0.1.1 — 2026-11-22
7
+
8
+ - **Pages change without a reload.** Links between the theme's pages are followed inside the app,
9
+ through the Next router, each move inside a view transition: the header holds still, a product's
10
+ picture flies from its card to its page and back, and the current category chip and the tab bar's
11
+ dot slide to their new place. A page loaded in full, such as another language, still animates in
12
+ browsers with cross-document view transitions. Nothing moves for visitors who ask for less motion.
13
+ - **Tapping a product's picture zooms it** to fill the screen, and back.
14
+ - **The back arrow returns to the page the visitor came from**, as an app's does. From a product,
15
+ that page comes back scrolled to the product's card, and its picture flies back into it. Opened
16
+ from a shared link, it goes to the shop.
17
+ - **On phones:** a tab bar with a menu that rises as a sheet, pictures that swipe, and **Buy now**
18
+ and **Add to cart** pinned to the bottom of a product page.
19
+ - **A Format field** on products (physical, digital, or both), shown as a badge.
20
+ - **Memberships for digital editions:** a **Membership** field on products, a **Library page** at
21
+ `/library` with the plans on offer, and **Library files** that only members of a plan including
22
+ them can see or download. A new `library` option links to it from the header and tab bar.
23
+ - The theme now names `@tansy/payments` as a peer dependency, for its Subscribe button, and
24
+ requires `tansy`, `@tansy/shop` and `@tansy/payments` ^0.1.1.
package/client.d.ts CHANGED
@@ -1,10 +1,28 @@
1
+ import { type ReactNode } from "react";
1
2
  import { type VariantOption } from "@tansy/shop/react";
2
3
  import { type SiteWords } from "tansy/react";
4
+ /**
5
+ * Follows the theme's links inside the app, through the Next router, so moving between pages swaps
6
+ * the page without loading a new document, each move inside a view transition (`moveTo`): the
7
+ * header holds still, the picture flies and the chip and tab dot slide. Pages loaded in full
8
+ * (another language, a shared link) still get the cross-document transition the layout switches
9
+ * on, named here on `pageswap`.
10
+ * Rendered by the layout on every page, it also leaves the note the back arrow reads.
11
+ */
12
+ export declare function ViewTransitionNames(): null;
13
+ /**
14
+ * Wraps the page beneath the header and tells a running move between pages (`moveTo`) that the new
15
+ * page is in, as soon as the router has put it in the document, so the browser animates to it.
16
+ */
17
+ export declare function PageTransition({ children }: {
18
+ children: ReactNode;
19
+ }): ReactNode;
3
20
  /**
4
21
  * Searches published products as the visitor types, through the records API. It reads as
5
22
  * whoever is looking, so the products collection's list rule still decides what can be found.
6
23
  */
7
- export declare function ProductSearch({ words, currency }: {
24
+ export declare function ProductSearch({ id: anchor, words, currency }: {
25
+ id?: string;
8
26
  words?: SiteWords;
9
27
  currency: string;
10
28
  }): import("react").JSX.Element;
@@ -14,11 +32,16 @@ export interface GalleryImage {
14
32
  alt: string;
15
33
  }
16
34
  /**
17
- * The product's pictures on a soft stage, with a ring around it and arrows to step through
18
- * them. Arrow keys step too once the stage has focus, the way they point in the page's direction.
35
+ * The product's pictures on a soft stage, with a ring around it. They sit side by side in a
36
+ * track that snaps, so a finger swipes through them as in an app, and arrows, thumbnails or the
37
+ * arrow keys (once the stage has focus) step through them too. The picture showing carries
38
+ * `transitionName`, the name its card in a list has, so moving between them flies it across.
39
+ * Tapping it zooms it to fill the screen, the same picture growing out of the stage, and closing
40
+ * shrinks it back.
19
41
  */
20
- export declare function ProductGallery({ images, words }: {
42
+ export declare function ProductGallery({ images, transitionName, words }: {
21
43
  images: GalleryImage[];
44
+ transitionName?: string;
22
45
  words?: SiteWords;
23
46
  }): import("react").JSX.Element;
24
47
  /**
@@ -36,7 +59,21 @@ export declare function BuyBox({ product, price, compareAt, stock, variants, cur
36
59
  cartHref?: string;
37
60
  words?: SiteWords;
38
61
  }): import("react").JSX.Element;
39
- /** The browser's share sheet where there is one, and copying the address where there isn't. */
62
+ /**
63
+ * A back arrow that returns to the page the visitor came from, as an app's does. It goes there as
64
+ * a new move forward rather than back through history, so it gets the same transition as any link,
65
+ * and adds `#` and the card of `card`, the product being left: the browser scrolls that card into
66
+ * view as the page shows, so the list comes back where the visitor was and the product's
67
+ * picture flies back into its own card. The address is worked out once the page has loaded, before
68
+ * this page's own links leave a note of their own. Opened from a shared link or a new tab, it is
69
+ * `href`.
70
+ */
71
+ export declare function BackLink({ href, card, className, children }: {
72
+ href: string;
73
+ card?: number | string;
74
+ className?: string;
75
+ children: ReactNode;
76
+ }): import("react").JSX.Element;
40
77
  export declare function ShareButton({ title, words, className }: {
41
78
  title: string;
42
79
  words?: SiteWords;
package/client.js CHANGED
@@ -1,14 +1,207 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useEffect, useId, useRef, useState } from "react";
3
+ import { usePathname, useRouter, useSearchParams } from "next/navigation";
4
+ import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
5
+ import { flushSync } from "react-dom";
4
6
  import { addToCart } from "@tansy/shop/react";
5
7
  import { apiPath, contentLocale, sitePath, siteWords } from "tansy/react";
6
- import { Bag, Check, ChevronLeft, ChevronRight, Minus, Plus, Search, Send } from "./icons";
7
- import { cx, money, text } from "./lib";
8
+ import { Bag, Check, ChevronLeft, ChevronRight, Close, Minus, Plus, Search, Send } from "./icons";
9
+ import { cardAnchor, cx, money, text } from "./lib";
8
10
  /**
9
11
  * The theme's parts that need the browser. Each takes `pickWords(words, "storefront")` from a
10
12
  * template, so it speaks the page's language and keeps links in it.
11
13
  */
14
+ /* ------------------------------------------------------- view transitions */
15
+ const reducedMotion = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches;
16
+ /**
17
+ * Runs a change to the page as a same-document view transition where the browser has them, with
18
+ * `type` so styles.css can tell it from moving between pages. Browsers that have transitions but
19
+ * not types get it without one.
20
+ */
21
+ function transition(change, type) {
22
+ if (typeof document.startViewTransition !== "function" || reducedMotion())
23
+ return change();
24
+ const update = () => flushSync(change);
25
+ try {
26
+ document.startViewTransition({ update, types: [type] });
27
+ }
28
+ catch {
29
+ document.startViewTransition(update);
30
+ }
31
+ }
32
+ const pathOf = (href) => {
33
+ try {
34
+ return new URL(href, window.location.href).pathname;
35
+ }
36
+ catch {
37
+ return "";
38
+ }
39
+ };
40
+ /**
41
+ * Before a page is left for a product, picks the picture that flies. Pictures that lead to a
42
+ * product carry `data-sf-vt` (the name) and `data-sf-vt-href`. When the same product shows twice,
43
+ * such as in the spotlight and the grid, the one pressed (or else the one most in view) takes the
44
+ * name and the others give it up, since a page may use a name once. The new page names its own.
45
+ */
46
+ function nameFlyingPicture(to, pressed) {
47
+ const path = pathOf(to);
48
+ const pictures = [...document.querySelectorAll("[data-sf-vt-href]")].filter((picture) => pathOf(picture.dataset.sfVtHref ?? "") === path);
49
+ if (!pictures.length)
50
+ return;
51
+ const near = (picture) => pressed && picture.closest("li, article, [data-sf-vt-scope]")?.contains(pressed);
52
+ const inView = (picture) => {
53
+ const box = picture.getBoundingClientRect();
54
+ return Math.max(0, Math.min(box.bottom, window.innerHeight) - Math.max(box.top, 0)) * Math.max(0, Math.min(box.right, window.innerWidth) - Math.max(box.left, 0));
55
+ };
56
+ const chosen = pictures.find(near) ?? pictures.reduce((best, picture) => (inView(picture) > inView(best) ? picture : best));
57
+ const name = chosen.dataset.sfVt ?? "";
58
+ for (const other of document.querySelectorAll("[data-sf-vt]")) {
59
+ if (other !== chosen && other.style.viewTransitionName === name)
60
+ other.style.viewTransitionName = "none";
61
+ }
62
+ chosen.style.viewTransitionName = name;
63
+ }
64
+ /** Set once a link here has been followed without loading a new document. */
65
+ let softNavigated = false;
66
+ /** Ends the view transition of a move between pages, once the new page is in. Set while one runs. */
67
+ let pageIn = null;
68
+ /**
69
+ * The link a click follows inside the app, or null when the browser should load it itself: a
70
+ * new tab, a download, another site, the API (files), another language, or a jump on this page.
71
+ */
72
+ function appLink(event) {
73
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
74
+ return null;
75
+ const link = event.target?.closest?.("a[href]");
76
+ if (!link || !link.closest(".sf-shell"))
77
+ return null;
78
+ if ((link.target && link.target !== "_self") || link.hasAttribute("download") || link.hasAttribute("hreflang") || link.relList.contains("external"))
79
+ return null;
80
+ if (link.origin !== location.origin || link.pathname.startsWith(apiPath("/")))
81
+ return null;
82
+ if (link.pathname === location.pathname && link.search === location.search && link.hash)
83
+ return null;
84
+ return link;
85
+ }
86
+ /**
87
+ * The Next router, or null where a template is rendered outside one (as tests render them), whose
88
+ * links then load pages as plain links do. `useRouter` throws there, but always reads its context,
89
+ * so catching keeps the hooks in the same order.
90
+ */
91
+ function useAppRouter() {
92
+ try {
93
+ return useRouter();
94
+ }
95
+ catch {
96
+ return null;
97
+ }
98
+ }
99
+ /** How long the old page may stay frozen waiting for the new one before it's let go without an animation. */
100
+ const PAGE_WAIT_MS = 3000;
101
+ /**
102
+ * Moves to `href` through the Next router inside a view transition: the browser takes the old page,
103
+ * the router swaps in the new one without loading a document, and `PageTransition` ends the update
104
+ * once it's in, so the browser animates from one to the other. styles.css says how.
105
+ */
106
+ function moveTo(router, href) {
107
+ if (typeof document.startViewTransition !== "function" || reducedMotion() || document.visibilityState !== "visible")
108
+ return router.push(href);
109
+ pageIn?.();
110
+ let pushed = false;
111
+ const push = () => {
112
+ if (pushed)
113
+ return;
114
+ pushed = true;
115
+ router.push(href);
116
+ };
117
+ const update = () => new Promise((resolve) => {
118
+ const timer = setTimeout(() => { pageIn = null; resolve(); }, PAGE_WAIT_MS);
119
+ pageIn = () => { clearTimeout(timer); pageIn = null; resolve(); };
120
+ push();
121
+ });
122
+ let transition;
123
+ try {
124
+ transition = document.startViewTransition({ update, types: ["sf-page"] });
125
+ }
126
+ catch {
127
+ transition = document.startViewTransition(update);
128
+ }
129
+ // The browser takes the old page on its next frame. Where none comes, the move goes without the animation.
130
+ setTimeout(() => {
131
+ if (pushed)
132
+ return;
133
+ transition.skipTransition();
134
+ push();
135
+ }, 1000);
136
+ }
137
+ /**
138
+ * Follows the theme's links inside the app, through the Next router, so moving between pages swaps
139
+ * the page without loading a new document, each move inside a view transition (`moveTo`): the
140
+ * header holds still, the picture flies and the chip and tab dot slide. Pages loaded in full
141
+ * (another language, a shared link) still get the cross-document transition the layout switches
142
+ * on, named here on `pageswap`.
143
+ * Rendered by the layout on every page, it also leaves the note the back arrow reads.
144
+ */
145
+ export function ViewTransitionNames() {
146
+ const router = useAppRouter();
147
+ useCameFromNote();
148
+ useEffect(() => {
149
+ let pressed = null;
150
+ const prefetched = new Set();
151
+ const press = (event) => { pressed = event.target instanceof Element ? event.target : null; };
152
+ if (!router)
153
+ return;
154
+ const hover = (event) => {
155
+ const link = event.target?.closest?.("a[href]");
156
+ if (!link || link.origin !== location.origin || link.pathname.startsWith(apiPath("/")) || prefetched.has(link.href))
157
+ return;
158
+ prefetched.add(link.href);
159
+ router.prefetch(link.href);
160
+ };
161
+ const click = (event) => {
162
+ const link = appLink(event);
163
+ if (!link)
164
+ return;
165
+ event.preventDefault();
166
+ if (!reducedMotion())
167
+ nameFlyingPicture(link.href, pressed ?? event.target);
168
+ softNavigated = true;
169
+ const href = link.pathname + link.search + link.hash;
170
+ // The page already showing: the router refreshes it in place, with nothing to animate.
171
+ if (link.pathname === location.pathname && link.search === location.search)
172
+ router.push(href);
173
+ else
174
+ moveTo(router, href);
175
+ };
176
+ const swap = (event) => {
177
+ const { viewTransition, activation } = event;
178
+ const to = activation?.entry?.url;
179
+ if (viewTransition && to)
180
+ nameFlyingPicture(to, pressed);
181
+ };
182
+ window.addEventListener("pointerdown", press, true);
183
+ document.addEventListener("mouseover", hover);
184
+ document.addEventListener("click", click);
185
+ window.addEventListener("pageswap", swap);
186
+ return () => {
187
+ window.removeEventListener("pointerdown", press, true);
188
+ document.removeEventListener("mouseover", hover);
189
+ document.removeEventListener("click", click);
190
+ window.removeEventListener("pageswap", swap);
191
+ };
192
+ }, [router]);
193
+ return null;
194
+ }
195
+ /**
196
+ * Wraps the page beneath the header and tells a running move between pages (`moveTo`) that the new
197
+ * page is in, as soon as the router has put it in the document, so the browser animates to it.
198
+ */
199
+ export function PageTransition({ children }) {
200
+ const pathname = usePathname();
201
+ const search = useSearchParams()?.toString();
202
+ useLayoutEffect(() => { pageIn?.(); }, [pathname, search]);
203
+ return children;
204
+ }
12
205
  const thumb = (fileId, size = "100x100") => apiPath(`/files/${encodeURIComponent(fileId)}?thumb=${size}`);
13
206
  const MIN_LENGTH = 2;
14
207
  const WAIT_MS = 250;
@@ -16,9 +209,10 @@ const WAIT_MS = 250;
16
209
  * Searches published products as the visitor types, through the records API. It reads as
17
210
  * whoever is looking, so the products collection's list rule still decides what can be found.
18
211
  */
19
- export function ProductSearch({ words, currency }) {
212
+ export function ProductSearch({ id: anchor, words, currency }) {
20
213
  const { t, formatNumber } = siteWords(words);
21
214
  const id = useId();
215
+ const input = useRef(null);
22
216
  const [query, setQuery] = useState("");
23
217
  const [results, setResults] = useState(null);
24
218
  const [state, setState] = useState("idle");
@@ -63,6 +257,16 @@ export function ProductSearch({ words, currency }) {
63
257
  // eslint-disable-next-line react-hooks/exhaustive-deps -- searches again only when the words typed change
64
258
  }, [query]);
65
259
  useEffect(() => () => pending.current?.abort(), []);
260
+ // The Search tab links here by its id: arriving that way puts the cursor in the box.
261
+ useEffect(() => {
262
+ if (!anchor)
263
+ return;
264
+ const focus = () => { if (window.location.hash === `#${anchor}`)
265
+ input.current?.focus({ preventScroll: false }); };
266
+ focus();
267
+ window.addEventListener("hashchange", focus);
268
+ return () => window.removeEventListener("hashchange", focus);
269
+ }, [anchor]);
66
270
  function submit(event) {
67
271
  event.preventDefault();
68
272
  void run(query);
@@ -73,33 +277,70 @@ export function ProductSearch({ words, currency }) {
73
277
  : state === "failed"
74
278
  ? t("storefront.searchFailed")
75
279
  : results === null ? "" : results.length ? t("storefront.found", { count: results.length }) : t("storefront.noResults", { query: query.trim() });
76
- return (_jsxs("div", { className: "sf:relative sf:w-full sf:max-w-xl", children: [_jsxs("form", { role: "search", onSubmit: submit, children: [_jsx("label", { className: "sf:sr-only", htmlFor: `${id}-q`, children: t("storefront.searchLabel") }), _jsxs("span", { className: "sf:flex sf:h-14 sf:items-center sf:gap-3 sf:rounded-full sf:border sf:border-line sf:bg-surface sf:ps-5 sf:pe-2 sf:transition sf:focus-within:border-accent sf:focus-within:bg-page sf:focus-within:ring-4 sf:focus-within:ring-accent/15", children: [_jsx(Search, { className: "sf:size-5 sf:shrink-0 sf:text-muted" }), _jsx("input", { id: `${id}-q`, type: "search", name: "q", autoComplete: "off", maxLength: 200, placeholder: t("storefront.searchPlaceholder"), value: query, onChange: (event) => setQuery(event.target.value), onKeyDown: (event) => { if (event.key === "Escape")
280
+ return (_jsxs("div", { id: anchor, className: "sf:relative sf:w-full sf:max-w-xl sf:scroll-mt-24", children: [_jsxs("form", { role: "search", onSubmit: submit, children: [_jsx("label", { className: "sf:sr-only", htmlFor: `${id}-q`, children: t("storefront.searchLabel") }), _jsxs("span", { className: "sf:flex sf:h-14 sf:items-center sf:gap-3 sf:rounded-full sf:border sf:border-line sf:bg-surface sf:ps-5 sf:pe-2 sf:transition sf:focus-within:border-accent sf:focus-within:bg-page sf:focus-within:ring-4 sf:focus-within:ring-accent/15", children: [_jsx(Search, { className: "sf:size-5 sf:shrink-0 sf:text-muted" }), _jsx("input", { ref: input, id: `${id}-q`, type: "search", enterKeyHint: "search", name: "q", autoComplete: "off", maxLength: 200, placeholder: t("storefront.searchPlaceholder"), value: query, onChange: (event) => setQuery(event.target.value), onKeyDown: (event) => { if (event.key === "Escape")
77
281
  setQuery(""); }, "aria-controls": `${id}-results`, "aria-describedby": `${id}-status`, className: "sf:h-full sf:min-w-0 sf:flex-1 sf:bg-transparent sf:text-base sf:text-ink sf:outline-none sf:placeholder:text-muted" }), _jsx("button", { type: "submit", className: "sf:inline-flex sf:h-10 sf:shrink-0 sf:items-center sf:rounded-full sf:bg-ink sf:px-5 sf:text-sm sf:font-medium sf:text-page sf:transition sf:hover:bg-accent sf:hover:text-on-accent", children: t("storefront.searchLabel") })] })] }), _jsx("p", { id: `${id}-status`, className: "sf:sr-only", role: "status", "aria-live": "polite", children: status }), _jsx("div", { id: `${id}-results`, hidden: !open, className: "sf:absolute sf:inset-x-0 sf:top-full sf:z-20 sf:mt-2 sf:overflow-hidden sf:rounded-3xl sf:border sf:border-line sf:bg-page sf:p-2 sf:shadow-card", children: results && results.length > 0 ? (_jsx("ul", { children: results.map((product) => {
78
282
  const path = text(product.recordPath);
79
283
  const image = Array.isArray(product.images) ? text(product.images[0]) : "";
80
284
  const price = typeof product.price === "number" ? product.price : null;
81
- return (_jsx("li", { children: _jsxs("a", { href: path ? sitePath(words, path) : undefined, className: "sf:flex sf:items-center sf:gap-3 sf:rounded-2xl sf:p-2 sf:text-ink sf:no-underline sf:hover:bg-surface sf:focus-visible:bg-surface sf:focus-visible:outline-none", children: [image ? _jsx("img", { src: thumb(image), alt: "", width: 48, height: 48, loading: "lazy", className: "sf:size-12 sf:rounded-full sf:bg-surface sf:object-cover" }) : _jsx("span", { className: "sf:grid sf:size-12 sf:place-items-center sf:rounded-full sf:bg-surface sf:text-muted", "aria-hidden": "true", children: _jsx(Bag, {}) }), _jsx("span", { className: "sf:min-w-0 sf:flex-1 sf:truncate sf:font-medium", children: text(product.title) }), price !== null && _jsx("span", { className: "sf:text-sm sf:text-muted sf:tabular-nums", children: money(formatNumber, price, currency) })] }) }, product.id));
285
+ return (_jsx("li", { children: _jsxs("a", { href: path ? sitePath(words, path) : undefined, className: "sf:flex sf:items-center sf:gap-3 sf:rounded-2xl sf:p-2 sf:text-ink sf:no-underline sf:hover:bg-surface sf:focus-visible:bg-surface sf:focus-visible:outline-none", children: [image ? _jsx("img", { src: thumb(image), alt: "", width: 48, height: 48, loading: "lazy", ...(path ? { "data-sf-vt": `sf-product-${product.id}`, "data-sf-vt-href": sitePath(words, path) } : {}), className: "sf-vt-product sf:size-12 sf:rounded-full sf:bg-surface sf:object-cover" }) : _jsx("span", { className: "sf:grid sf:size-12 sf:place-items-center sf:rounded-full sf:bg-surface sf:text-muted", "aria-hidden": "true", children: _jsx(Bag, {}) }), _jsx("span", { className: "sf:min-w-0 sf:flex-1 sf:truncate sf:font-medium", children: text(product.title) }), price !== null && _jsx("span", { className: "sf:text-sm sf:text-muted sf:tabular-nums", children: money(formatNumber, price, currency) })] }) }, product.id));
82
286
  }) })) : _jsx("p", { className: "sf:p-3 sf:text-sm sf:text-muted", children: status }) })] }));
83
287
  }
84
288
  const RoundButton = ({ label, onClick, children }) => (_jsx("button", { type: "button", "aria-label": label, onClick: onClick, className: "sf:grid sf:size-10 sf:place-items-center sf:rounded-full sf:text-ink sf:transition sf:hover:bg-ink sf:hover:text-page sf:focus-visible:outline-2 sf:focus-visible:outline-accent", children: children }));
289
+ /** Smooth unless the visitor asks for less motion. */
290
+ const scrollBehavior = () => (reducedMotion() ? "auto" : "smooth");
85
291
  /**
86
- * The product's pictures on a soft stage, with a ring around it and arrows to step through
87
- * them. Arrow keys step too once the stage has focus, the way they point in the page's direction.
292
+ * The product's pictures on a soft stage, with a ring around it. They sit side by side in a
293
+ * track that snaps, so a finger swipes through them as in an app, and arrows, thumbnails or the
294
+ * arrow keys (once the stage has focus) step through them too. The picture showing carries
295
+ * `transitionName`, the name its card in a list has, so moving between them flies it across.
296
+ * Tapping it zooms it to fill the screen, the same picture growing out of the stage, and closing
297
+ * shrinks it back.
88
298
  */
89
- export function ProductGallery({ images, words }) {
299
+ export function ProductGallery({ images, transitionName, words }) {
90
300
  const { t } = siteWords(words);
91
301
  const [index, setIndex] = useState(0);
302
+ const [zoomed, setZoomed] = useState(false);
303
+ const track = useRef(null);
304
+ const opener = useRef(null);
92
305
  const count = images.length;
93
- const go = (step) => setIndex((current) => (current + step + count) % count);
306
+ const name = transitionName ?? "sf-zoom";
307
+ function zoom(open) {
308
+ transition(() => setZoomed(open), "sf-zoom");
309
+ if (!open)
310
+ opener.current?.focus({ preventScroll: true });
311
+ }
312
+ // While zoomed: Escape closes, and the page behind holds still.
313
+ useEffect(() => {
314
+ if (!zoomed)
315
+ return;
316
+ const keys = (event) => { if (event.key === "Escape")
317
+ zoom(false); };
318
+ const root = document.documentElement;
319
+ const overflow = root.style.overflow;
320
+ root.style.overflow = "hidden";
321
+ window.addEventListener("keydown", keys);
322
+ return () => { root.style.overflow = overflow; window.removeEventListener("keydown", keys); };
323
+ }, [zoomed]);
324
+ /** Scrolls the track to a picture. The index follows from the scroll, so swiping and stepping agree. */
325
+ function show(at) {
326
+ const slide = track.current?.children[(at + count) % count];
327
+ slide?.scrollIntoView({ behavior: scrollBehavior(), block: "nearest", inline: "center" });
328
+ }
329
+ function onScroll() {
330
+ const element = track.current;
331
+ if (!element || !element.clientWidth)
332
+ return;
333
+ // scrollLeft runs negative right to left, so its size is what counts.
334
+ setIndex(Math.min(count - 1, Math.round(Math.abs(element.scrollLeft) / element.clientWidth)));
335
+ }
94
336
  function keys(event) {
95
337
  if (count < 2 || (event.key !== "ArrowLeft" && event.key !== "ArrowRight"))
96
338
  return;
97
339
  event.preventDefault();
98
340
  const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
99
- go((event.key === "ArrowRight") !== rtl ? 1 : -1);
341
+ show(index + ((event.key === "ArrowRight") !== rtl ? 1 : -1));
100
342
  }
101
- const current = images[index];
102
- return (_jsxs("section", { "aria-label": t("storefront.images"), className: "sf:flex sf:flex-col sf:gap-4", children: [_jsxs("div", { role: count > 1 ? "group" : undefined, "aria-roledescription": count > 1 ? "carousel" : undefined, tabIndex: count > 1 ? 0 : undefined, onKeyDown: keys, className: "sf:group sf:relative sf:isolate sf:grid sf:aspect-square sf:place-items-center sf:overflow-hidden sf:rounded-card sf:bg-surface sf:focus-visible:outline-2 sf:focus-visible:outline-offset-4 sf:focus-visible:outline-accent", children: [_jsx("span", { "aria-hidden": "true", className: "sf:absolute sf:top-[58%] sf:left-1/2 sf:-z-10 sf:h-[26%] sf:w-[118%] sf:-translate-x-1/2 sf:-rotate-6 sf:rounded-[50%] sf:border sf:border-ink/15" }), _jsx("span", { "aria-hidden": "true", className: "sf:absolute sf:top-1/2 sf:left-1/2 sf:-z-20 sf:size-[72%] sf:-translate-1/2 sf:rounded-full sf:bg-page/70 sf:blur-2xl" }), current ? (_jsx("img", { src: current.src, alt: current.alt, className: "sf:size-[82%] sf:object-contain sf:drop-shadow-[0_24px_30px_rgba(0,0,0,0.18)] sf:transition-transform sf:duration-500 sf:ease-out sf:group-hover:scale-[1.03] sf:motion-reduce:transition-none" }, current.src)) : _jsx(Bag, { className: "sf:size-16 sf:text-muted/50", strokeWidth: 1 }), count > 1 && (_jsxs("div", { className: "sf:absolute sf:bottom-6 sf:left-1/2 sf:flex sf:-translate-x-1/2 sf:items-center sf:gap-1 sf:rounded-full sf:border sf:border-line sf:bg-page/80 sf:p-1 sf:shadow-sm sf:backdrop-blur", children: [_jsx(RoundButton, { label: t("storefront.previousImage"), onClick: () => go(-1), children: _jsx(ChevronLeft, { className: "sf:size-5 sf:rtl:-scale-x-100" }) }), _jsxs("span", { className: "sf:min-w-12 sf:text-center sf:text-sm sf:text-muted sf:tabular-nums", "aria-live": "polite", children: [index + 1, " / ", count] }), _jsx(RoundButton, { label: t("storefront.nextImage"), onClick: () => go(1), children: _jsx(ChevronRight, { className: "sf:size-5 sf:rtl:-scale-x-100" }) })] }))] }), count > 1 && (_jsx("ul", { className: "sf:flex sf:gap-3 sf:overflow-x-auto sf:pb-1", children: images.map((image, at) => (_jsx("li", { className: "sf:shrink-0", children: _jsx("button", { type: "button", onClick: () => setIndex(at), "aria-label": t("storefront.showImage", { number: at + 1 }), "aria-current": at === index ? "true" : undefined, className: cx("sf:block sf:size-20 sf:overflow-hidden sf:rounded-full sf:border-2 sf:bg-surface sf:p-1 sf:transition sf:focus-visible:outline-2 sf:focus-visible:outline-offset-2 sf:focus-visible:outline-accent", at === index ? "sf:border-accent" : "sf:border-transparent sf:opacity-70 sf:hover:opacity-100"), children: _jsx("img", { src: image.thumb, alt: image.alt, loading: "lazy", className: "sf:size-full sf:rounded-full sf:object-cover" }) }) }, image.src))) }))] }));
343
+ return (_jsxs("section", { "aria-label": t("storefront.images"), className: "sf:flex sf:flex-col sf:gap-4", children: [_jsxs("div", { role: count > 1 ? "group" : undefined, "aria-roledescription": count > 1 ? "carousel" : undefined, tabIndex: count > 1 ? 0 : undefined, onKeyDown: keys, className: "sf:group sf:relative sf:isolate sf:aspect-square sf:overflow-hidden sf:rounded-card sf:bg-surface sf:focus-visible:outline-2 sf:focus-visible:outline-offset-4 sf:focus-visible:outline-accent", children: [_jsx("span", { "aria-hidden": "true", className: "sf:absolute sf:top-[58%] sf:left-1/2 sf:-z-10 sf:h-[26%] sf:w-[118%] sf:-translate-x-1/2 sf:-rotate-6 sf:rounded-[50%] sf:border sf:border-ink/15" }), _jsx("span", { "aria-hidden": "true", className: "sf:absolute sf:top-1/2 sf:left-1/2 sf:-z-20 sf:size-[72%] sf:-translate-1/2 sf:rounded-full sf:bg-page/70 sf:blur-2xl" }), count > 0 ? (_jsx("div", { ref: track, onScroll: onScroll, className: "sf-track sf:absolute sf:inset-0 sf:flex sf:snap-x sf:snap-mandatory sf:overflow-x-auto sf:overscroll-x-contain", children: images.map((image, at) => (_jsx("div", { className: "sf:grid sf:size-full sf:shrink-0 sf:snap-center sf:snap-always sf:place-items-center", "aria-hidden": at !== index ? true : undefined, children: _jsx("button", { type: "button", ref: at === index ? opener : undefined, tabIndex: at === index ? 0 : -1, onClick: () => zoom(true), "aria-label": t("storefront.zoomIn"), className: "sf:grid sf:size-full sf:cursor-zoom-in sf:place-items-center sf:focus-visible:outline-none", children: _jsx("img", { src: image.src, alt: image.alt, loading: at === 0 ? "eager" : "lazy", draggable: false, style: at === index && !zoomed ? { viewTransitionName: name } : undefined, className: cx(at === index && "sf-zoom-target", "sf-vt-product sf:size-[82%] sf:object-contain sf:drop-shadow-[0_24px_30px_rgba(0,0,0,0.18)] sf:transition-transform sf:duration-500 sf:ease-out sf:select-none sf:group-hover:scale-[1.03] sf:motion-reduce:transition-none") }) }) }, image.src))) })) : _jsx("div", { className: "sf:grid sf:size-full sf:place-items-center", children: _jsx(Bag, { className: "sf:size-16 sf:text-muted/50", strokeWidth: 1 }) }), count > 1 && (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": "true", className: "sf:pointer-events-none sf:absolute sf:bottom-5 sf:left-1/2 sf:flex sf:-translate-x-1/2 sf:gap-1.5 sf:sm:hidden", children: images.map((image, at) => _jsx("span", { className: cx("sf:h-1.5 sf:rounded-full sf:transition-all sf:duration-300", at === index ? "sf:w-5 sf:bg-ink" : "sf:w-1.5 sf:bg-ink/25") }, image.src)) }), _jsxs("div", { className: "sf:absolute sf:bottom-6 sf:left-1/2 sf:hidden sf:-translate-x-1/2 sf:items-center sf:gap-1 sf:rounded-full sf:border sf:border-line sf:bg-page/80 sf:p-1 sf:shadow-sm sf:backdrop-blur sf:sm:flex", children: [_jsx(RoundButton, { label: t("storefront.previousImage"), onClick: () => show(index - 1), children: _jsx(ChevronLeft, { className: "sf:size-5 sf:rtl:-scale-x-100" }) }), _jsxs("span", { className: "sf:min-w-12 sf:text-center sf:text-sm sf:text-muted sf:tabular-nums", "aria-live": "polite", children: [index + 1, " / ", count] }), _jsx(RoundButton, { label: t("storefront.nextImage"), onClick: () => show(index + 1), children: _jsx(ChevronRight, { className: "sf:size-5 sf:rtl:-scale-x-100" }) })] })] }))] }), zoomed && images[index] && (_jsxs("div", { role: "dialog", "aria-modal": "true", "aria-label": images[index].alt || t("storefront.images"), className: "sf-zoom sf:fixed sf:inset-0 sf:z-[60] sf:grid sf:cursor-zoom-out sf:place-items-center sf:p-4", onClick: () => zoom(false), children: [_jsx("img", { src: images[index].src, alt: images[index].alt, draggable: false, style: { viewTransitionName: name }, className: "sf-zoom-target sf-vt-product sf:max-h-[88dvh] sf:w-full sf:max-w-[min(92vw,56rem)] sf:object-contain sf:select-none" }), _jsx("button", { type: "button", autoFocus: true, onClick: (event) => { event.stopPropagation(); zoom(false); }, "aria-label": t("storefront.closeZoom"), className: "sf-zoom-close sf:fixed sf:end-4 sf:top-4 sf:grid sf:size-11 sf:place-items-center sf:rounded-full sf:border sf:border-line sf:bg-page sf:text-ink sf:shadow-card", children: _jsx(Close, {}) })] })), count > 1 && (_jsx("ul", { className: "sf-chips sf:flex sf:gap-3 sf:overflow-x-auto sf:pb-1", children: images.map((image, at) => (_jsx("li", { className: "sf:shrink-0", children: _jsx("button", { type: "button", onClick: () => show(at), "aria-label": t("storefront.showImage", { number: at + 1 }), "aria-current": at === index ? "true" : undefined, className: cx("sf:block sf:size-20 sf:overflow-hidden sf:rounded-full sf:border-2 sf:bg-surface sf:p-1 sf:transition sf:focus-visible:outline-2 sf:focus-visible:outline-offset-2 sf:focus-visible:outline-accent", at === index ? "sf:border-accent" : "sf:border-transparent sf:opacity-70 sf:hover:opacity-100"), children: _jsx("img", { src: image.thumb, alt: image.alt, loading: "lazy", className: "sf:size-full sf:rounded-full sf:object-cover" }) }) }, image.src))) }))] }));
103
344
  }
104
345
  /* ----------------------------------------------------------------- buy box */
105
346
  function Stepper({ value, max, onChange, id, words }) {
@@ -134,16 +375,72 @@ export function BuyBox({ product, price, compareAt, stock, variants = [], curren
134
375
  if (soldOut)
135
376
  return;
136
377
  addToCart(product, chosen?.id ?? null, quantity);
378
+ // A short tap, as an app gives, on phones that can. Only after a real tap, as browsers refuse it otherwise.
379
+ if (navigator.userActivation?.isActive)
380
+ navigator.vibrate?.(12);
137
381
  const submitter = event.nativeEvent.submitter;
138
382
  if (submitter?.getAttribute("value") === "buy")
139
383
  window.location.assign(sitePath(words, cartHref));
140
384
  else
141
385
  setAdded(true);
142
386
  }
143
- return (_jsxs("form", { onSubmit: submit, className: "sf:flex sf:flex-col sf:gap-7", children: [_jsxs("div", { className: "sf:flex sf:flex-wrap sf:items-end sf:gap-x-4 sf:gap-y-2", children: [amount !== null && _jsx("p", { className: "sf:text-4xl sf:font-semibold sf:tracking-tight sf:text-ink sf:tabular-nums sf:sm:text-5xl", children: money(formatNumber, amount, currency) }), compareAt !== null && amount !== null && compareAt > amount && _jsx("p", { className: "sf:pb-1.5 sf:text-lg sf:text-muted sf:tabular-nums", children: _jsx("s", { children: money(formatNumber, compareAt, currency) }) }), _jsxs("p", { className: cx("sf:ms-auto sf:mb-1.5 sf:inline-flex sf:items-center sf:gap-1.5 sf:rounded-full sf:px-3 sf:py-1 sf:text-sm sf:font-medium", soldOut ? "sf:bg-surface sf:text-muted" : "sf:bg-accent/10 sf:text-accent"), children: [!soldOut && _jsx(Check, { className: "sf:size-4" }), soldOut ? t("storefront.soldOut") : left !== null && left <= 5 ? t("storefront.onlyLeft", { count: left }) : t("storefront.inStock")] })] }), variants.length > 0 && (_jsxs("fieldset", { className: "sf:flex sf:flex-col sf:gap-3", children: [_jsx("legend", { className: "sf:mb-3 sf:text-sm sf:font-medium sf:text-muted", children: t("storefront.options") }), _jsx("div", { className: "sf:flex sf:flex-wrap sf:gap-2", children: variants.map((option) => (_jsxs("label", { className: "sf:relative", children: [_jsx("input", { type: "radio", name: `${id}-variant`, value: option.id, checked: variant === option.id, disabled: option.stock === 0, onChange: () => choose(option), className: "sf:peer sf:sr-only" }), _jsx("span", { className: "sf:inline-flex sf:h-12 sf:min-w-12 sf:cursor-pointer sf:items-center sf:justify-center sf:rounded-full sf:border sf:border-line sf:bg-page sf:px-4 sf:text-sm sf:font-medium sf:text-ink sf:transition sf:select-none sf:hover:border-ink sf:peer-checked:border-accent sf:peer-checked:bg-accent sf:peer-checked:text-on-accent sf:peer-focus-visible:ring-4 sf:peer-focus-visible:ring-accent/25 sf:peer-disabled:cursor-not-allowed sf:peer-disabled:text-muted sf:peer-disabled:line-through sf:peer-disabled:opacity-60 sf:peer-disabled:hover:border-line", children: option.title })] }, option.id))) })] })), !soldOut && (_jsxs("div", { className: "sf:flex sf:items-center sf:gap-4", children: [_jsx("label", { htmlFor: `${id}-quantity`, className: "sf:text-sm sf:font-medium sf:text-muted", children: t("storefront.quantity") }), _jsx(Stepper, { id: `${id}-quantity`, value: Math.min(quantity, max), max: max, onChange: (value) => { setQuantity(value); setAdded(false); }, words: words })] })), _jsxs("div", { className: "sf:grid sf:grid-cols-2 sf:gap-3", children: [_jsx("button", { type: "submit", value: "buy", disabled: soldOut, className: "sf:inline-flex sf:h-14 sf:items-center sf:justify-center sf:rounded-full sf:bg-accent sf:px-6 sf:text-base sf:font-semibold sf:text-on-accent sf:shadow-[0_10px_24px_-10px] sf:shadow-accent sf:transition sf:hover:brightness-110 sf:active:scale-[0.98] sf:disabled:cursor-not-allowed sf:disabled:opacity-50 sf:disabled:shadow-none sf:focus-visible:outline-2 sf:focus-visible:outline-offset-2 sf:focus-visible:outline-accent", children: t("storefront.buyNow") }), _jsx("button", { type: "submit", value: "add", disabled: soldOut, className: "sf:inline-flex sf:h-14 sf:items-center sf:justify-center sf:rounded-full sf:border sf:border-line sf:bg-surface sf:px-6 sf:text-base sf:font-semibold sf:text-ink sf:transition sf:hover:border-ink sf:active:scale-[0.98] sf:disabled:cursor-not-allowed sf:disabled:opacity-50 sf:focus-visible:outline-2 sf:focus-visible:outline-offset-2 sf:focus-visible:outline-accent", children: soldOut ? t("storefront.soldOut") : t("storefront.addToCart") })] }), _jsx("p", { role: "status", className: cx("sf:-mt-3 sf:text-sm sf:text-accent", !added && "sf:sr-only"), children: added && _jsxs(_Fragment, { children: [t("storefront.added"), " ", _jsx("a", { href: sitePath(words, cartHref), className: "sf:font-semibold sf:underline sf:underline-offset-4", children: t("storefront.viewCart") })] }) })] }));
387
+ return (_jsxs("form", { onSubmit: submit, className: "sf:flex sf:flex-col sf:gap-7", children: [_jsxs("div", { className: "sf:flex sf:flex-wrap sf:items-end sf:gap-x-4 sf:gap-y-2", children: [amount !== null && _jsx("p", { className: "sf:text-4xl sf:font-semibold sf:tracking-tight sf:text-ink sf:tabular-nums sf:sm:text-5xl", children: money(formatNumber, amount, currency) }), compareAt !== null && amount !== null && compareAt > amount && _jsx("p", { className: "sf:pb-1.5 sf:text-lg sf:text-muted sf:tabular-nums", children: _jsx("s", { children: money(formatNumber, compareAt, currency) }) }), _jsxs("p", { className: cx("sf:ms-auto sf:mb-1.5 sf:inline-flex sf:items-center sf:gap-1.5 sf:rounded-full sf:px-3 sf:py-1 sf:text-sm sf:font-medium", soldOut ? "sf:bg-surface sf:text-muted" : "sf:bg-accent/10 sf:text-accent"), children: [!soldOut && _jsx(Check, { className: "sf:size-4" }), soldOut ? t("storefront.soldOut") : left !== null && left <= 5 ? t("storefront.onlyLeft", { count: left }) : t("storefront.inStock")] })] }), variants.length > 0 && (_jsxs("fieldset", { className: "sf:flex sf:flex-col sf:gap-3", children: [_jsx("legend", { className: "sf:mb-3 sf:text-sm sf:font-medium sf:text-muted", children: t("storefront.options") }), _jsx("div", { className: "sf:flex sf:flex-wrap sf:gap-2", children: variants.map((option) => (_jsxs("label", { className: "sf:relative", children: [_jsx("input", { type: "radio", name: `${id}-variant`, value: option.id, checked: variant === option.id, disabled: option.stock === 0, onChange: () => choose(option), className: "sf:peer sf:sr-only" }), _jsx("span", { className: "sf:inline-flex sf:h-12 sf:min-w-12 sf:cursor-pointer sf:items-center sf:justify-center sf:rounded-full sf:border sf:border-line sf:bg-page sf:px-4 sf:text-sm sf:font-medium sf:text-ink sf:transition sf:select-none sf:hover:border-ink sf:peer-checked:border-accent sf:peer-checked:bg-accent sf:peer-checked:text-on-accent sf:peer-focus-visible:ring-4 sf:peer-focus-visible:ring-accent/25 sf:peer-disabled:cursor-not-allowed sf:peer-disabled:text-muted sf:peer-disabled:line-through sf:peer-disabled:opacity-60 sf:peer-disabled:hover:border-line", children: option.title })] }, option.id))) })] })), !soldOut && (_jsxs("div", { className: "sf:flex sf:items-center sf:gap-4", children: [_jsx("label", { htmlFor: `${id}-quantity`, className: "sf:text-sm sf:font-medium sf:text-muted", children: t("storefront.quantity") }), _jsx(Stepper, { id: `${id}-quantity`, value: Math.min(quantity, max), max: max, onChange: (value) => { setQuantity(value); setAdded(false); }, words: words })] })), _jsxs("div", { className: "sf-buybar sf:grid sf:grid-cols-2 sf:gap-3", children: [_jsx("button", { type: "submit", value: "buy", disabled: soldOut, className: "sf:inline-flex sf:h-14 sf:items-center sf:justify-center sf:rounded-full sf:bg-accent sf:px-6 sf:text-base sf:font-semibold sf:text-on-accent sf:shadow-[0_10px_24px_-10px] sf:shadow-accent sf:transition sf:hover:brightness-110 sf:active:scale-[0.98] sf:disabled:cursor-not-allowed sf:disabled:opacity-50 sf:disabled:shadow-none sf:focus-visible:outline-2 sf:focus-visible:outline-offset-2 sf:focus-visible:outline-accent", children: t("storefront.buyNow") }), _jsx("button", { type: "submit", value: "add", disabled: soldOut, className: "sf:inline-flex sf:h-14 sf:items-center sf:justify-center sf:rounded-full sf:border sf:border-line sf:bg-surface sf:px-6 sf:text-base sf:font-semibold sf:text-ink sf:transition sf:hover:border-ink sf:active:scale-[0.98] sf:disabled:cursor-not-allowed sf:disabled:opacity-50 sf:focus-visible:outline-2 sf:focus-visible:outline-offset-2 sf:focus-visible:outline-accent", children: soldOut ? t("storefront.soldOut") : t("storefront.addToCart") })] }), _jsx("p", { role: "status", className: cx("sf:-mt-3 sf:text-sm sf:text-accent", !added && "sf:sr-only"), children: added && _jsxs(_Fragment, { children: [t("storefront.added"), " ", _jsx("a", { href: sitePath(words, cartHref), className: "sf:font-semibold sf:underline sf:underline-offset-4", children: t("storefront.viewCart") })] }) })] }));
144
388
  }
145
389
  /* ------------------------------------------------------------------- share */
146
390
  /** The browser's share sheet where there is one, and copying the address where there isn't. */
391
+ const CAME_FROM = "sf-came-from";
392
+ const withoutHash = (href) => href.split("#")[0];
393
+ /** Where the visitor followed a link here from, when this page is where it led. */
394
+ function cameFrom() {
395
+ try {
396
+ const kind = performance.getEntriesByType("navigation")[0]?.type;
397
+ const note = JSON.parse(sessionStorage.getItem(CAME_FROM) ?? "null");
398
+ if ((kind !== "navigate" && !softNavigated) || !note || withoutHash(note.to) !== withoutHash(location.href))
399
+ return null;
400
+ const from = new URL(note.from);
401
+ return from.origin === location.origin && withoutHash(from.href) !== withoutHash(location.href) ? withoutHash(from.href) : null;
402
+ }
403
+ catch {
404
+ return null;
405
+ }
406
+ }
407
+ /** Leaves the note `cameFrom` reads whenever a link to another page here is followed. Rendered by the layout, on every page. */
408
+ function useCameFromNote() {
409
+ useEffect(() => {
410
+ const note = (event) => {
411
+ const link = event.target?.closest?.("a[href]");
412
+ if (!link || link.origin !== location.origin || link.target === "_blank" || link.hasAttribute("download"))
413
+ return;
414
+ try {
415
+ sessionStorage.setItem(CAME_FROM, JSON.stringify({ from: location.href, to: link.href }));
416
+ }
417
+ catch {
418
+ // Storage can be off. The back arrow then follows its own link.
419
+ }
420
+ };
421
+ document.addEventListener("click", note, true);
422
+ return () => document.removeEventListener("click", note, true);
423
+ }, []);
424
+ }
425
+ /**
426
+ * A back arrow that returns to the page the visitor came from, as an app's does. It goes there as
427
+ * a new move forward rather than back through history, so it gets the same transition as any link,
428
+ * and adds `#` and the card of `card`, the product being left: the browser scrolls that card into
429
+ * view as the page shows, so the list comes back where the visitor was and the product's
430
+ * picture flies back into its own card. The address is worked out once the page has loaded, before
431
+ * this page's own links leave a note of their own. Opened from a shared link or a new tab, it is
432
+ * `href`.
433
+ */
434
+ export function BackLink({ href, card, className, children }) {
435
+ const [target, setTarget] = useState(href);
436
+ const pathname = usePathname();
437
+ useEffect(() => {
438
+ const from = cameFrom();
439
+ // eslint-disable-next-line react-hooks/set-state-in-effect -- sessionStorage only exists in the browser
440
+ setTarget(from ? (card === undefined ? from : `${from}#${cardAnchor(card)}`) : href);
441
+ }, [card, href, pathname]);
442
+ return _jsx("a", { href: target, className: className, children: children });
443
+ }
147
444
  export function ShareButton({ title, words, className }) {
148
445
  const { t } = siteWords(words);
149
446
  const [copied, setCopied] = useState(false);
package/icons.d.ts CHANGED
@@ -5,6 +5,11 @@ export declare const ChevronLeft: (props: Props) => import("react").JSX.Element;
5
5
  export declare const ChevronRight: (props: Props) => import("react").JSX.Element;
6
6
  export declare const ChevronDown: (props: Props) => import("react").JSX.Element;
7
7
  export declare const Bag: (props: Props) => import("react").JSX.Element;
8
+ export declare const Store: (props: Props) => import("react").JSX.Element;
9
+ export declare const BookOpen: (props: Props) => import("react").JSX.Element;
10
+ export declare const Download: (props: Props) => import("react").JSX.Element;
11
+ export declare const Lock: (props: Props) => import("react").JSX.Element;
12
+ export declare const Close: (props: Props) => import("react").JSX.Element;
8
13
  export declare const User: (props: Props) => import("react").JSX.Element;
9
14
  export declare const Search: (props: Props) => import("react").JSX.Element;
10
15
  export declare const Send: (props: Props) => import("react").JSX.Element;
package/icons.js CHANGED
@@ -8,6 +8,11 @@ export const ChevronLeft = (props) => _jsx(Icon, { ...props, children: _jsx("pat
8
8
  export const ChevronRight = (props) => _jsx(Icon, { ...props, children: _jsx("path", { d: "m9 18 6-6-6-6" }) });
9
9
  export const ChevronDown = (props) => _jsx(Icon, { ...props, children: _jsx("path", { d: "m6 9 6 6 6-6" }) });
10
10
  export const Bag = (props) => _jsxs(Icon, { ...props, children: [_jsx("path", { d: "M5 8h14l-1 12H6L5 8Z" }), _jsx("path", { d: "M9 8V6a3 3 0 0 1 6 0v2" })] });
11
+ export const Store = (props) => _jsxs(Icon, { ...props, children: [_jsx("path", { d: "M4 10v10h16V10" }), _jsx("path", { d: "M3 10 5 4h14l2 6c0 1.7-1.3 3-3 3s-3-1.3-3-3c0 1.7-1.3 3-3 3s-3-1.3-3-3c0 1.7-1.3 3-3 3s-3-1.3-3-3Z" }), _jsx("path", { d: "M10 20v-5h4v5" })] });
12
+ export const BookOpen = (props) => _jsxs(Icon, { ...props, children: [_jsx("path", { d: "M12 6.5C10.3 5.2 7.9 4.5 4 4.5v14c3.9 0 6.3.7 8 2 1.7-1.3 4.1-2 8-2v-14c-3.9 0-6.3.7-8 2Z" }), _jsx("path", { d: "M12 6.5v14" })] });
13
+ export const Download = (props) => _jsxs(Icon, { ...props, children: [_jsx("path", { d: "M12 4v11m0 0-4-4m4 4 4-4" }), _jsx("path", { d: "M5 20h14" })] });
14
+ export const Lock = (props) => _jsxs(Icon, { ...props, children: [_jsx("rect", { x: "5", y: "11", width: "14", height: "9", rx: "2" }), _jsx("path", { d: "M8 11V8a4 4 0 0 1 8 0v3" })] });
15
+ export const Close = (props) => _jsx(Icon, { ...props, children: _jsx("path", { d: "M6 6l12 12M18 6 6 18" }) });
11
16
  export const User = (props) => _jsxs(Icon, { ...props, children: [_jsx("circle", { cx: "12", cy: "8", r: "4" }), _jsx("path", { d: "M4 21a8 8 0 0 1 16 0" })] });
12
17
  export const Search = (props) => _jsxs(Icon, { ...props, children: [_jsx("circle", { cx: "11", cy: "11", r: "7" }), _jsx("path", { d: "m20 20-3.5-3.5" })] });
13
18
  export const Send = (props) => _jsxs(Icon, { ...props, children: [_jsx("path", { d: "M21 3 10 14" }), _jsx("path", { d: "m21 3-7 18-4-7-7-4 18-7Z" })] });
package/index.d.ts CHANGED
@@ -5,6 +5,11 @@ export interface StorefrontOptions {
5
5
  search: boolean;
6
6
  /** An orders button in the header, for shops whose customers sign in to see their orders. */
7
7
  accountLinks: boolean;
8
+ /**
9
+ * The members' library: a Library tab and header link, for shops that sell memberships through
10
+ * Payments whose members read digital editions free. Its page is at /library.
11
+ */
12
+ library: boolean;
8
13
  /** "auto" follows the visitor's light or dark setting. "light" always shows the light colours. */
9
14
  colorScheme: "auto" | "light";
10
15
  }
@@ -13,4 +18,4 @@ export interface StorefrontOptions {
13
18
  * image stage, option chips and a quantity stepper, and a two-column cart. Checkout, orders
14
19
  * and the cart itself are the plugin's parts, so they behave as on the plugin's own pages.
15
20
  */
16
- export declare const storefront: ({ tagline, search, accountLinks, colorScheme }?: Partial<StorefrontOptions>) => import("tansy/theme").ThemeManifest<StorefrontOptions>;
21
+ export declare const storefront: ({ tagline, search, accountLinks, library, colorScheme }?: Partial<StorefrontOptions>) => import("tansy/theme").ThemeManifest<StorefrontOptions>;