@nuvler/cli 0.5.13 → 0.5.15
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 +6 -0
- package/dist/api/theme-context.js +5 -1
- package/dist/api/theme-context.js.map +1 -1
- package/dist/commands/theme/build.js +11 -6
- package/dist/commands/theme/build.js.map +1 -1
- package/dist/commands/theme/validate.js +69 -26
- package/dist/commands/theme/validate.js.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/nuvler.js +147 -39
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/src/definition.tsx +3 -3
- package/dist/templates/nuvler-atelier/src/theme.tsx +34 -1
- package/dist/templates/nuvler-default/README.md +3 -1
- package/dist/templates/nuvler-default/nuvler.theme.json +15 -4
- package/dist/templates/nuvler-default/package.json +2 -2
- package/dist/templates/nuvler-default/src/custom-html-content.tsx +26 -0
- package/dist/templates/nuvler-default/src/footer.tsx +2 -1
- package/dist/templates/nuvler-default/src/home.tsx +5 -0
- package/dist/templates/nuvler-default/src/theme-component.tsx +305 -46
- package/dist/templates/nuvler-default/src/theme.css +1007 -259
- package/dist/templates/nuvler-default/test/editorial-content.test.mjs +47 -0
- package/dist/templates/nuvler-default/test/home-reference.test.mjs +42 -0
- package/dist/templates/starter/src/theme.tsx +20 -2
- package/dist/theme/artifact.js +3 -2
- package/dist/theme/artifact.js.map +1 -1
- package/package.json +3 -3
- package/preview-host/src/main.tsx +14 -0
- package/preview-host/vendor/theme-runtime/default-theme.tsx +1611 -334
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type CSSProperties,
|
|
9
|
+
} from "react";
|
|
4
10
|
import {
|
|
5
11
|
productUrl,
|
|
6
12
|
type NuvlerStoreThemeDefinition,
|
|
@@ -9,7 +15,9 @@ import {
|
|
|
9
15
|
type ThemeEditorialItem,
|
|
10
16
|
type ThemeHomeSection,
|
|
11
17
|
type ThemeNavigationItem,
|
|
18
|
+
type ThemePageContent,
|
|
12
19
|
type ThemePageSummary,
|
|
20
|
+
type ThemeImage,
|
|
13
21
|
type ThemeProduct,
|
|
14
22
|
type ThemeRuntimeAdapters,
|
|
15
23
|
type ThemeRuntimeSdk,
|
|
@@ -18,6 +26,7 @@ import {
|
|
|
18
26
|
import { nuvlerDefaultTheme } from "./definition.js";
|
|
19
27
|
import { ThemeInteractionProvider } from "./product-detail-interactive.js";
|
|
20
28
|
import { plainText, ThemeImageView } from "./shared.js";
|
|
29
|
+
import { CustomHtmlContent } from "./custom-html-content.js";
|
|
21
30
|
|
|
22
31
|
interface PreviewContext {
|
|
23
32
|
store: { name: string; slug: string };
|
|
@@ -38,8 +47,14 @@ interface PreviewContext {
|
|
|
38
47
|
};
|
|
39
48
|
}
|
|
40
49
|
|
|
50
|
+
// SDK 1.4.4 predates the optional editorial body already supported by this theme.
|
|
51
|
+
type PreviewEditorialItem = ThemeEditorialItem & {
|
|
52
|
+
content?: ThemePageContent | string | null;
|
|
53
|
+
};
|
|
54
|
+
|
|
41
55
|
type PreviewRoute =
|
|
42
|
-
| { type: "home" | "loading" | "not-found"
|
|
56
|
+
| { type: "home" | "loading" | "not-found"; title?: string }
|
|
57
|
+
| { type: "page"; title: string; slug: string; content: ThemePageContent }
|
|
43
58
|
| {
|
|
44
59
|
type: "catalog";
|
|
45
60
|
products: ThemeProduct[];
|
|
@@ -62,11 +77,135 @@ type PreviewRoute =
|
|
|
62
77
|
| { type: "product"; product: ThemeProduct }
|
|
63
78
|
| {
|
|
64
79
|
type: "editorial-list";
|
|
80
|
+
description?: string;
|
|
81
|
+
content?: ThemePageContent;
|
|
65
82
|
title: string;
|
|
66
83
|
basePath: string;
|
|
67
84
|
items: ThemeEditorialItem[];
|
|
68
85
|
}
|
|
69
|
-
| { type: "editorial-detail"; basePath: string; item:
|
|
86
|
+
| { type: "editorial-detail"; basePath: string; item: PreviewEditorialItem };
|
|
87
|
+
|
|
88
|
+
function PageBlocks({ content }: { content: ThemePageContent }) {
|
|
89
|
+
const text = (value: unknown): string =>
|
|
90
|
+
typeof value === "string" ? plainText(value) : "";
|
|
91
|
+
return (
|
|
92
|
+
<div className="article-content content-renderer">
|
|
93
|
+
{content.blocks.map((block, index) => {
|
|
94
|
+
const data = block.data;
|
|
95
|
+
const key = block.id || `${block.type}-${index}`;
|
|
96
|
+
if (block.type === "customHtml")
|
|
97
|
+
return (
|
|
98
|
+
<CustomHtmlContent
|
|
99
|
+
key={key}
|
|
100
|
+
html={typeof data.html === "string" ? data.html : ""}
|
|
101
|
+
css={typeof data.css === "string" ? data.css : ""}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
if (block.type === "header") {
|
|
105
|
+
const heading = text(data.text);
|
|
106
|
+
return Number(data.level) === 3 ? (
|
|
107
|
+
<h3 key={key}>{heading}</h3>
|
|
108
|
+
) : (
|
|
109
|
+
<h2 key={key}>{heading}</h2>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (block.type === "paragraph")
|
|
113
|
+
return <p key={key}>{text(data.text)}</p>;
|
|
114
|
+
if (block.type === "delimiter") return <hr key={key} />;
|
|
115
|
+
if (block.type === "quote")
|
|
116
|
+
return (
|
|
117
|
+
<blockquote key={key}>
|
|
118
|
+
<p>{text(data.text)}</p>
|
|
119
|
+
{text(data.caption) && <cite>{text(data.caption)}</cite>}
|
|
120
|
+
</blockquote>
|
|
121
|
+
);
|
|
122
|
+
if (block.type === "list") {
|
|
123
|
+
const items = Array.isArray(data.items) ? data.items : [];
|
|
124
|
+
const List = data.style === "ordered" ? "ol" : "ul";
|
|
125
|
+
return (
|
|
126
|
+
<List key={key}>
|
|
127
|
+
{items.map((item, itemIndex) => (
|
|
128
|
+
<li key={itemIndex}>
|
|
129
|
+
{text(
|
|
130
|
+
item && typeof item === "object" && "content" in item
|
|
131
|
+
? (item as { content: unknown }).content
|
|
132
|
+
: item,
|
|
133
|
+
)}
|
|
134
|
+
</li>
|
|
135
|
+
))}
|
|
136
|
+
</List>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (block.type === "image") {
|
|
140
|
+
const file =
|
|
141
|
+
data.file && typeof data.file === "object"
|
|
142
|
+
? (data.file as Record<string, unknown>)
|
|
143
|
+
: {};
|
|
144
|
+
const url = typeof file.url === "string" ? file.url : "";
|
|
145
|
+
const image: ThemeImage | null = url
|
|
146
|
+
? { url, alt: text(data.caption), width: null, height: null }
|
|
147
|
+
: null;
|
|
148
|
+
return image ? (
|
|
149
|
+
<figure key={key}>
|
|
150
|
+
<ThemeImageView
|
|
151
|
+
image={image}
|
|
152
|
+
fallbackAlt={text(data.caption) || "Imagem do conteúdo"}
|
|
153
|
+
/>
|
|
154
|
+
{text(data.caption) && (
|
|
155
|
+
<figcaption>{text(data.caption)}</figcaption>
|
|
156
|
+
)}
|
|
157
|
+
</figure>
|
|
158
|
+
) : null;
|
|
159
|
+
}
|
|
160
|
+
if (block.type === "imageText") {
|
|
161
|
+
const rawImage =
|
|
162
|
+
data.image && typeof data.image === "object"
|
|
163
|
+
? (data.image as Record<string, unknown>)
|
|
164
|
+
: {};
|
|
165
|
+
const url = typeof rawImage.url === "string" ? rawImage.url : "";
|
|
166
|
+
const image: ThemeImage | null = url
|
|
167
|
+
? { url, alt: text(rawImage.alt), width: null, height: null }
|
|
168
|
+
: null;
|
|
169
|
+
return (
|
|
170
|
+
<section className="content-image-text" key={key}>
|
|
171
|
+
{image && (
|
|
172
|
+
<ThemeImageView
|
|
173
|
+
image={image}
|
|
174
|
+
fallbackAlt="Imagem do conteúdo"
|
|
175
|
+
/>
|
|
176
|
+
)}
|
|
177
|
+
<div>
|
|
178
|
+
{text(data.title) && <h2>{text(data.title)}</h2>}
|
|
179
|
+
{text(data.text) && <p>{text(data.text)}</p>}
|
|
180
|
+
</div>
|
|
181
|
+
</section>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
if (block.type === "table") {
|
|
185
|
+
const rows = Array.isArray(data.content) ? data.content : [];
|
|
186
|
+
return (
|
|
187
|
+
<div className="content-table" key={key}>
|
|
188
|
+
<table>
|
|
189
|
+
<tbody>
|
|
190
|
+
{rows.map((row, rowIndex) => (
|
|
191
|
+
<tr key={rowIndex}>
|
|
192
|
+
{Array.isArray(row)
|
|
193
|
+
? row.map((cell, cellIndex) => (
|
|
194
|
+
<td key={cellIndex}>{text(cell)}</td>
|
|
195
|
+
))
|
|
196
|
+
: null}
|
|
197
|
+
</tr>
|
|
198
|
+
))}
|
|
199
|
+
</tbody>
|
|
200
|
+
</table>
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
})}
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
70
209
|
|
|
71
210
|
export interface NuvlerDefaultThemeProps {
|
|
72
211
|
context: PreviewContext;
|
|
@@ -87,32 +226,34 @@ function readStoredCart(storageKey: string): PreviewCartItem[] {
|
|
|
87
226
|
const parsed: unknown = JSON.parse(stored);
|
|
88
227
|
if (!Array.isArray(parsed)) return [];
|
|
89
228
|
|
|
90
|
-
return parsed
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
229
|
+
return parsed
|
|
230
|
+
.flatMap((candidate) => {
|
|
231
|
+
if (
|
|
232
|
+
!candidate ||
|
|
233
|
+
typeof candidate !== "object" ||
|
|
234
|
+
!("productSlug" in candidate) ||
|
|
235
|
+
typeof candidate.productSlug !== "string" ||
|
|
236
|
+
!("title" in candidate) ||
|
|
237
|
+
typeof candidate.title !== "string" ||
|
|
238
|
+
!("sku" in candidate) ||
|
|
239
|
+
typeof candidate.sku !== "string"
|
|
240
|
+
) {
|
|
241
|
+
return [];
|
|
242
|
+
}
|
|
103
243
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
244
|
+
const item = candidate as ThemeCartItem & {
|
|
245
|
+
key?: unknown;
|
|
246
|
+
quantity?: unknown;
|
|
247
|
+
};
|
|
248
|
+
const key = `${item.productSlug}::${item.variantId || "parent"}`;
|
|
249
|
+
const quantity =
|
|
250
|
+
typeof item.quantity === "number" && Number.isFinite(item.quantity)
|
|
251
|
+
? Math.min(99, Math.max(1, Math.trunc(item.quantity)))
|
|
252
|
+
: 1;
|
|
113
253
|
|
|
114
|
-
|
|
115
|
-
|
|
254
|
+
return [{ ...item, key, quantity }];
|
|
255
|
+
})
|
|
256
|
+
.slice(-30);
|
|
116
257
|
}
|
|
117
258
|
|
|
118
259
|
function money(value: number): string {
|
|
@@ -137,6 +278,12 @@ function catalogHref(
|
|
|
137
278
|
}
|
|
138
279
|
|
|
139
280
|
function editorialMeta(basePath: string) {
|
|
281
|
+
if (basePath === "")
|
|
282
|
+
return {
|
|
283
|
+
eyebrow: "Páginas",
|
|
284
|
+
action: "Saiba mais",
|
|
285
|
+
empty: "Nenhuma página publicada",
|
|
286
|
+
};
|
|
140
287
|
if (basePath === "/servicos")
|
|
141
288
|
return {
|
|
142
289
|
eyebrow: "Soluções",
|
|
@@ -184,7 +331,14 @@ function EditorialPreview({
|
|
|
184
331
|
<div className="editorial-grid editorial-list-grid">
|
|
185
332
|
{items.map((item) => (
|
|
186
333
|
<article className="editorial-card" key={item.slug}>
|
|
187
|
-
<a
|
|
334
|
+
<a
|
|
335
|
+
className="editorial-card-image"
|
|
336
|
+
href={
|
|
337
|
+
"href" in item && typeof item.href === "string"
|
|
338
|
+
? item.href
|
|
339
|
+
: `${basePath}/${item.slug}`
|
|
340
|
+
}
|
|
341
|
+
>
|
|
188
342
|
<ThemeImageView
|
|
189
343
|
image={item.image || item.thumbnail || item.coverImage}
|
|
190
344
|
fallbackAlt={item.title}
|
|
@@ -198,7 +352,15 @@ function EditorialPreview({
|
|
|
198
352
|
<span>{item.category.title || item.category.name}</span>
|
|
199
353
|
)}
|
|
200
354
|
<h2>
|
|
201
|
-
<a
|
|
355
|
+
<a
|
|
356
|
+
href={
|
|
357
|
+
"href" in item && typeof item.href === "string"
|
|
358
|
+
? item.href
|
|
359
|
+
: `${basePath}/${item.slug}`
|
|
360
|
+
}
|
|
361
|
+
>
|
|
362
|
+
{item.title}
|
|
363
|
+
</a>
|
|
202
364
|
</h2>
|
|
203
365
|
{publishedDate(item.publishedAt) && (
|
|
204
366
|
<small className="editorial-card-date">
|
|
@@ -206,7 +368,14 @@ function EditorialPreview({
|
|
|
206
368
|
</small>
|
|
207
369
|
)}
|
|
208
370
|
<p>{item.description}</p>
|
|
209
|
-
<a
|
|
371
|
+
<a
|
|
372
|
+
className="text-link"
|
|
373
|
+
href={
|
|
374
|
+
"href" in item && typeof item.href === "string"
|
|
375
|
+
? item.href
|
|
376
|
+
: `${basePath}/${item.slug}`
|
|
377
|
+
}
|
|
378
|
+
>
|
|
210
379
|
{meta.action} <span>→</span>
|
|
211
380
|
</a>
|
|
212
381
|
</div>
|
|
@@ -227,7 +396,14 @@ export function createNuvlerDefaultRuntime(
|
|
|
227
396
|
}: NuvlerDefaultThemeProps) {
|
|
228
397
|
const [cartItems, setCartItems] = useState<PreviewCartItem[]>([]);
|
|
229
398
|
const [cartOpen, setCartOpen] = useState(false);
|
|
399
|
+
const [cartToast, setCartToast] = useState<string | null>(null);
|
|
400
|
+
const [cartViewportHeight, setCartViewportHeight] = useState<number | null>(
|
|
401
|
+
null,
|
|
402
|
+
);
|
|
230
403
|
const [hydratedCartKey, setHydratedCartKey] = useState<string | null>(null);
|
|
404
|
+
const cartToastTimeout = useRef<ReturnType<
|
|
405
|
+
typeof window.setTimeout
|
|
406
|
+
> | null>(null);
|
|
231
407
|
const cartStorageKey = `nuvler:cart:${context.store.slug}`;
|
|
232
408
|
|
|
233
409
|
useEffect(() => {
|
|
@@ -245,6 +421,35 @@ export function createNuvlerDefaultRuntime(
|
|
|
245
421
|
window.localStorage.setItem(cartStorageKey, JSON.stringify(cartItems));
|
|
246
422
|
}, [cartItems, cartStorageKey, hydratedCartKey]);
|
|
247
423
|
|
|
424
|
+
useEffect(
|
|
425
|
+
() => () => {
|
|
426
|
+
if (cartToastTimeout.current)
|
|
427
|
+
window.clearTimeout(cartToastTimeout.current);
|
|
428
|
+
},
|
|
429
|
+
[],
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
useEffect(() => {
|
|
433
|
+
if (!cartOpen) return;
|
|
434
|
+
|
|
435
|
+
const viewport = window.visualViewport;
|
|
436
|
+
const syncCartViewportHeight = () =>
|
|
437
|
+
setCartViewportHeight(
|
|
438
|
+
Math.round(viewport?.height ?? window.innerHeight),
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
syncCartViewportHeight();
|
|
442
|
+
window.addEventListener("resize", syncCartViewportHeight);
|
|
443
|
+
viewport?.addEventListener("resize", syncCartViewportHeight);
|
|
444
|
+
viewport?.addEventListener("scroll", syncCartViewportHeight);
|
|
445
|
+
|
|
446
|
+
return () => {
|
|
447
|
+
window.removeEventListener("resize", syncCartViewportHeight);
|
|
448
|
+
viewport?.removeEventListener("resize", syncCartViewportHeight);
|
|
449
|
+
viewport?.removeEventListener("scroll", syncCartViewportHeight);
|
|
450
|
+
};
|
|
451
|
+
}, [cartOpen]);
|
|
452
|
+
|
|
248
453
|
const { Header, Footer, Home, ProductDetail, ProductGrid, NotFound } =
|
|
249
454
|
themeDefinition.components;
|
|
250
455
|
const site: ThemeSite = {
|
|
@@ -327,7 +532,13 @@ export function createNuvlerDefaultRuntime(
|
|
|
327
532
|
);
|
|
328
533
|
return [...current, { ...item, key, quantity: 1 }];
|
|
329
534
|
});
|
|
330
|
-
|
|
535
|
+
setCartToast(`“${item.title}” foi adicionado ao carrinho.`);
|
|
536
|
+
if (cartToastTimeout.current)
|
|
537
|
+
window.clearTimeout(cartToastTimeout.current);
|
|
538
|
+
cartToastTimeout.current = window.setTimeout(() => {
|
|
539
|
+
setCartToast(null);
|
|
540
|
+
cartToastTimeout.current = null;
|
|
541
|
+
}, 3200);
|
|
331
542
|
};
|
|
332
543
|
const cartButton = (
|
|
333
544
|
<button
|
|
@@ -520,8 +731,16 @@ export function createNuvlerDefaultRuntime(
|
|
|
520
731
|
<div className="store-container">
|
|
521
732
|
<span className="page-kicker">{meta.eyebrow}</span>
|
|
522
733
|
<h1>{route.title}</h1>
|
|
734
|
+
{route.description && <p>{route.description}</p>}
|
|
523
735
|
</div>
|
|
524
736
|
</section>
|
|
737
|
+
{route.content?.blocks.length ? (
|
|
738
|
+
<section className="store-section">
|
|
739
|
+
<div className="store-container">
|
|
740
|
+
<PageBlocks content={route.content} />
|
|
741
|
+
</div>
|
|
742
|
+
</section>
|
|
743
|
+
) : null}
|
|
525
744
|
<section className="store-section">
|
|
526
745
|
<div className="store-container">
|
|
527
746
|
<EditorialPreview items={route.items} basePath={route.basePath} />
|
|
@@ -574,6 +793,13 @@ export function createNuvlerDefaultRuntime(
|
|
|
574
793
|
fallbackHeight={900}
|
|
575
794
|
/>
|
|
576
795
|
)}
|
|
796
|
+
{typeof route.item.content === "string" ? (
|
|
797
|
+
<div className="article-content legacy-content">
|
|
798
|
+
{plainText(route.item.content)}
|
|
799
|
+
</div>
|
|
800
|
+
) : route.item.content?.blocks?.length ? (
|
|
801
|
+
<PageBlocks content={route.item.content} />
|
|
802
|
+
) : null}
|
|
577
803
|
<div className="article-content">
|
|
578
804
|
<a className="text-link" href={route.basePath}>
|
|
579
805
|
← Voltar para{" "}
|
|
@@ -587,7 +813,19 @@ export function createNuvlerDefaultRuntime(
|
|
|
587
813
|
</article>
|
|
588
814
|
</main>
|
|
589
815
|
);
|
|
590
|
-
} else if (route.type === "
|
|
816
|
+
} else if (route.type === "page")
|
|
817
|
+
content = (
|
|
818
|
+
<main className="article-page">
|
|
819
|
+
<article className="store-container article-shell">
|
|
820
|
+
<header className="article-header">
|
|
821
|
+
<span>Página</span>
|
|
822
|
+
<h1>{route.title}</h1>
|
|
823
|
+
</header>
|
|
824
|
+
<PageBlocks content={route.content} />
|
|
825
|
+
</article>
|
|
826
|
+
</main>
|
|
827
|
+
);
|
|
828
|
+
else if (route.type === "not-found")
|
|
591
829
|
content = NotFound ? (
|
|
592
830
|
<NotFound homeHref="/" />
|
|
593
831
|
) : (
|
|
@@ -639,10 +877,30 @@ export function createNuvlerDefaultRuntime(
|
|
|
639
877
|
template={themeDefinition.template}
|
|
640
878
|
/>
|
|
641
879
|
)}
|
|
880
|
+
{cartToast && (
|
|
881
|
+
<div className="cart-toast" role="status" aria-live="polite">
|
|
882
|
+
<span aria-hidden="true">✓</span>
|
|
883
|
+
<p>{cartToast}</p>
|
|
884
|
+
<button
|
|
885
|
+
type="button"
|
|
886
|
+
onClick={() => setCartToast(null)}
|
|
887
|
+
aria-label="Fechar aviso"
|
|
888
|
+
>
|
|
889
|
+
×
|
|
890
|
+
</button>
|
|
891
|
+
</div>
|
|
892
|
+
)}
|
|
642
893
|
{cartOpen && (
|
|
643
894
|
<div
|
|
644
895
|
className="cart-backdrop"
|
|
645
896
|
role="presentation"
|
|
897
|
+
style={
|
|
898
|
+
cartViewportHeight
|
|
899
|
+
? ({
|
|
900
|
+
"--cart-viewport-height": `${cartViewportHeight}px`,
|
|
901
|
+
} as CSSProperties)
|
|
902
|
+
: undefined
|
|
903
|
+
}
|
|
646
904
|
onPointerDown={(event) =>
|
|
647
905
|
event.target === event.currentTarget && setCartOpen(false)
|
|
648
906
|
}
|
|
@@ -699,6 +957,14 @@ export function createNuvlerDefaultRuntime(
|
|
|
699
957
|
<div className="cart-quantity">
|
|
700
958
|
<button
|
|
701
959
|
type="button"
|
|
960
|
+
className={
|
|
961
|
+
item.quantity === 1 ? "cart-delete" : undefined
|
|
962
|
+
}
|
|
963
|
+
aria-label={
|
|
964
|
+
item.quantity === 1
|
|
965
|
+
? `Remover ${item.title} do carrinho`
|
|
966
|
+
: `Diminuir quantidade de ${item.title}`
|
|
967
|
+
}
|
|
702
968
|
onClick={() =>
|
|
703
969
|
setCartItems((current) =>
|
|
704
970
|
current.flatMap((candidate) =>
|
|
@@ -716,7 +982,13 @@ export function createNuvlerDefaultRuntime(
|
|
|
716
982
|
)
|
|
717
983
|
}
|
|
718
984
|
>
|
|
719
|
-
|
|
985
|
+
{item.quantity === 1 ? (
|
|
986
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
987
|
+
<path d="M4 7h16M9 7V4h6v3m3 0-1 13H7L6 7m4 4v5m4-5v5" />
|
|
988
|
+
</svg>
|
|
989
|
+
) : (
|
|
990
|
+
"−"
|
|
991
|
+
)}
|
|
720
992
|
</button>
|
|
721
993
|
<span>{item.quantity}</span>
|
|
722
994
|
<button
|
|
@@ -739,19 +1011,6 @@ export function createNuvlerDefaultRuntime(
|
|
|
739
1011
|
>
|
|
740
1012
|
+
|
|
741
1013
|
</button>
|
|
742
|
-
<button
|
|
743
|
-
type="button"
|
|
744
|
-
className="cart-remove"
|
|
745
|
-
onClick={() =>
|
|
746
|
-
setCartItems((current) =>
|
|
747
|
-
current.filter(
|
|
748
|
-
(candidate) => candidate.key !== item.key,
|
|
749
|
-
),
|
|
750
|
-
)
|
|
751
|
-
}
|
|
752
|
-
>
|
|
753
|
-
Remover
|
|
754
|
-
</button>
|
|
755
1014
|
</div>
|
|
756
1015
|
</div>
|
|
757
1016
|
</article>
|