@praxical/storefront 0.0.0-stage → 0.11.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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/app-card.d.ts +23 -0
- package/dist/app-card.js +7 -0
- package/dist/categories.d.ts +8 -0
- package/dist/categories.js +9 -0
- package/dist/chunk-2S25ONSZ.js +79 -0
- package/dist/chunk-3VUJFWN2.js +9 -0
- package/dist/chunk-CWNG7M2R.js +76 -0
- package/dist/chunk-GZ3EJYYQ.js +126 -0
- package/dist/chunk-KLXMWVYU.js +39 -0
- package/dist/chunk-MA2HFZ3M.js +31 -0
- package/dist/chunk-STDADX3Z.js +255 -0
- package/dist/discovery.d.ts +19 -0
- package/dist/discovery.js +11 -0
- package/dist/image-gallery.d.ts +14 -0
- package/dist/image-gallery.js +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +34 -0
- package/dist/links.d.ts +4 -0
- package/dist/links.js +7 -0
- package/dist/markdown.d.ts +7 -0
- package/dist/markdown.js +8 -0
- package/dist/presentation.css +520 -0
- package/dist/product.d.ts +30 -0
- package/dist/product.js +11 -0
- package/dist/scoped.css +545 -0
- package/package.json +81 -3
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// packages/storefront/src/image-gallery.tsx
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { ChevronLeft, ChevronRight, Expand } from "lucide-react";
|
|
6
|
+
import { ImageViewer } from "@praxical/ui/media";
|
|
7
|
+
import { accentStyle, isStoreImage } from "@praxical/design";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function ImageGallery({ images, accent, name }) {
|
|
10
|
+
const valid = images.filter((img) => isStoreImage(img.url));
|
|
11
|
+
return valid.length ? /* @__PURE__ */ jsx(
|
|
12
|
+
Gallery,
|
|
13
|
+
{
|
|
14
|
+
images: valid,
|
|
15
|
+
accent,
|
|
16
|
+
name
|
|
17
|
+
},
|
|
18
|
+
JSON.stringify(valid.map((img) => img.url))
|
|
19
|
+
) : null;
|
|
20
|
+
}
|
|
21
|
+
function Gallery({ images, accent, name }) {
|
|
22
|
+
const [selected, setSelected] = useState(0);
|
|
23
|
+
const [expanded, setExpanded] = useState(false);
|
|
24
|
+
const [dragging, setDragging] = useState(false);
|
|
25
|
+
const current = useRef(0), destination = useRef(null);
|
|
26
|
+
const track = useRef(null);
|
|
27
|
+
const portalContainer = useRef(null);
|
|
28
|
+
const drag = useRef(null);
|
|
29
|
+
const suppressClick = useRef(false);
|
|
30
|
+
const clamp = (index) => Math.max(0, Math.min(images.length - 1, index));
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const list = track.current;
|
|
33
|
+
if (!list) return;
|
|
34
|
+
const observer = new ResizeObserver(
|
|
35
|
+
() => list.scrollTo({
|
|
36
|
+
left: (destination.current ?? current.current) * list.clientWidth,
|
|
37
|
+
behavior: "instant"
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
observer.observe(list);
|
|
41
|
+
return () => observer.disconnect();
|
|
42
|
+
}, []);
|
|
43
|
+
function show(index) {
|
|
44
|
+
const next = clamp(index);
|
|
45
|
+
current.current = next;
|
|
46
|
+
destination.current = next;
|
|
47
|
+
setSelected(next);
|
|
48
|
+
const reduced = document.documentElement.dataset.motion === "reduced" || matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
49
|
+
track.current?.scrollTo({
|
|
50
|
+
left: next * track.current.clientWidth,
|
|
51
|
+
behavior: reduced ? "instant" : "smooth"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function endDrag(event) {
|
|
55
|
+
const gesture = drag.current;
|
|
56
|
+
if (!gesture || gesture.id !== event.pointerId) return;
|
|
57
|
+
drag.current = null;
|
|
58
|
+
setDragging(false);
|
|
59
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId))
|
|
60
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
61
|
+
if (gesture.moved) {
|
|
62
|
+
suppressClick.current = true;
|
|
63
|
+
show(
|
|
64
|
+
Math.round(
|
|
65
|
+
event.currentTarget.scrollLeft / event.currentTarget.clientWidth
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function arrows(key) {
|
|
71
|
+
return {
|
|
72
|
+
ArrowRight: current.current + 1,
|
|
73
|
+
ArrowLeft: current.current - 1,
|
|
74
|
+
Home: 0,
|
|
75
|
+
End: images.length - 1
|
|
76
|
+
}[key];
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ jsxs(
|
|
79
|
+
"section",
|
|
80
|
+
{
|
|
81
|
+
ref: portalContainer,
|
|
82
|
+
className: "image-gallery",
|
|
83
|
+
"aria-label": `${name} screenshots`,
|
|
84
|
+
"aria-roledescription": "carousel",
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
className: `gallery-track tone-${accent}${dragging ? " is-dragging" : ""}`,
|
|
90
|
+
style: accentStyle(accent),
|
|
91
|
+
ref: track,
|
|
92
|
+
onScroll: (event) => {
|
|
93
|
+
const list = event.currentTarget;
|
|
94
|
+
if (!list.clientWidth || drag.current?.moved) return;
|
|
95
|
+
if (destination.current !== null && Math.abs(list.scrollLeft - destination.current * list.clientWidth) > 1)
|
|
96
|
+
return;
|
|
97
|
+
destination.current = null;
|
|
98
|
+
const index = clamp(Math.round(list.scrollLeft / list.clientWidth));
|
|
99
|
+
current.current = index;
|
|
100
|
+
setSelected(index);
|
|
101
|
+
},
|
|
102
|
+
onPointerDown: (event) => {
|
|
103
|
+
destination.current = null;
|
|
104
|
+
suppressClick.current = false;
|
|
105
|
+
if (event.pointerType === "mouse" && event.button === 0)
|
|
106
|
+
drag.current = {
|
|
107
|
+
id: event.pointerId,
|
|
108
|
+
x: event.clientX,
|
|
109
|
+
y: event.clientY,
|
|
110
|
+
left: event.currentTarget.scrollLeft,
|
|
111
|
+
moved: false
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
onPointerMove: (event) => {
|
|
115
|
+
const gesture = drag.current;
|
|
116
|
+
if (!gesture || gesture.id !== event.pointerId) return;
|
|
117
|
+
const distance = event.clientX - gesture.x;
|
|
118
|
+
if (!gesture.moved && Math.abs(distance) > 8 && Math.abs(distance) > Math.abs(event.clientY - gesture.y)) {
|
|
119
|
+
gesture.moved = true;
|
|
120
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
121
|
+
setDragging(true);
|
|
122
|
+
}
|
|
123
|
+
if (gesture.moved) {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
event.currentTarget.scrollLeft = gesture.left - distance;
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
onPointerUp: endDrag,
|
|
129
|
+
onPointerCancel: endDrag,
|
|
130
|
+
onClickCapture: (event) => {
|
|
131
|
+
if (suppressClick.current) {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
event.stopPropagation();
|
|
134
|
+
suppressClick.current = false;
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
onWheel: () => {
|
|
138
|
+
destination.current = null;
|
|
139
|
+
},
|
|
140
|
+
onKeyDown: (event) => {
|
|
141
|
+
const next = arrows(event.key);
|
|
142
|
+
if (next !== void 0) {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
show(next);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
tabIndex: 0,
|
|
148
|
+
"aria-label": "Screenshot slides. Swipe or use Left and Right arrow keys.",
|
|
149
|
+
children: images.map((img, index) => /* @__PURE__ */ jsx(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
className: "gallery-slide",
|
|
153
|
+
role: "group",
|
|
154
|
+
"aria-roledescription": "slide",
|
|
155
|
+
"aria-label": `${index + 1} of ${images.length}`,
|
|
156
|
+
children: /* @__PURE__ */ jsxs(
|
|
157
|
+
"button",
|
|
158
|
+
{
|
|
159
|
+
type: "button",
|
|
160
|
+
className: "gallery-open",
|
|
161
|
+
tabIndex: selected === index ? 0 : -1,
|
|
162
|
+
"aria-label": `Enlarge screenshot ${index + 1} of ${name}`,
|
|
163
|
+
onClick: () => {
|
|
164
|
+
show(index);
|
|
165
|
+
setExpanded(true);
|
|
166
|
+
},
|
|
167
|
+
children: [
|
|
168
|
+
/* @__PURE__ */ jsx(
|
|
169
|
+
"img",
|
|
170
|
+
{
|
|
171
|
+
src: img.url,
|
|
172
|
+
alt: img.alt,
|
|
173
|
+
width: img.width,
|
|
174
|
+
height: img.height,
|
|
175
|
+
loading: index === 0 ? "eager" : "lazy",
|
|
176
|
+
draggable: false
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
/* @__PURE__ */ jsxs("span", { className: "gallery-expand-hint", children: [
|
|
180
|
+
/* @__PURE__ */ jsx(Expand, { size: 16 }),
|
|
181
|
+
" Enlarge"
|
|
182
|
+
] })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
},
|
|
187
|
+
img.url
|
|
188
|
+
))
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
/* @__PURE__ */ jsxs("div", { className: "gallery-controls", children: [
|
|
192
|
+
/* @__PURE__ */ jsxs("p", { "aria-live": "polite", "aria-atomic": "true", children: [
|
|
193
|
+
images[selected].alt,
|
|
194
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
195
|
+
selected + 1,
|
|
196
|
+
" / ",
|
|
197
|
+
images.length
|
|
198
|
+
] })
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
201
|
+
/* @__PURE__ */ jsx(
|
|
202
|
+
"button",
|
|
203
|
+
{
|
|
204
|
+
type: "button",
|
|
205
|
+
className: "icon-button",
|
|
206
|
+
"aria-label": "Previous screenshot",
|
|
207
|
+
disabled: selected === 0,
|
|
208
|
+
onClick: () => show(selected - 1),
|
|
209
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { size: 20 })
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ jsx(
|
|
213
|
+
"button",
|
|
214
|
+
{
|
|
215
|
+
type: "button",
|
|
216
|
+
className: "icon-button",
|
|
217
|
+
"aria-label": "Next screenshot",
|
|
218
|
+
disabled: selected === images.length - 1,
|
|
219
|
+
onClick: () => show(selected + 1),
|
|
220
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { size: 20 })
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] })
|
|
224
|
+
] }),
|
|
225
|
+
images.length > 1 && /* @__PURE__ */ jsx("div", { className: "gallery-thumbnails", children: images.map((img, index) => /* @__PURE__ */ jsx(
|
|
226
|
+
"button",
|
|
227
|
+
{
|
|
228
|
+
type: "button",
|
|
229
|
+
"aria-label": `Show screenshot ${index + 1}: ${img.alt}`,
|
|
230
|
+
"aria-pressed": selected === index,
|
|
231
|
+
onClick: () => show(index),
|
|
232
|
+
children: /* @__PURE__ */ jsx("img", { src: img.url, alt: "", loading: "lazy", draggable: false })
|
|
233
|
+
},
|
|
234
|
+
img.url
|
|
235
|
+
)) }),
|
|
236
|
+
/* @__PURE__ */ jsx(
|
|
237
|
+
ImageViewer,
|
|
238
|
+
{
|
|
239
|
+
images,
|
|
240
|
+
title: `${name} screenshots`,
|
|
241
|
+
open: expanded,
|
|
242
|
+
onOpenChange: setExpanded,
|
|
243
|
+
selected,
|
|
244
|
+
onSelectedChange: show,
|
|
245
|
+
finalFocus: () => track.current?.querySelectorAll(".gallery-open")[current.current] ?? null
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export {
|
|
254
|
+
ImageGallery
|
|
255
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { CardApp } from "./app-card.js";
|
|
3
|
+
import { type LinkRenderer } from "./links.js";
|
|
4
|
+
export type FeaturedApp = CardApp & {
|
|
5
|
+
id: string;
|
|
6
|
+
category: string;
|
|
7
|
+
};
|
|
8
|
+
/** @deprecated Legacy featured grid on unprefixed roles. Compose from `@praxical/ui` instead (Pane, ServiceRow or Tiles with AppIcon, Badge for the price, PageHeader with `media`); kept through 0.8.x and removed no earlier than 0.9. */
|
|
9
|
+
export declare function FeaturedApps({ apps, pickedIDs, variant, renderLink, }: {
|
|
10
|
+
apps: FeaturedApp[];
|
|
11
|
+
pickedIDs?: string[];
|
|
12
|
+
variant?: "lined" | "plain" | "bordered";
|
|
13
|
+
renderLink?: LinkRenderer;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
/** @deprecated Legacy Folium hero artwork. Compose from `@praxical/ui` instead (Pane, ServiceRow or Tiles with AppIcon, Badge for the price, PageHeader with `media`); kept through 0.8.x and removed no earlier than 0.9. */
|
|
16
|
+
export declare function FoliumFeature({ artwork, renderLink, }: {
|
|
17
|
+
artwork: ReactNode;
|
|
18
|
+
renderLink?: LinkRenderer;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Screenshot = {
|
|
2
|
+
media_id?: string;
|
|
3
|
+
url: string;
|
|
4
|
+
alt: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
};
|
|
8
|
+
type GalleryProps = {
|
|
9
|
+
images: Screenshot[];
|
|
10
|
+
accent: string;
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function ImageGallery({ images, accent, name }: GalleryProps): import("react").JSX.Element | null;
|
|
14
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AppCardView } from "./app-card.js";
|
|
2
|
+
export type { CardApp, CardLinkProps } from "./app-card.js";
|
|
3
|
+
export { ImageGallery } from "./image-gallery.js";
|
|
4
|
+
export type { Screenshot } from "./image-gallery.js";
|
|
5
|
+
export { Markdown } from "./markdown.js";
|
|
6
|
+
export type { LinkRenderer, MarkdownLinkProps } from "./markdown.js";
|
|
7
|
+
export { ProductHeader, ProductOverview } from "./product.js";
|
|
8
|
+
export type { ProductContent } from "./product.js";
|
|
9
|
+
export { FeaturedApps, FoliumFeature } from "./discovery.js";
|
|
10
|
+
export { categories, categoryName } from "./categories.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
AppCardView
|
|
4
|
+
} from "./chunk-KLXMWVYU.js";
|
|
5
|
+
import {
|
|
6
|
+
FeaturedApps,
|
|
7
|
+
FoliumFeature
|
|
8
|
+
} from "./chunk-CWNG7M2R.js";
|
|
9
|
+
import {
|
|
10
|
+
categories,
|
|
11
|
+
categoryName
|
|
12
|
+
} from "./chunk-2S25ONSZ.js";
|
|
13
|
+
import {
|
|
14
|
+
ImageGallery
|
|
15
|
+
} from "./chunk-STDADX3Z.js";
|
|
16
|
+
import {
|
|
17
|
+
ProductHeader,
|
|
18
|
+
ProductOverview
|
|
19
|
+
} from "./chunk-GZ3EJYYQ.js";
|
|
20
|
+
import {
|
|
21
|
+
Markdown
|
|
22
|
+
} from "./chunk-MA2HFZ3M.js";
|
|
23
|
+
import "./chunk-3VUJFWN2.js";
|
|
24
|
+
export {
|
|
25
|
+
AppCardView,
|
|
26
|
+
FeaturedApps,
|
|
27
|
+
FoliumFeature,
|
|
28
|
+
ImageGallery,
|
|
29
|
+
Markdown,
|
|
30
|
+
ProductHeader,
|
|
31
|
+
ProductOverview,
|
|
32
|
+
categories,
|
|
33
|
+
categoryName
|
|
34
|
+
};
|
package/dist/links.d.ts
ADDED
package/dist/links.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type LinkRenderer } from "./links.js";
|
|
2
|
+
export type { LinkRenderer, MarkdownLinkProps } from "./links.js";
|
|
3
|
+
/** Publisher HTML and remote image loads are deliberately excluded. */
|
|
4
|
+
export declare function Markdown({ children, renderLink, }: {
|
|
5
|
+
children: string;
|
|
6
|
+
renderLink?: LinkRenderer;
|
|
7
|
+
}): import("react").JSX.Element;
|