@chinggis.systems/collection-ui 1.0.0 → 1.0.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/README.md +21 -36
- package/dist/CollectionRenderer.d.ts +2 -2
- package/dist/CollectionRenderer.d.ts.map +1 -1
- package/dist/CollectionRenderer.js +305 -292
- package/dist/CollectionRenderer.js.map +1 -1
- package/dist/CollectionView.d.ts +13 -0
- package/dist/CollectionView.d.ts.map +1 -0
- package/dist/CollectionView.js +42 -0
- package/dist/CollectionView.js.map +1 -0
- package/dist/assets/spine/BurnBlend.png +0 -0
- package/dist/assets/spine/FlatEdges.webp +0 -0
- package/dist/assets/spine/FlatShadow.webp +0 -0
- package/dist/assets/spine/NormalBlend.webp +0 -0
- package/dist/assets/spine/SoftLightBlend.webp +0 -0
- package/dist/collectionV2Model.d.ts +43 -0
- package/dist/collectionV2Model.d.ts.map +1 -0
- package/dist/collectionV2Model.js +4 -0
- package/dist/collectionV2Model.js.map +1 -0
- package/dist/createAdapters.d.ts +66 -74
- package/dist/createAdapters.d.ts.map +1 -1
- package/dist/createAdapters.js +223 -223
- package/dist/createAdapters.js.map +1 -1
- package/dist/defaultAdapters.d.ts +7 -7
- package/dist/defaultAdapters.js +8 -8
- package/dist/index.d.ts +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/layoutPresets.d.ts +18 -18
- package/dist/layoutPresets.js +129 -129
- package/dist/primitives/BookSpine.d.ts +11 -11
- package/dist/primitives/BookSpine.js +10 -10
- package/dist/primitives/CollectionCarousel.d.ts +3 -3
- package/dist/primitives/CollectionCarousel.d.ts.map +1 -1
- package/dist/primitives/CollectionCarousel.js +22 -13
- package/dist/primitives/CollectionCarousel.js.map +1 -1
- package/dist/styles.css +236 -51
- package/dist/types.d.ts +141 -141
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +8 -8
- package/dist/utils.js +26 -26
- package/package.json +1 -1
|
@@ -1,293 +1,306 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useId } from "react";
|
|
3
|
-
import { defaultAdapters } from "./defaultAdapters";
|
|
4
|
-
import { compact, cx, hasCollections, hasItems, sortCollections, } from "./utils";
|
|
5
|
-
const defaultLabels = {
|
|
6
|
-
all: "All",
|
|
7
|
-
viewAll: "View all",
|
|
8
|
-
readMore: "Read more",
|
|
9
|
-
previous: "Previous",
|
|
10
|
-
next: "Next",
|
|
11
|
-
};
|
|
12
|
-
export function CollectionRenderer({ collection, layout, adapters, labels, className, }) {
|
|
13
|
-
const resolvedLayout = layout ?? collection.layout;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
case "
|
|
47
|
-
if (!
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return (_jsx(
|
|
51
|
-
}
|
|
52
|
-
case "
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
case "
|
|
66
|
-
if (!
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return (_jsx(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
case "
|
|
83
|
-
if (!hasCollections(collection)) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
return (_jsx(
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, } from "react";
|
|
3
|
+
import { defaultAdapters } from "./defaultAdapters";
|
|
4
|
+
import { compact, cx, hasCollections, hasItems, sortCollections, } from "./utils";
|
|
5
|
+
const defaultLabels = {
|
|
6
|
+
all: "All",
|
|
7
|
+
viewAll: "View all",
|
|
8
|
+
readMore: "Read more",
|
|
9
|
+
previous: "Previous",
|
|
10
|
+
next: "Next",
|
|
11
|
+
};
|
|
12
|
+
export function CollectionRenderer({ collection, layout, adapters, labels, className, }) {
|
|
13
|
+
const resolvedLayout = layout ?? collection.layout;
|
|
14
|
+
const isPreview = className?.split(/\s+/).includes("collection-ui--preview");
|
|
15
|
+
if (!resolvedLayout) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return (_jsx("div", { className: cx("collection-ui", className), "data-layout": resolvedLayout.name, "data-direction": resolvedLayout.direction ?? undefined, onClickCapture: isPreview ? preventPreviewNavigation : undefined, style: {
|
|
19
|
+
"--collection-ui-columns": resolvedLayout.columns ?? undefined,
|
|
20
|
+
}, children: _jsx(CollectionBody, { collection: collection, layout: resolvedLayout, adapters: adapters, labels: { ...defaultLabels, ...labels } }) }));
|
|
21
|
+
}
|
|
22
|
+
function preventPreviewNavigation(event) {
|
|
23
|
+
const target = event.target;
|
|
24
|
+
if (!(target instanceof Element)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const link = target.closest("a[href]");
|
|
28
|
+
if (link) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
event.stopPropagation();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function CollectionBody({ collection, layout, adapters, labels, }) {
|
|
34
|
+
switch (layout.name) {
|
|
35
|
+
case "dynamic":
|
|
36
|
+
case "list": {
|
|
37
|
+
if (!hasItems(collection)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (layout.direction === "vertical") {
|
|
41
|
+
return (_jsx(VerticalList, { collection: collection, items: compact(collection.items), adapters: adapters, labels: labels, numbered: layout.isNumbered }));
|
|
42
|
+
}
|
|
43
|
+
return (_jsx(HorizontalList, { collection: collection, items: compact(collection.items), adapters: adapters, labels: labels }));
|
|
44
|
+
}
|
|
45
|
+
case "grid":
|
|
46
|
+
case "relative": {
|
|
47
|
+
if (!hasItems(collection)) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return (_jsx(GridList, { collection: collection, items: compact(collection.items), adapters: adapters, labels: labels }));
|
|
51
|
+
}
|
|
52
|
+
case "carousel": {
|
|
53
|
+
if (!hasItems(collection)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return (_jsx(HorizontalList, { collection: collection, items: compact(collection.items), adapters: adapters, labels: labels }));
|
|
57
|
+
}
|
|
58
|
+
case "grid-title": {
|
|
59
|
+
if (!hasCollections(collection)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return (_jsx(GridTitle, { collection: collection, adapters: adapters, labels: labels, itemLimit: layout.itemLimit ?? 3 }));
|
|
63
|
+
}
|
|
64
|
+
case "hero":
|
|
65
|
+
case "banner": {
|
|
66
|
+
if (!collection.imageUrl) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return (_jsx(LargeBanner, { collection: collection, adapters: adapters, labels: labels }));
|
|
70
|
+
}
|
|
71
|
+
case "special": {
|
|
72
|
+
if (!hasItems(collection)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return (_jsx(SpecialItem, { collection: collection, adapters: adapters, labels: labels }));
|
|
76
|
+
}
|
|
77
|
+
case "slide":
|
|
78
|
+
if (!hasCollections(collection)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return (_jsx(SlideShow, { collections: compact(collection.collections), adapters: adapters, labels: labels }));
|
|
82
|
+
case "featured": {
|
|
83
|
+
if (!hasCollections(collection)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return (_jsx(FeaturedBanners, { collections: compact(collection.collections), adapters: adapters, labels: labels }));
|
|
87
|
+
}
|
|
88
|
+
case "image-grid": {
|
|
89
|
+
if (!hasCollections(collection)) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return (_jsx(ImageGrid, { collection: collection, adapters: adapters, labels: labels, variant: layout.shape === "square" ? "square" : "circle" }));
|
|
93
|
+
}
|
|
94
|
+
case "block-grid": {
|
|
95
|
+
if (!hasCollections(collection)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return (_jsx(ImageGrid, { collection: collection, adapters: adapters, labels: labels, variant: "block" }));
|
|
99
|
+
}
|
|
100
|
+
default:
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function getAdapters(adapters) {
|
|
105
|
+
return { ...defaultAdapters, ...adapters };
|
|
106
|
+
}
|
|
107
|
+
function renderItem(adapters, props) {
|
|
108
|
+
return adapters.renderItem({
|
|
109
|
+
...props,
|
|
110
|
+
renderBookMedia: adapters.renderBookMedia,
|
|
111
|
+
renderPrice: adapters.renderPrice,
|
|
112
|
+
renderHtml: adapters.renderHtml,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function Container({ adapters, children, className, }) {
|
|
116
|
+
const resolved = getAdapters(adapters);
|
|
117
|
+
return resolved.renderContainer(children, {
|
|
118
|
+
className: cx("collection-ui-container", className),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function LinkAdapter({ adapters, href, children, className, collection, item, onClick, }) {
|
|
122
|
+
const resolved = getAdapters(adapters);
|
|
123
|
+
if (!href) {
|
|
124
|
+
return _jsx(_Fragment, { children: children });
|
|
125
|
+
}
|
|
126
|
+
return (_jsx(_Fragment, { children: resolved.renderLink({
|
|
127
|
+
href,
|
|
128
|
+
children,
|
|
129
|
+
className,
|
|
130
|
+
collection,
|
|
131
|
+
item,
|
|
132
|
+
onClick,
|
|
133
|
+
}) }));
|
|
134
|
+
}
|
|
135
|
+
function ImageAdapter(props) {
|
|
136
|
+
const resolved = getAdapters(props.adapters);
|
|
137
|
+
if (!props.src) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return _jsx(_Fragment, { children: resolved.renderImage(props) });
|
|
141
|
+
}
|
|
142
|
+
function SectionTitle({ collection, adapters, labels, small, actions, }) {
|
|
143
|
+
const resolved = getAdapters(adapters);
|
|
144
|
+
const href = resolved.resolveCollectionHref(collection);
|
|
145
|
+
return (_jsxs("div", { className: "collection-ui-title", children: [_jsxs("div", { className: "collection-ui-title__row", children: [_jsx("h2", { className: cx("collection-ui-title__heading", small && "collection-ui-title__heading--small"), children: href ? (_jsx(LinkAdapter, { adapters: adapters, href: href, collection: collection, children: collection.name })) : (collection.name) }), href || actions ? (_jsxs("div", { className: "collection-ui-title__actions", children: [href ? (_jsx(LinkAdapter, { adapters: adapters, href: href, collection: collection, className: "collection-ui-title__link", children: small ? labels.all : labels.viewAll })) : null, actions] })) : null] }), collection.description ? (_jsx("p", { className: "collection-ui-title__description", children: collection.description })) : null] }));
|
|
146
|
+
}
|
|
147
|
+
function HorizontalList({ collection, items, adapters, labels, }) {
|
|
148
|
+
const id = useId().replaceAll(":", "");
|
|
149
|
+
const carouselId = `collection-carousel-${id}`;
|
|
150
|
+
const resolved = getAdapters(adapters);
|
|
151
|
+
const collectionHref = resolved.resolveCollectionHref(collection);
|
|
152
|
+
const slides = items.map((item, index) => {
|
|
153
|
+
const href = resolved.resolveItemHref(item);
|
|
154
|
+
return renderItem(resolved, {
|
|
155
|
+
item,
|
|
156
|
+
href,
|
|
157
|
+
index,
|
|
158
|
+
variant: "card",
|
|
159
|
+
collection,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
if (collectionHref) {
|
|
163
|
+
slides.push(_jsxs(LinkAdapter, { adapters: adapters, href: collectionHref, collection: collection, className: "collection-ui-view-all", children: [_jsx("span", { className: "collection-ui-view-all__icon", "aria-hidden": "true", children: ">" }), _jsx("span", { children: labels.viewAll })] }));
|
|
164
|
+
}
|
|
165
|
+
return (_jsx(Container, { adapters: adapters, children: _jsxs("section", { className: "collection-ui-horizontal", "aria-labelledby": `collection-title-${id}`, children: [_jsx("div", { id: `collection-title-${id}`, children: _jsx(SectionTitle, { collection: collection, adapters: adapters, labels: labels, actions: _jsxs("div", { className: "collection-ui-title__controls", children: [_jsx("button", { type: "button", "aria-controls": carouselId, "aria-label": labels.previous, className: `prev-btn-${carouselId} collection-ui-carousel__prev-${carouselId} prev-btn`, children: "<" }), _jsx("button", { type: "button", "aria-controls": carouselId, "aria-label": labels.next, className: `next-btn-${carouselId} collection-ui-carousel__next-${carouselId} next-btn`, children: ">" })] }) }) }), resolved.renderCarousel({
|
|
166
|
+
id: carouselId,
|
|
167
|
+
slides,
|
|
168
|
+
className: "collection-ui-carousel__track",
|
|
169
|
+
slideClassName: "collection-ui-carousel__slide",
|
|
170
|
+
previousLabel: labels.previous,
|
|
171
|
+
nextLabel: labels.next,
|
|
172
|
+
showControls: false,
|
|
173
|
+
slidesPerView: "auto",
|
|
174
|
+
slidesPerGroupAuto: true,
|
|
175
|
+
spaceBetween: 20,
|
|
176
|
+
})] }) }));
|
|
177
|
+
}
|
|
178
|
+
function GridList({ collection, items, adapters, labels, }) {
|
|
179
|
+
const resolved = getAdapters(adapters);
|
|
180
|
+
const collectionHref = resolved.resolveCollectionHref(collection);
|
|
181
|
+
const cards = items.map((item, index) => {
|
|
182
|
+
const href = resolved.resolveItemHref(item);
|
|
183
|
+
return (_jsx("div", { className: "collection-ui-grid__item", children: renderItem(resolved, {
|
|
184
|
+
item,
|
|
185
|
+
href,
|
|
186
|
+
index,
|
|
187
|
+
variant: "card",
|
|
188
|
+
collection,
|
|
189
|
+
}) }, item.id));
|
|
190
|
+
});
|
|
191
|
+
return (_jsx(Container, { adapters: adapters, children: _jsxs("section", { className: "collection-ui-grid", "aria-label": collection.name ?? undefined, children: [_jsx(SectionTitle, { collection: collection, adapters: adapters, labels: labels }), _jsxs("div", { className: "collection-ui-grid__items", children: [cards, collectionHref ? (_jsxs(LinkAdapter, { adapters: adapters, href: collectionHref, collection: collection, className: "collection-ui-view-all collection-ui-grid__view-all", children: [_jsx("span", { className: "collection-ui-view-all__icon", "aria-hidden": "true", children: ">" }), _jsx("span", { children: labels.viewAll })] })) : null] })] }) }));
|
|
192
|
+
}
|
|
193
|
+
function VerticalList({ collection, items, adapters, labels, numbered, limit, hideTitle, }) {
|
|
194
|
+
const resolved = getAdapters(adapters);
|
|
195
|
+
const visibleItems = limit ? items.slice(0, limit) : items;
|
|
196
|
+
return (_jsx(Container, { adapters: adapters, children: _jsxs("section", { className: "collection-ui-vertical", children: [hideTitle ? null : (_jsx(SectionTitle, { collection: collection, adapters: adapters, labels: labels })), _jsx("div", { className: "collection-ui-vertical__grid", role: "list", children: visibleItems.map((item, index) => {
|
|
197
|
+
const href = resolved.resolveItemHref(item);
|
|
198
|
+
return (_jsx("div", { className: "collection-ui-vertical__item", role: "listitem", children: renderItem(resolved, {
|
|
199
|
+
item,
|
|
200
|
+
href,
|
|
201
|
+
index,
|
|
202
|
+
number: numbered ? index + 1 : undefined,
|
|
203
|
+
variant: "vertical",
|
|
204
|
+
collection,
|
|
205
|
+
}) }, item.id));
|
|
206
|
+
}) })] }) }));
|
|
207
|
+
}
|
|
208
|
+
function GridTitle({ collection, adapters, labels, itemLimit, }) {
|
|
209
|
+
const id = useId().replaceAll(":", "");
|
|
210
|
+
const resolved = getAdapters(adapters);
|
|
211
|
+
const slides = compact(collection.collections).map((child) => (_jsxs("div", { className: "collection-ui-grid-title__panel", children: [_jsx(SectionTitle, { collection: child, adapters: adapters, labels: labels, small: true }), _jsx(VerticalList, { collection: child, items: compact(child.items), adapters: adapters, labels: labels, numbered: true, limit: itemLimit, hideTitle: true })] }, child.id)));
|
|
212
|
+
return (_jsx("section", { className: "collection-ui-band", children: _jsxs(Container, { adapters: adapters, children: [_jsx(SectionTitle, { collection: collection, adapters: adapters, labels: labels }), resolved.renderCarousel({
|
|
213
|
+
id: `collection-grid-title-${id}`,
|
|
214
|
+
slides,
|
|
215
|
+
className: "collection-ui-grid-title",
|
|
216
|
+
slideClassName: "collection-ui-grid-title__slide",
|
|
217
|
+
previousLabel: labels.previous,
|
|
218
|
+
nextLabel: labels.next,
|
|
219
|
+
showControls: true,
|
|
220
|
+
slidesPerView: 1,
|
|
221
|
+
slidesPerGroupAuto: false,
|
|
222
|
+
spaceBetween: 24,
|
|
223
|
+
breakpoints: {
|
|
224
|
+
1280: {
|
|
225
|
+
slidesPerView: 2,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
})] }) }));
|
|
229
|
+
}
|
|
230
|
+
function LargeBanner({ collection, adapters, labels, }) {
|
|
231
|
+
const resolved = getAdapters(adapters);
|
|
232
|
+
const href = resolved.resolveCollectionHref(collection);
|
|
233
|
+
const handleClick = () => resolved.onCollectionClick?.(collection, href);
|
|
234
|
+
return (_jsx(Container, { adapters: adapters, className: "collection-ui-container--wide", children: _jsxs("section", { className: "collection-ui-banner", children: [_jsxs("div", { className: "collection-ui-banner__copy", children: [collection.type ? (_jsx("div", { className: "collection-ui-banner__eyebrow", children: resolved.formatCollectionType(collection.type) })) : null, _jsx("h2", { className: "collection-ui-banner__title", children: collection.name }), collection.description ? (_jsx("p", { className: "collection-ui-banner__description", children: collection.description })) : null, href ? (_jsx(LinkAdapter, { adapters: adapters, href: href, collection: collection, onClick: handleClick, className: "collection-ui-button", children: labels.readMore })) : null] }), collection.imageUrl ? (_jsx(LinkAdapter, { adapters: adapters, href: href ?? "", collection: collection, onClick: handleClick, children: _jsx(ImageAdapter, { adapters: adapters, src: collection.imageUrl, alt: collection.name ?? "Collection banner", width: 1003, height: 564, priority: true, sizes: "(max-width: 768px) 100vw, 1003px", className: "collection-ui-banner__image", collection: collection, style: { height: "auto" } }) })) : null] }) }));
|
|
235
|
+
}
|
|
236
|
+
function SpecialItem({ collection, adapters, labels, }) {
|
|
237
|
+
const item = compact(collection.items)[0];
|
|
238
|
+
const resolved = getAdapters(adapters);
|
|
239
|
+
if (!item) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const href = resolved.resolveItemHref(item);
|
|
243
|
+
return (_jsx("section", { className: "collection-ui-band", children: _jsx(Container, { adapters: adapters, children: _jsxs("div", { className: "collection-ui-special", children: [renderItem(resolved, {
|
|
244
|
+
item,
|
|
245
|
+
href,
|
|
246
|
+
index: 0,
|
|
247
|
+
variant: "special",
|
|
248
|
+
collection,
|
|
249
|
+
}), href ? (_jsx(LinkAdapter, { adapters: adapters, href: href, item: item, collection: collection, onClick: () => resolved.onItemClick?.(item, href), className: "collection-ui-button collection-ui-special__button", children: labels.readMore })) : null] }) }) }));
|
|
250
|
+
}
|
|
251
|
+
function FeaturedBanners({ collections, adapters, labels, }) {
|
|
252
|
+
return (_jsx(Container, { adapters: adapters, className: "collection-ui-container--wide", children: _jsx("div", { className: cx("collection-ui-featured", collections.length >= 3 && "collection-ui-featured--three"), children: sortCollections(collections).map((collection) => (_jsx(FeaturedBanner, { collection: collection, adapters: adapters, labels: labels }, collection.id))) }) }));
|
|
253
|
+
}
|
|
254
|
+
function SlideShow({ collections, adapters, labels, }) {
|
|
255
|
+
const id = useId().replaceAll(":", "");
|
|
256
|
+
const resolved = getAdapters(adapters);
|
|
257
|
+
const slides = sortCollections(collections).map((collection) => (_jsx("div", { className: "collection-ui-slide__item", children: _jsx(FeaturedBanner, { collection: collection, adapters: adapters, labels: labels }) }, collection.id)));
|
|
258
|
+
return (_jsx(Container, { adapters: adapters, className: "collection-ui-container--wide", children: _jsx("section", { className: "collection-ui-slide", children: resolved.renderCarousel({
|
|
259
|
+
id: `collection-slide-${id}`,
|
|
260
|
+
slides,
|
|
261
|
+
className: "collection-ui-slide__track",
|
|
262
|
+
slideClassName: "collection-ui-slide__slide",
|
|
263
|
+
previousLabel: labels.previous,
|
|
264
|
+
nextLabel: labels.next,
|
|
265
|
+
showControls: true,
|
|
266
|
+
effect: "coverflow",
|
|
267
|
+
centeredSlides: true,
|
|
268
|
+
loop: slides.length > 1,
|
|
269
|
+
slidesPerView: 1.1,
|
|
270
|
+
slidesPerGroupAuto: false,
|
|
271
|
+
spaceBetween: 20,
|
|
272
|
+
breakpoints: {
|
|
273
|
+
768: {
|
|
274
|
+
slidesPerView: 1.35,
|
|
275
|
+
spaceBetween: 24,
|
|
276
|
+
},
|
|
277
|
+
1200: {
|
|
278
|
+
slidesPerView: 1.6,
|
|
279
|
+
spaceBetween: 28,
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
}) }) }));
|
|
283
|
+
}
|
|
284
|
+
function FeaturedBanner({ collection, adapters, labels, }) {
|
|
285
|
+
const resolved = getAdapters(adapters);
|
|
286
|
+
const href = resolved.resolveCollectionHref(collection);
|
|
287
|
+
const handleClick = () => resolved.onCollectionClick?.(collection, href);
|
|
288
|
+
if (!collection.imageUrl) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
return (_jsxs("article", { className: "collection-ui-featured-card", children: [_jsx(LinkAdapter, { adapters: adapters, href: href ?? "", collection: collection, onClick: handleClick, children: _jsx(ImageAdapter, { adapters: adapters, src: collection.imageUrl, alt: collection.name ?? "", width: 740, height: 417, priority: true, className: "collection-ui-featured-card__image", collection: collection, style: { height: "auto" } }) }), _jsxs("div", { className: "collection-ui-featured-card__body", children: [_jsx("h2", { className: "collection-ui-featured-card__title", children: _jsx(LinkAdapter, { adapters: adapters, href: href ?? "", collection: collection, onClick: handleClick, children: collection.name }) }), collection.description ? (_jsx("p", { className: "collection-ui-featured-card__description", children: collection.description })) : null, href ? (_jsx(LinkAdapter, { adapters: adapters, href: href, collection: collection, onClick: handleClick, className: "collection-ui-featured-card__link", children: labels.readMore })) : null] })] }));
|
|
292
|
+
}
|
|
293
|
+
function ImageGrid({ collection, adapters, labels, variant, }) {
|
|
294
|
+
const resolved = getAdapters(adapters);
|
|
295
|
+
const imageCollections = sortCollections(collection.collections).filter((item) => item.imageUrl);
|
|
296
|
+
return (_jsx(Container, { adapters: adapters, children: _jsxs("section", { className: cx("collection-ui-image-grid", `collection-ui-image-grid--${variant}`), children: [_jsx(SectionTitle, { collection: collection, adapters: adapters, labels: labels }), _jsx("div", { className: "collection-ui-image-grid__items", children: imageCollections.map((child, index) => {
|
|
297
|
+
const href = resolved.resolveCollectionHref(child);
|
|
298
|
+
const handleClick = () => resolved.onCollectionClick?.(child, href);
|
|
299
|
+
return (_jsx("div", { className: cx("collection-ui-image-grid__item", variant === "block" &&
|
|
300
|
+
index % 2 === 0 &&
|
|
301
|
+
"collection-ui-image-grid__item--end"), children: _jsx(LinkAdapter, { adapters: adapters, href: href ?? "", collection: child, onClick: handleClick, children: _jsx(ImageAdapter, { adapters: adapters, src: child.imageUrl ?? "", alt: child.name ?? "", width: variant === "circle" ? 200 : 176, height: variant === "circle" ? 200 : 64, className: cx("collection-ui-image-grid__image", variant === "circle" &&
|
|
302
|
+
"collection-ui-image-grid__image--circle", variant === "square" &&
|
|
303
|
+
"collection-ui-image-grid__image--square"), collection: child }) }) }, child.id));
|
|
304
|
+
}) })] }) }));
|
|
305
|
+
}
|
|
293
306
|
//# sourceMappingURL=CollectionRenderer.js.map
|