@nuvler/cli 0.5.4 → 0.5.5
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 +2 -2
- package/dist/api/client.js +3 -0
- package/dist/api/client.js.map +1 -1
- package/dist/api/theme-context.js +6 -1
- package/dist/api/theme-context.js.map +1 -1
- package/dist/commands/theme/create.js +1 -1
- package/dist/migrate/generator.js +32 -9
- package/dist/migrate/generator.js.map +1 -1
- package/dist/nuvler.js +100 -14
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-atelier/package.json +3 -3
- package/dist/templates/nuvler-atelier/src/definition.tsx +42 -6
- package/dist/templates/nuvler-atelier/src/theme.css +20 -0
- package/dist/templates/nuvler-atelier/src/theme.tsx +1 -1
- package/dist/templates/nuvler-default/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-default/package.json +2 -2
- package/dist/templates/nuvler-default/src/banner-carousel.tsx +19 -15
- package/dist/templates/nuvler-default/src/header-interactions.tsx +4 -4
- package/dist/templates/nuvler-default/src/header.tsx +2 -2
- package/dist/templates/nuvler-default/src/home.tsx +5 -3
- package/dist/templates/nuvler-default/src/server-shell.tsx +4 -1
- package/dist/templates/nuvler-default/src/theme-component.tsx +2 -2
- package/dist/templates/nuvler-default/src/theme.css +9 -2
- package/dist/templates/starter/README.md +5 -0
- package/dist/templates/starter/nuvler.theme.json +1 -1
- package/dist/templates/starter/package.json +2 -2
- package/dist/templates/starter/src/definition.tsx +30 -4
- package/dist/templates/starter/src/theme.css +13 -2
- package/dist/templates/starter/src/theme.tsx +1 -1
- package/package.json +3 -3
- package/preview-host/package.json +1 -1
- package/preview-host/vendor/theme-runtime/default-theme.tsx +39 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuvler-theme-nuvler-atelier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.3.3"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nuvler/cli": "^0.5.
|
|
22
|
+
"@nuvler/cli": "^0.5.5",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from "react";
|
|
1
|
+
import { useEffect, useMemo, useState, type CSSProperties } from "react";
|
|
2
2
|
import manifestData from "../nuvler.theme.json" with { type: "json" };
|
|
3
3
|
import {
|
|
4
4
|
defineTheme,
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
type ProductDetailProps,
|
|
10
10
|
type ProductGridProps,
|
|
11
11
|
type ThemeImage,
|
|
12
|
+
type ThemeHomeBanner,
|
|
13
|
+
type ThemeHomeSection,
|
|
12
14
|
type ThemeManifest,
|
|
13
15
|
type ThemeProduct,
|
|
14
16
|
} from "@nuvler/theme-sdk";
|
|
@@ -79,9 +81,13 @@ function SmartSearch({ searchProducts }: Pick<HeaderProps, "searchProducts">) {
|
|
|
79
81
|
</div>;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
function Header({ site, categories, pages, cart, searchProducts, template }: HeaderProps) {
|
|
84
|
+
function Header({ site, categories, pages, menu = [], headerButton, cart, searchProducts, template }: HeaderProps) {
|
|
83
85
|
const name = site.settings?.siteName || site.tenant.name;
|
|
84
86
|
const visibleCategories = categories.slice(0, 6);
|
|
87
|
+
const configuredMenu = [...menu].sort((left, right) => left.order - right.order);
|
|
88
|
+
const navigationLinks = configuredMenu.length
|
|
89
|
+
? configuredMenu
|
|
90
|
+
: visibleCategories.map((category, index) => ({ key: category.slug, href: `/${category.slug}`, label: category.name, order: index }));
|
|
85
91
|
return <>
|
|
86
92
|
<div className="atelier-announcement"><div className="atelier-container"><span>{template.announcement}</span><span>Curadoria feita para você · Atendimento humano</span></div></div>
|
|
87
93
|
<header className="atelier-header">
|
|
@@ -92,22 +98,50 @@ function Header({ site, categories, pages, cart, searchProducts, template }: Hea
|
|
|
92
98
|
</a>
|
|
93
99
|
<SmartSearch searchProducts={searchProducts} />
|
|
94
100
|
<div className="atelier-header-actions">
|
|
95
|
-
<a href="/contato"><small>Precisa de ajuda?</small><strong>Fale com a loja</strong></a>
|
|
101
|
+
{headerButton?.enabled ? <a className="atelier-header-highlight" href={headerButton.href} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noopener noreferrer" : undefined} style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }}><strong>{headerButton.label}</strong></a> : <a href="/contato"><small>Precisa de ajuda?</small><strong>Fale com a loja</strong></a>}
|
|
96
102
|
{cart}
|
|
97
103
|
</div>
|
|
98
104
|
</div>
|
|
99
105
|
<div className="atelier-nav-shell">
|
|
100
106
|
<nav className="atelier-container atelier-nav" aria-label="Categorias">
|
|
101
|
-
<details className="atelier-mobile-menu"><summary>Menu <span>+</span></summary><div>{
|
|
107
|
+
<details className="atelier-mobile-menu"><summary>Menu <span>+</span></summary><div>{navigationLinks.map((item) => <a href={item.href} key={item.key} target={("openInNewTab" in item && item.openInNewTab) ? "_blank" : undefined} rel={("openInNewTab" in item && item.openInNewTab) ? "noopener noreferrer" : undefined}>{item.label}</a>)}{headerButton?.enabled && <a href={headerButton.href} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noopener noreferrer" : undefined}>{headerButton.label}</a>}</div></details>
|
|
102
108
|
<a className="atelier-all-products" href="/produtos"><span>◫</span> Catálogo completo</a>
|
|
103
|
-
{
|
|
104
|
-
<details className="atelier-more"><summary>Mais</summary><div>{
|
|
109
|
+
{navigationLinks.slice(0, 6).map((item, index) => <a href={item.href} key={item.key} target={("openInNewTab" in item && item.openInNewTab) ? "_blank" : undefined} rel={("openInNewTab" in item && item.openInNewTab) ? "noopener noreferrer" : undefined}><small>{String(index + 1).padStart(2, "0")}</small>{item.label}</a>)}
|
|
110
|
+
<details className="atelier-more"><summary>Mais</summary><div>{navigationLinks.slice(6).map((item) => <a href={item.href} key={item.key} target={("openInNewTab" in item && item.openInNewTab) ? "_blank" : undefined} rel={("openInNewTab" in item && item.openInNewTab) ? "noopener noreferrer" : undefined}>{item.label}</a>)}{!configuredMenu.length && pages.map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</div></details>
|
|
105
111
|
</nav>
|
|
106
112
|
</div>
|
|
107
113
|
</header>
|
|
108
114
|
</>;
|
|
109
115
|
}
|
|
110
116
|
|
|
117
|
+
function atelierBanners(section: ThemeHomeSection): ThemeHomeBanner[] {
|
|
118
|
+
if (!Array.isArray(section.data.banners)) return [];
|
|
119
|
+
return section.data.banners.filter((item): item is ThemeHomeBanner => Boolean(item && typeof item === "object"));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function AtelierBannerCarousel({ section }: { section: ThemeHomeSection }) {
|
|
123
|
+
const banners = atelierBanners(section).filter((banner) => Boolean(banner.image?.url || banner.imageUrl));
|
|
124
|
+
const [active, setActive] = useState(0);
|
|
125
|
+
const autoplay = section.data.autoplay !== false;
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (!autoplay || banners.length < 2) return;
|
|
128
|
+
const timer = window.setInterval(() => setActive((current) => (current + 1) % banners.length), 6000);
|
|
129
|
+
return () => window.clearInterval(timer);
|
|
130
|
+
}, [autoplay, banners.length]);
|
|
131
|
+
if (!banners.length) return null;
|
|
132
|
+
const desktopHeight = typeof section.data.desktopHeight === "number" ? section.data.desktopHeight : 590;
|
|
133
|
+
const mobileHeight = typeof section.data.mobileHeight === "number" ? section.data.mobileHeight : 420;
|
|
134
|
+
const fit = section.data.imageFit === "CONTAIN" || section.data.imageFit === "NATURAL" ? section.data.imageFit.toLowerCase() : "cover";
|
|
135
|
+
return <section className="atelier-banner-carousel" data-image-fit={fit} style={{ "--atelier-banner-desktop-height": `${desktopHeight}px`, "--atelier-banner-mobile-height": `${mobileHeight}px` } as CSSProperties}>
|
|
136
|
+
<div className="atelier-banner-track" style={{ transform: `translateX(-${active * 100}%)` }}>{banners.map((banner, index) => {
|
|
137
|
+
const imageUrl = banner.image?.url || banner.imageUrl || "";
|
|
138
|
+
const mobileUrl = banner.mobileImage?.url || banner.mobileImageUrl;
|
|
139
|
+
return <article key={`${imageUrl}-${index}`}><picture>{mobileUrl && <source media="(max-width: 767px)" srcSet={mobileUrl} />}<img src={imageUrl} alt={banner.image?.alt || banner.imageAlt || banner.title || "Banner"} loading={index === 0 ? "eager" : "lazy"} /></picture>{(banner.title || banner.description || (banner.buttonLabel && banner.buttonUrl)) && <div><div className="atelier-container">{banner.title && <h2>{banner.title}</h2>}{banner.description && <p>{banner.description}</p>}{banner.buttonLabel && banner.buttonUrl && <a className="atelier-button atelier-button-light" href={banner.buttonUrl}>{banner.buttonLabel}</a>}</div></div>}</article>;
|
|
140
|
+
})}</div>
|
|
141
|
+
{banners.length > 1 && <><button type="button" aria-label="Banner anterior" onClick={() => setActive((active - 1 + banners.length) % banners.length)}>‹</button><button type="button" aria-label="Próximo banner" onClick={() => setActive((active + 1) % banners.length)}>›</button></>}
|
|
142
|
+
</section>;
|
|
143
|
+
}
|
|
144
|
+
|
|
111
145
|
function Footer({ site, pages }: FooterProps) {
|
|
112
146
|
const name = site.settings?.siteName || site.tenant.name;
|
|
113
147
|
const contact = site.settings?.contact;
|
|
@@ -142,6 +176,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
142
176
|
const heroUrl = value(hero?.data, "buttonUrl") || template.primaryAction(site.modules).href;
|
|
143
177
|
const highlight = products[0];
|
|
144
178
|
const editorial = [...posts, ...cases].slice(0, 3);
|
|
179
|
+
const bannerSections = sections.filter((section) => section.enabled && section.type === "banner-carousel");
|
|
145
180
|
return <main>
|
|
146
181
|
<section className="atelier-hero atelier-container">
|
|
147
182
|
<div className="atelier-hero-copy"><span className="atelier-kicker">Nuvler Atelier · edição 01</span><h1>{heroTitle}</h1><p>{heroDescription}</p><div><a className="atelier-button atelier-button-light" href={heroUrl}>{heroButton}<b>↗</b></a><a className="atelier-text-link" href="/produtos">Ver catálogo completo →</a></div></div>
|
|
@@ -151,6 +186,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
151
186
|
{highlight && <a href={productUrl(highlight)}><small>Destaque da semana</small><strong>{highlight.title}</strong><span>{price(highlight) || "Conheça o produto"} →</span></a>}
|
|
152
187
|
</div>
|
|
153
188
|
</section>
|
|
189
|
+
{bannerSections.map((section, index) => <AtelierBannerCarousel section={section} key={section.id || index} />)}
|
|
154
190
|
<section className="atelier-marquee"><div>{template.benefits.concat(template.benefits).map((benefit, index) => <span key={`${benefit.title}-${index}`}><b>✦</b>{benefit.title}<small>{benefit.description}</small></span>)}</div></section>
|
|
155
191
|
<section className="atelier-section atelier-container">
|
|
156
192
|
<header className="atelier-section-heading"><div><span className="atelier-kicker">Seleção essencial</span><h2>Produtos que merecem atenção</h2></div><p>Uma vitrine com mais respiro, imagens protagonistas e as informações certas para decidir.</p><a href="/produtos">Explorar tudo ↗</a></header>
|
|
@@ -57,6 +57,7 @@ body { margin: 0; }
|
|
|
57
57
|
.atelier-header-actions > a { display: flex; flex-direction: column; }
|
|
58
58
|
.atelier-header-actions small { color: color-mix(in srgb, var(--atelier-text) 55%, transparent); font-size: 10px; }
|
|
59
59
|
.atelier-header-actions strong { font-size: 12px; }
|
|
60
|
+
.atelier-header-actions .atelier-header-highlight { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; border-radius: var(--atelier-radius); padding: 0 18px; }
|
|
60
61
|
.atelier-cart-button { display: flex; min-height: 44px; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--atelier-text); font-weight: 800; }
|
|
61
62
|
.atelier-cart-button b { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; background: var(--atelier-primary); color: var(--atelier-primary-text); font-size: 11px; }
|
|
62
63
|
.atelier-nav-shell { border-block: 1px solid var(--atelier-line); }
|
|
@@ -85,6 +86,20 @@ body { margin: 0; }
|
|
|
85
86
|
.atelier-hero-visual > a small { grid-column: 1 / -1; font-size: 9px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
|
|
86
87
|
.atelier-hero-visual > a strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
87
88
|
.atelier-hero-visual > a span { font-size: 11px; font-weight: 800; }
|
|
89
|
+
.atelier-banner-carousel { position: relative; overflow: hidden; background: var(--atelier-surface-alt); }
|
|
90
|
+
.atelier-banner-track { display: flex; transition: transform .5s ease; }
|
|
91
|
+
.atelier-banner-track > article { position: relative; flex: 0 0 100%; height: var(--atelier-banner-desktop-height, 590px); }
|
|
92
|
+
.atelier-banner-track picture { position: absolute; inset: 0; display: grid; place-items: center; width: 100%; height: 100%; }
|
|
93
|
+
.atelier-banner-track img { display: block; width: 100%; height: 100%; object-fit: cover; }
|
|
94
|
+
.atelier-banner-carousel[data-image-fit="contain"] img { object-fit: contain; }
|
|
95
|
+
.atelier-banner-carousel[data-image-fit="natural"] img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
|
|
96
|
+
.atelier-banner-track article > div { position: absolute; inset: 0; display: flex; align-items: center; background: linear-gradient(90deg, rgba(16,28,26,.72), transparent 72%); color: #fff; }
|
|
97
|
+
.atelier-banner-track article > div > div { width: 100%; }
|
|
98
|
+
.atelier-banner-track h2 { max-width: 720px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(42px, 6vw, 78px); font-weight: 400; line-height: .96; }
|
|
99
|
+
.atelier-banner-track p { max-width: 620px; margin: 22px 0 28px; font-size: 16px; line-height: 1.7; }
|
|
100
|
+
.atelier-banner-carousel > button { position: absolute; z-index: 3; top: 50%; width: 44px; height: 44px; transform: translateY(-50%); border: 1px solid rgba(255,255,255,.55); border-radius: 50%; background: rgba(16,28,26,.76); color: #fff; font-size: 28px; }
|
|
101
|
+
.atelier-banner-carousel > button:first-of-type { left: 18px; }
|
|
102
|
+
.atelier-banner-carousel > button:last-of-type { right: 18px; }
|
|
88
103
|
.atelier-orbit { position: absolute; width: 62%; aspect-ratio: 1; border: 1px solid rgba(23,63,58,.24); border-radius: 50%; }
|
|
89
104
|
.atelier-orbit.second { width: 84%; }
|
|
90
105
|
.atelier-marquee { overflow: hidden; border-bottom: 1px solid var(--atelier-line); background: var(--atelier-surface); }
|
|
@@ -213,6 +228,7 @@ body { margin: 0; }
|
|
|
213
228
|
@media (max-width: 1120px) {
|
|
214
229
|
.atelier-header-main { grid-template-columns: 220px 1fr auto; gap: 20px; }
|
|
215
230
|
.atelier-header-actions > a { display: none; }
|
|
231
|
+
.atelier-header-actions > .atelier-header-highlight { display: inline-flex; }
|
|
216
232
|
.atelier-nav > a:nth-of-type(n+6) { display: none; }
|
|
217
233
|
.atelier-hero { min-height: 600px; grid-template-columns: 1fr .85fr; }
|
|
218
234
|
.atelier-hero-copy { padding: 58px; }
|
|
@@ -230,6 +246,7 @@ body { margin: 0; }
|
|
|
230
246
|
.atelier-brand { justify-self: center; }
|
|
231
247
|
.atelier-search-wrap { grid-row: 2; grid-column: 1 / -1; width: 100%; }
|
|
232
248
|
.atelier-header-actions { position: absolute; right: 14px; top: 52px; }
|
|
249
|
+
.atelier-header-actions > .atelier-header-highlight { display: none; }
|
|
233
250
|
.atelier-cart-button span { display: none; }
|
|
234
251
|
.atelier-nav { min-height: 52px; }
|
|
235
252
|
.atelier-nav > a, .atelier-nav > details:not(.atelier-mobile-menu) { display: none !important; }
|
|
@@ -243,6 +260,9 @@ body { margin: 0; }
|
|
|
243
260
|
.atelier-hero-copy h1 { font-size: clamp(48px, 15vw, 72px); }
|
|
244
261
|
.atelier-hero-copy > div { align-items: flex-start; flex-direction: column; }
|
|
245
262
|
.atelier-hero-visual { min-height: 520px; }
|
|
263
|
+
.atelier-banner-track > article { height: var(--atelier-banner-mobile-height, 420px); }
|
|
264
|
+
.atelier-banner-track article > div { align-items: flex-end; padding-bottom: 54px; background: linear-gradient(0deg, rgba(16,28,26,.82), transparent 88%); }
|
|
265
|
+
.atelier-banner-track h2 { font-size: 42px; }
|
|
246
266
|
.atelier-section-heading { display: flex; align-items: flex-start; flex-direction: column; gap: 20px; }
|
|
247
267
|
.atelier-products, .atelier-products[data-columns="4"] { grid-template-columns: repeat(2, 1fr); }
|
|
248
268
|
.atelier-editorial-grid { grid-template-columns: 1fr; }
|
|
@@ -108,7 +108,7 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
|
|
|
108
108
|
|
|
109
109
|
const cartButton = <button className="atelier-cart-button" type="button" onClick={() => setCartOpen(true)} aria-label={`Abrir seleção com ${cartCount} itens`}><span>Seleção</span><b>{String(cartCount).padStart(2, "0")}</b></button>;
|
|
110
110
|
return <div className="nuvler-atelier-theme" data-theme-id={themeDefinition.manifest.id} data-theme-version={themeDefinition.manifest.version} style={style}>
|
|
111
|
-
<Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} />
|
|
111
|
+
<Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} menu={context.navigation.menu} headerButton={context.navigation.headerButton} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} />
|
|
112
112
|
{content}
|
|
113
113
|
<Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />
|
|
114
114
|
{cartOpen && <div className="atelier-cart-backdrop" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="atelier-cart-drawer"><header><div><small>Sua curadoria</small><h2>{cartCount} {cartCount === 1 ? "item" : "itens"}</h2></div><button onClick={() => setCartOpen(false)} aria-label="Fechar">×</button></header><div className="atelier-cart-lines">{cart.length === 0 ? <p>Sua seleção está vazia. Explore os produtos e adicione o que interessar.</p> : cart.map((item) => <article key={item.key}><AtelierImage image={item.image} alt={item.title} /><div><strong>{item.title}</strong><small>{item.variantName || item.sku}</small><span><button onClick={() => setCart((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button>{item.quantity}<button onClick={() => setCart((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: candidate.quantity + 1 } : candidate))}>+</button></span></div></article>)}</div>{cart.length > 0 && <footer><p>Valores e disponibilidade serão confirmados pela equipe.</p>{whatsapp ? <a className="atelier-button atelier-button-light" href={`https://wa.me/${whatsapp}?text=${encodeURIComponent(message)}`} target="_blank" rel="noreferrer">Enviar pelo WhatsApp ↗</a> : <span>Configure o WhatsApp da loja para concluir.</span>}</footer>}</aside></div>}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/theme-default",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Tema padrão oficial da Nuvler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"react": "^19.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
67
|
+
"@nuvler/theme-sdk": "^1.3.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/react": "^19.0.0",
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { BannerCarouselFrame } from "./carousel-frame.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CSSProperties } from "react";
|
|
3
|
+
import type { ThemeBannerImageFit, ThemeHomeBanner } from "@nuvler/theme-sdk";
|
|
3
4
|
import { ThemeImageView, type ThemeImageComponent } from "./shared.js";
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
-
imageUrl: string;
|
|
7
|
-
image?: ThemeImage | null;
|
|
8
|
-
imageAlt?: string;
|
|
9
|
-
title?: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
buttonLabel?: string;
|
|
12
|
-
buttonUrl?: string;
|
|
13
|
-
}
|
|
6
|
+
export type ThemeBanner = ThemeHomeBanner & { imageUrl: string };
|
|
14
7
|
|
|
15
|
-
export function BannerCarousel({ banners, autoplay, priority = false, ImageComponent = ThemeImageView }: {
|
|
8
|
+
export function BannerCarousel({ banners, autoplay, desktopHeight = 590, mobileHeight = 420, imageFit = "COVER", priority = false, ImageComponent = ThemeImageView }: {
|
|
16
9
|
banners: ThemeBanner[];
|
|
17
10
|
autoplay: boolean;
|
|
11
|
+
desktopHeight?: number;
|
|
12
|
+
mobileHeight?: number;
|
|
13
|
+
imageFit?: ThemeBannerImageFit;
|
|
18
14
|
priority?: boolean;
|
|
19
15
|
ImageComponent?: ThemeImageComponent;
|
|
20
16
|
}) {
|
|
21
17
|
if (!banners.length) return null;
|
|
18
|
+
const style = {
|
|
19
|
+
"--banner-desktop-height": `${desktopHeight}px`,
|
|
20
|
+
"--banner-mobile-height": `${mobileHeight}px`,
|
|
21
|
+
} as CSSProperties;
|
|
22
22
|
return (
|
|
23
|
-
<
|
|
24
|
-
{banners.
|
|
23
|
+
<div className="banner-carousel-settings" data-image-fit={imageFit.toLowerCase()} style={style}>
|
|
24
|
+
<BannerCarouselFrame count={banners.length} autoplay={autoplay}>
|
|
25
|
+
{banners.map((banner, index) => (
|
|
25
26
|
<article className="banner-slide" data-banner-slide key={`${banner.imageUrl}-${index}`} aria-hidden={index !== 0}>
|
|
26
27
|
<ImageComponent
|
|
27
28
|
image={banner.image ?? {
|
|
@@ -35,7 +36,9 @@ export function BannerCarousel({ banners, autoplay, priority = false, ImageCompo
|
|
|
35
36
|
sizes="100vw"
|
|
36
37
|
fallbackWidth={1600}
|
|
37
38
|
fallbackHeight={640}
|
|
39
|
+
className={banner.mobileImage?.url || banner.mobileImageUrl ? "banner-image-desktop" : undefined}
|
|
38
40
|
/>
|
|
41
|
+
{(banner.mobileImage?.url || banner.mobileImageUrl) && <ImageComponent image={banner.mobileImage ?? { url: banner.mobileImageUrl ?? null, alt: banner.mobileImageAlt || banner.imageAlt || banner.title || "Banner", width: null, height: null }} fallbackAlt={banner.title || "Banner"} sizes="100vw" fallbackWidth={720} fallbackHeight={900} className="banner-image-mobile" />}
|
|
39
42
|
{(banner.title || banner.description || (banner.buttonLabel && banner.buttonUrl)) && (
|
|
40
43
|
<div className="banner-overlay">
|
|
41
44
|
<div className="store-container">
|
|
@@ -48,7 +51,8 @@ export function BannerCarousel({ banners, autoplay, priority = false, ImageCompo
|
|
|
48
51
|
</div>
|
|
49
52
|
)}
|
|
50
53
|
</article>
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
))}
|
|
55
|
+
</BannerCarouselFrame>
|
|
56
|
+
</div>
|
|
53
57
|
);
|
|
54
58
|
}
|
|
@@ -155,7 +155,7 @@ export function ConfiguredNavigation({ menu, categories: initialCategories }: {
|
|
|
155
155
|
<a href="/">Início</a>
|
|
156
156
|
{menu.map((item) => {
|
|
157
157
|
const categorySlug = categorySlugFromMenuItem(item);
|
|
158
|
-
if (!categorySlug) return <a href={item.href} key={item.key}>{item.label}</a>;
|
|
158
|
+
if (!categorySlug) return <a href={item.href} key={item.key} target={item.openInNewTab ? "_blank" : undefined} rel={item.openInNewTab ? "noopener noreferrer" : undefined}>{item.label}</a>;
|
|
159
159
|
const match = findCategory(categories, categorySlug);
|
|
160
160
|
const hasSubcategories = status !== "loaded" || Boolean(match?.category.children.length);
|
|
161
161
|
return <div className="main-nav-group" key={item.key} onPointerEnter={() => { void load(); }} onFocusCapture={() => { void load(); }}>
|
|
@@ -270,7 +270,7 @@ function MobileCategories({ categories, path = [] }: { categories: ThemeCategory
|
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
export function MobileStoreMenu({ site, categories: initialCategories, pages, menu = [] }: { site: ThemeSite; categories: ThemeCategory[]; pages: ThemePageSummary[]; menu?: ThemeNavigationItem[] }) {
|
|
273
|
+
export function MobileStoreMenu({ site, categories: initialCategories, pages, menu = [], headerButton }: { site: ThemeSite; categories: ThemeCategory[]; pages: ThemePageSummary[]; menu?: ThemeNavigationItem[]; headerButton?: import("@nuvler/theme-sdk").ThemeNavigationHeaderButton | null }) {
|
|
274
274
|
const [open, setOpen] = useState(false);
|
|
275
275
|
const { categories, status, load } = useLazyCategories(initialCategories);
|
|
276
276
|
useEffect(() => {
|
|
@@ -284,9 +284,9 @@ export function MobileStoreMenu({ site, categories: initialCategories, pages, me
|
|
|
284
284
|
const configuredHasCategories = configuredMenu.some((item) => item.type === "CATEGORY");
|
|
285
285
|
return <><button type="button" className="mobile-menu-trigger" onClick={() => { setOpen(true); if (!configuredMenu.length || configuredHasCategories) void load(); }} aria-label="Abrir menu"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16" /></svg></button>{open && <div className="mobile-menu-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setOpen(false)}><aside className="mobile-menu-drawer" aria-label="Menu da loja"><div className="mobile-menu-heading"><div><small>Navegue pela loja</small><strong>{settings?.siteName || site.tenant.name}</strong></div><button type="button" onClick={() => setOpen(false)} aria-label="Fechar menu">×</button></div><nav className="mobile-menu-links"><a href="/">Início</a>{configuredMenu.length ? configuredMenu.map((item) => {
|
|
286
286
|
const categorySlug = categorySlugFromMenuItem(item);
|
|
287
|
-
if (!categorySlug) return <a href={item.href} key={item.key}>{item.label}</a>;
|
|
287
|
+
if (!categorySlug) return <a href={item.href} key={item.key} target={item.openInNewTab ? "_blank" : undefined} rel={item.openInNewTab ? "noopener noreferrer" : undefined}>{item.label}</a>;
|
|
288
288
|
const match = findCategory(categories, categorySlug);
|
|
289
289
|
const hasSubcategories = status !== "loaded" || Boolean(match?.category.children.length);
|
|
290
290
|
return hasSubcategories ? <details key={item.key} className="mobile-menu-category"><summary><span>{item.label}</span><span aria-hidden="true">+</span></summary><div><a href={item.href}>Ver tudo em {item.label}</a>{status !== "loaded" && !match?.category.children.length && <p className="mobile-menu-category-status" role="status">{status === "error" ? "Não foi possível carregar as subcategorias." : "Carregando subcategorias…"}</p>}{match?.category.children.length ? <MobileCategories categories={match.category.children} path={match.path} /> : null}</div></details> : <a href={item.href} key={item.key}>{item.label}</a>;
|
|
291
|
-
}) : <>{site.modules.includes("PRODUCTS") && <a href="/produtos">Todos os produtos</a>}{site.modules.includes("BLOG") && <a href="/blog">Blog</a>}{site.modules.includes("SERVICES") && <a href="/servicos">Serviços</a>}{site.modules.includes("CASES") && <a href="/cases">Cases</a>}{pages.slice(0, 8).map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</>}</nav>{!configuredMenu.length && categories.length > 0 && <section className="mobile-menu-categories"><h2>Categorias</h2>{status === "loading" && <p className="mobile-menu-category-status" role="status">Carregando categorias…</p>}{status === "error" && <p className="mobile-menu-category-status">Não foi possível atualizar as categorias.</p>}<MobileCategories categories={categories} /></section>}</aside></div>}</>;
|
|
291
|
+
}) : <>{site.modules.includes("PRODUCTS") && <a href="/produtos">Todos os produtos</a>}{site.modules.includes("BLOG") && <a href="/blog">Blog</a>}{site.modules.includes("SERVICES") && <a href="/servicos">Serviços</a>}{site.modules.includes("CASES") && <a href="/cases">Cases</a>}{pages.slice(0, 8).map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</>}{headerButton?.enabled && <a className="mobile-menu-highlight" href={headerButton.href} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noopener noreferrer" : undefined} style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }}>{headerButton.label}</a>}</nav>{!configuredMenu.length && categories.length > 0 && <section className="mobile-menu-categories"><h2>Categorias</h2>{status === "loading" && <p className="mobile-menu-category-status" role="status">Carregando categorias…</p>}{status === "error" && <p className="mobile-menu-category-status">Não foi possível atualizar as categorias.</p>}<MobileCategories categories={categories} /></section>}</aside></div>}</>;
|
|
292
292
|
}
|
|
@@ -6,11 +6,11 @@ function SupplementaryLinks({ site, pages }: Pick<HeaderProps, "site" | "pages">
|
|
|
6
6
|
return <>{site.modules.includes("BLOG") && <a href="/blog">Blog</a>}{site.modules.includes("SERVICES") && <a href="/servicos">Serviços</a>}{site.modules.includes("CASES") && <a href="/cases">Cases</a>}{pages.slice(0, 6).map((page) => <a key={page.slug} href={`/${page.slug}`}>{page.title}</a>)}</>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function Header({ site, categories, pages, menu = [], template, cart, suggestionsEndpoint, suggestionsQueryParam, searchProducts, ImageComponent = ThemeImageView }: HeaderProps & { ImageComponent?: ThemeImageComponent }) {
|
|
9
|
+
export function Header({ site, categories, pages, menu = [], headerButton, template, cart, suggestionsEndpoint, suggestionsQueryParam, searchProducts, ImageComponent = ThemeImageView }: HeaderProps & { ImageComponent?: ThemeImageComponent }) {
|
|
10
10
|
const name = site.settings?.siteName || site.tenant.name;
|
|
11
11
|
const hasCategories = categories.length > 0;
|
|
12
12
|
const configuredMenu = [...menu].sort((left, right) => left.order - right.order);
|
|
13
13
|
const hasConfiguredMenu = configuredMenu.length > 0;
|
|
14
14
|
const hasExtra = !hasConfiguredMenu && (site.modules.some((module) => ["BLOG", "SERVICES", "CASES"].includes(module)) || pages.length > 0);
|
|
15
|
-
return <><div className="announcement"><div className="store-container announcement-inner"><span>{template.announcement}</span>{site.settings?.contact.phone && <span>{site.settings.contact.phone}</span>}</div></div><header className="store-header"><div className={`store-container header-inner${hasCategories && hasExtra ? "" : " header-inner-simple"}`}><MobileStoreMenu site={site} categories={categories} pages={pages} menu={configuredMenu} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <ImageComponent image={site.settings.logo} fallbackAlt={name} className="brand-logo" sizes="200px" fallbackWidth={240} fallbackHeight={96} /> : <><span className="brand-mark">7</span><span>{name}</span></>}</a>{site.modules.includes("PRODUCTS") && <SmartProductSearch endpoint={suggestionsEndpoint} queryParam={suggestionsQueryParam} searchProducts={searchProducts} />}<div className="header-message"><span className="header-message-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m12 3 2.1 4.9L19 10l-4.9 2.1L12 17l-2.1-4.9L5 10l4.9-2.1L12 3Z" /></svg></span><span className="header-message-copy"><small>Nossa loja</small><strong>{site.settings?.description?.trim() || template.announcement}</strong></span></div>{hasCategories && hasExtra && <div className="header-actions"><details className="header-more-menu"><summary>Mais <span aria-hidden="true">⌄</span></summary><div className="header-more-panel"><SupplementaryLinks site={site} pages={pages} /></div></details></div>}{cart}</div>{hasConfiguredMenu ? <ConfiguredNavigation menu={configuredMenu} categories={categories} /> : hasCategories ? <CategoryNavigation categories={categories} /> : <div className="primary-nav-shell"><nav className="store-container main-nav" aria-label="Navegação principal"><a href="/">Início</a>{site.modules.includes("PRODUCTS") && <a href="/produtos">Produtos</a>}<SupplementaryLinks site={site} pages={pages} /></nav></div>}</header></>;
|
|
15
|
+
return <><div className="announcement"><div className="store-container announcement-inner"><span>{template.announcement}</span>{site.settings?.contact.phone && <span>{site.settings.contact.phone}</span>}</div></div><header className="store-header"><div className={`store-container header-inner${hasCategories && hasExtra ? "" : " header-inner-simple"}`}><MobileStoreMenu site={site} categories={categories} pages={pages} menu={configuredMenu} headerButton={headerButton} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <ImageComponent image={site.settings.logo} fallbackAlt={name} className="brand-logo" sizes="200px" fallbackWidth={240} fallbackHeight={96} /> : <><span className="brand-mark">7</span><span>{name}</span></>}</a>{site.modules.includes("PRODUCTS") && <SmartProductSearch endpoint={suggestionsEndpoint} queryParam={suggestionsQueryParam} searchProducts={searchProducts} />}<div className="header-message"><span className="header-message-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m12 3 2.1 4.9L19 10l-4.9 2.1L12 17l-2.1-4.9L5 10l4.9-2.1L12 3Z" /></svg></span><span className="header-message-copy"><small>Nossa loja</small><strong>{site.settings?.description?.trim() || template.announcement}</strong></span></div>{hasCategories && hasExtra && <div className="header-actions"><details className="header-more-menu"><summary>Mais <span aria-hidden="true">⌄</span></summary><div className="header-more-panel"><SupplementaryLinks site={site} pages={pages} /></div></details></div>}{headerButton?.enabled && <a className="header-highlight-link" href={headerButton.href} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noopener noreferrer" : undefined} style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }}>{headerButton.label}</a>}{cart}</div>{hasConfiguredMenu ? <ConfiguredNavigation menu={configuredMenu} categories={categories} /> : hasCategories ? <CategoryNavigation categories={categories} /> : <div className="primary-nav-shell"><nav className="store-container main-nav" aria-label="Navegação principal"><a href="/">Início</a>{site.modules.includes("PRODUCTS") && <a href="/produtos">Produtos</a>}<SupplementaryLinks site={site} pages={pages} /></nav></div>}</header></>;
|
|
16
16
|
}
|
|
@@ -62,8 +62,10 @@ function banners(data: Record<string, unknown>): ThemeBanner[] {
|
|
|
62
62
|
return data.banners.flatMap((entry) => {
|
|
63
63
|
if (!entry || typeof entry !== "object") return [];
|
|
64
64
|
const item = entry as Record<string, unknown>;
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
const image = imageValue(item.image);
|
|
66
|
+
const imageUrl = image?.url || (typeof item.imageUrl === "string" ? item.imageUrl : "");
|
|
67
|
+
if (!imageUrl) return [];
|
|
68
|
+
return [{ imageUrl, image, imageAlt: typeof item.imageAlt === "string" ? item.imageAlt : undefined, mobileImageUrl: typeof item.mobileImageUrl === "string" ? item.mobileImageUrl : undefined, mobileImage: imageValue(item.mobileImage), mobileImageAlt: typeof item.mobileImageAlt === "string" ? item.mobileImageAlt : undefined, title: typeof item.title === "string" ? item.title : undefined, description: typeof item.description === "string" ? item.description : undefined, buttonLabel: typeof item.buttonLabel === "string" ? item.buttonLabel : undefined, buttonUrl: typeof item.buttonUrl === "string" ? item.buttonUrl : undefined }];
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -158,7 +160,7 @@ export function Home({ sections, products, posts, services, cases, site, templat
|
|
|
158
160
|
const catalog = site.settings?.catalog ?? { showCategory: true, showDescription: true, desktopColumns: 4 as const };
|
|
159
161
|
return <>{rendered.map((section, index) => {
|
|
160
162
|
if (section.type === "hero") return <Hero key={section.id || index} section={section} site={site} action={template.primaryAction(site.modules)} priority={index === 0} ImageComponent={ImageComponent} />;
|
|
161
|
-
if (section.type === "banner-carousel") return <BannerCarousel key={section.id || index} banners={banners(section.data)} autoplay={section.data.autoplay !== false} priority={index === 0} ImageComponent={ImageComponent} />;
|
|
163
|
+
if (section.type === "banner-carousel") return <BannerCarousel key={section.id || index} banners={banners(section.data)} autoplay={section.data.autoplay !== false} desktopHeight={typeof section.data.desktopHeight === "number" ? section.data.desktopHeight : undefined} mobileHeight={typeof section.data.mobileHeight === "number" ? section.data.mobileHeight : undefined} imageFit={section.data.imageFit === "CONTAIN" || section.data.imageFit === "NATURAL" ? section.data.imageFit : "COVER"} priority={index === 0} ImageComponent={ImageComponent} />;
|
|
162
164
|
if (section.type === "theme-component") return <ThemeComponent key={section.id || index} section={section} submitContact={submitContact} />;
|
|
163
165
|
if (["image-text", "rich-text", "cta"].includes(section.type)) return <TextSection key={section.id || index} section={section} ImageComponent={ImageComponent} />;
|
|
164
166
|
if (section.type === "products-grid" || section.type === "products-carousel") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import type { ThemeCategory, ThemeNavigationItem, ThemePageSummary, ThemeSite } from "@nuvler/theme-sdk";
|
|
2
|
+
import type { ThemeCategory, ThemeNavigationHeaderButton, ThemeNavigationItem, ThemePageSummary, ThemeSite } from "@nuvler/theme-sdk";
|
|
3
3
|
|
|
4
4
|
import { Footer } from "./footer.js";
|
|
5
5
|
import { Header } from "./header.js";
|
|
@@ -15,6 +15,7 @@ export interface NuvlerDefaultShellProps {
|
|
|
15
15
|
categories: ThemeCategory[];
|
|
16
16
|
pages: ThemePageSummary[];
|
|
17
17
|
menu?: ThemeNavigationItem[];
|
|
18
|
+
headerButton?: ThemeNavigationHeaderButton | null;
|
|
18
19
|
children: ReactNode;
|
|
19
20
|
cart?: ReactNode;
|
|
20
21
|
platformBrand?: ReactNode;
|
|
@@ -28,6 +29,7 @@ export function NuvlerDefaultShell({
|
|
|
28
29
|
categories,
|
|
29
30
|
pages,
|
|
30
31
|
menu,
|
|
32
|
+
headerButton,
|
|
31
33
|
children,
|
|
32
34
|
cart,
|
|
33
35
|
platformBrand,
|
|
@@ -73,6 +75,7 @@ export function NuvlerDefaultShell({
|
|
|
73
75
|
categories={categories}
|
|
74
76
|
pages={pages}
|
|
75
77
|
menu={menu}
|
|
78
|
+
headerButton={headerButton}
|
|
76
79
|
template={nuvlerDefaultTemplate}
|
|
77
80
|
cart={cart}
|
|
78
81
|
suggestionsEndpoint={suggestionsEndpoint}
|
|
@@ -9,7 +9,7 @@ import { plainText, ThemeImageView } from "./shared.js";
|
|
|
9
9
|
interface PreviewContext {
|
|
10
10
|
store: { name: string; slug: string };
|
|
11
11
|
site: { modules: string[]; settings: ThemeSite["settings"] };
|
|
12
|
-
navigation: { pages: ThemePageSummary[]; categories: ThemeCategory[]; menu?: ThemeNavigationItem[] };
|
|
12
|
+
navigation: { pages: ThemePageSummary[]; categories: ThemeCategory[]; menu?: ThemeNavigationItem[]; headerButton?: import("@nuvler/theme-sdk").ThemeNavigationHeaderButton | null };
|
|
13
13
|
home: { content: { sections: ThemeHomeSection[] } };
|
|
14
14
|
catalog: { products: ThemeProduct[] };
|
|
15
15
|
editorial: { posts: ThemeEditorialItem[]; services: ThemeEditorialItem[]; cases: ThemeEditorialItem[] };
|
|
@@ -100,7 +100,7 @@ export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefi
|
|
|
100
100
|
else if (route.type === "editorial-list") content = <main className="catalog-page"><section className="catalog-hero"><div className="store-container"><span>Conteúdo</span><h1>{route.title}</h1></div></section><section className="store-section"><div className="store-container"><EditorialPreview items={route.items} basePath={route.basePath} /></div></section></main>;
|
|
101
101
|
else if (route.type === "editorial-detail") content = <main className="store-section"><article className="store-container editorial-content"><span>Conteúdo</span><h1>{route.item.title}</h1><p>{route.item.description}</p></article></main>;
|
|
102
102
|
else content = <main className="not-found-page"><div className="not-found-card"><span>{route.type === "loading" ? "Carregando" : "404"}</span><h1>{route.title || (route.type === "loading" ? "Buscando conteúdo da loja" : "Conteúdo não encontrado")}</h1></div></main>;
|
|
103
|
-
return <ThemeInteractionProvider onAddToCart={addToCart}><div className="store-shell nuvler-default-theme" data-theme-id={themeDefinition.manifest.id} data-theme-version={themeDefinition.manifest.version} style={style}><Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} menu={context.navigation.menu} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} /><div className="store-page">{content}</div><Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />{cartOpen && <div className="cart-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="cart-drawer" aria-label="Carrinho de orçamento"><div className="cart-heading"><div><small>Seu orçamento</small><strong>{cartCount} {cartCount === 1 ? "item" : "itens"}</strong></div><button type="button" onClick={() => setCartOpen(false)} aria-label="Fechar carrinho">×</button></div><div className="cart-items">{!cartItems.length && <div className="cart-empty"><strong>Seu carrinho está vazio</strong><p>Abra um produto e adicione-o para montar a solicitação.</p><button type="button" onClick={() => setCartOpen(false)}>Continuar navegando</button></div>}{cartItems.map((item) => <article className="cart-item" key={item.key}><a href={item.productUrl || productUrl({ slug: item.productSlug })} onClick={() => setCartOpen(false)}><ThemeImageView image={item.image} fallbackAlt={item.title} /></a><div><strong>{item.title}</strong>{item.variantName && <small>{item.variantName}</small>}{item.sku && <small>Ref. {item.sku}</small>}<div className="cart-quantity"><button type="button" onClick={() => setCartItems((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button><span>{item.quantity}</span><button type="button" onClick={() => setCartItems((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: Math.min(99, candidate.quantity + 1) } : candidate))}>+</button><button type="button" className="cart-remove" onClick={() => setCartItems((current) => current.filter((candidate) => candidate.key !== item.key))}>Remover</button></div></div></article>)}</div>{cartItems.length > 0 && <footer className="cart-footer"><p>O valor e a disponibilidade serão confirmados pela loja.</p>{checkoutUrl ? <a className="button button-primary button-block" href={checkoutUrl} target="_blank" rel="noreferrer">Enviar orçamento pelo WhatsApp</a> : <p className="cart-warning">Configure o WhatsApp da loja para enviar o orçamento.</p>}</footer>}</aside></div>}</div></ThemeInteractionProvider>;
|
|
103
|
+
return <ThemeInteractionProvider onAddToCart={addToCart}><div className="store-shell nuvler-default-theme" data-theme-id={themeDefinition.manifest.id} data-theme-version={themeDefinition.manifest.version} style={style}><Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} menu={context.navigation.menu} headerButton={context.navigation.headerButton} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} /><div className="store-page">{content}</div><Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />{cartOpen && <div className="cart-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="cart-drawer" aria-label="Carrinho de orçamento"><div className="cart-heading"><div><small>Seu orçamento</small><strong>{cartCount} {cartCount === 1 ? "item" : "itens"}</strong></div><button type="button" onClick={() => setCartOpen(false)} aria-label="Fechar carrinho">×</button></div><div className="cart-items">{!cartItems.length && <div className="cart-empty"><strong>Seu carrinho está vazio</strong><p>Abra um produto e adicione-o para montar a solicitação.</p><button type="button" onClick={() => setCartOpen(false)}>Continuar navegando</button></div>}{cartItems.map((item) => <article className="cart-item" key={item.key}><a href={item.productUrl || productUrl({ slug: item.productSlug })} onClick={() => setCartOpen(false)}><ThemeImageView image={item.image} fallbackAlt={item.title} /></a><div><strong>{item.title}</strong>{item.variantName && <small>{item.variantName}</small>}{item.sku && <small>Ref. {item.sku}</small>}<div className="cart-quantity"><button type="button" onClick={() => setCartItems((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button><span>{item.quantity}</span><button type="button" onClick={() => setCartItems((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: Math.min(99, candidate.quantity + 1) } : candidate))}>+</button><button type="button" className="cart-remove" onClick={() => setCartItems((current) => current.filter((candidate) => candidate.key !== item.key))}>Remover</button></div></div></article>)}</div>{cartItems.length > 0 && <footer className="cart-footer"><p>O valor e a disponibilidade serão confirmados pela loja.</p>{checkoutUrl ? <a className="button button-primary button-block" href={checkoutUrl} target="_blank" rel="noreferrer">Enviar orçamento pelo WhatsApp</a> : <p className="cart-warning">Configure o WhatsApp da loja para enviar o orçamento.</p>}</footer>}</aside></div>}</div></ThemeInteractionProvider>;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
Theme.displayName = `NuvlerThemeRuntime(${themeDefinition.manifest.id})`;
|
|
@@ -514,6 +514,7 @@ select {
|
|
|
514
514
|
.cart-heading button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--store-background); color: var(--store-text); cursor: pointer; font-size: 25px; }
|
|
515
515
|
.mobile-menu-links { display: grid; padding: 10px 16px; border-bottom: 1px solid var(--store-line); }
|
|
516
516
|
.mobile-menu-links a { padding: 12px 4px; font-size: 13px; font-weight: 750; }
|
|
517
|
+
.mobile-menu-links .mobile-menu-highlight { margin-top: 8px; padding: 13px 16px; border-radius: var(--border-radius); text-align: center; }
|
|
517
518
|
.mobile-menu-categories { padding: 18px 16px; }
|
|
518
519
|
.mobile-menu-categories h2 { margin: 0 0 10px; color: var(--store-muted); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
|
|
519
520
|
.mobile-menu-category-status { margin: 0 0 10px; color: var(--store-muted); font-size: 12px; }
|
|
@@ -1094,6 +1095,7 @@ select {
|
|
|
1094
1095
|
align-items: center;
|
|
1095
1096
|
gap: 10px;
|
|
1096
1097
|
}
|
|
1098
|
+
.header-highlight-link { flex: 0 0 auto; padding: 12px 16px; border-radius: var(--border-radius); font-size: 12px; font-weight: 800; white-space: nowrap; }
|
|
1097
1099
|
|
|
1098
1100
|
.header-more-menu {
|
|
1099
1101
|
position: relative;
|
|
@@ -1272,7 +1274,7 @@ select {
|
|
|
1272
1274
|
.banner-slide {
|
|
1273
1275
|
position: relative;
|
|
1274
1276
|
flex: 0 0 100%;
|
|
1275
|
-
|
|
1277
|
+
height: var(--banner-desktop-height, 590px);
|
|
1276
1278
|
}
|
|
1277
1279
|
|
|
1278
1280
|
.banner-slide > img,
|
|
@@ -1283,6 +1285,9 @@ select {
|
|
|
1283
1285
|
height: 100%;
|
|
1284
1286
|
object-fit: cover;
|
|
1285
1287
|
}
|
|
1288
|
+
.banner-image-mobile { display: none; }
|
|
1289
|
+
.banner-carousel-settings[data-image-fit="contain"] .banner-slide > img { object-fit: contain; }
|
|
1290
|
+
.banner-carousel-settings[data-image-fit="natural"] .banner-slide > img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; left: 50%; top: 50%; transform: translate(-50%, -50%); }
|
|
1286
1291
|
|
|
1287
1292
|
.banner-overlay {
|
|
1288
1293
|
position: absolute;
|
|
@@ -3010,8 +3015,10 @@ select {
|
|
|
3010
3015
|
}
|
|
3011
3016
|
|
|
3012
3017
|
.banner-slide {
|
|
3013
|
-
|
|
3018
|
+
height: var(--banner-mobile-height, 420px);
|
|
3014
3019
|
}
|
|
3020
|
+
.banner-image-desktop { display: none; }
|
|
3021
|
+
.banner-image-mobile { display: block; }
|
|
3015
3022
|
|
|
3016
3023
|
.banner-overlay {
|
|
3017
3024
|
align-items: end;
|
|
@@ -38,6 +38,11 @@ Os componentes registrados por `defineTheme()` recebem props tipadas:
|
|
|
38
38
|
- `ProductGridProps`;
|
|
39
39
|
- `ProductDetailProps`.
|
|
40
40
|
|
|
41
|
+
O starter já aplica a navegação configurada pelo lojista, links externos e o
|
|
42
|
+
botão de destaque do cabeçalho. O banner da Home também reconhece imagem mobile,
|
|
43
|
+
altura para desktop/mobile e os modos `COVER`, `CONTAIN` e `NATURAL`. Preserve
|
|
44
|
+
esses contratos ao substituir a estrutura visual do tema.
|
|
45
|
+
|
|
41
46
|
Tipos de dados mais usados:
|
|
42
47
|
|
|
43
48
|
```ts
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.3.3"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nuvler/cli": "^0.5.
|
|
22
|
+
"@nuvler/cli": "^0.5.5",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import manifestData from "../nuvler.theme.json" with { type: "json" };
|
|
2
|
+
import type { CSSProperties } from "react";
|
|
2
3
|
import {
|
|
3
4
|
defineTheme,
|
|
4
5
|
productUrl,
|
|
@@ -7,12 +8,23 @@ import {
|
|
|
7
8
|
type HomeProps,
|
|
8
9
|
type ProductDetailProps,
|
|
9
10
|
type ProductGridProps,
|
|
11
|
+
type ThemeBannerCarouselData,
|
|
12
|
+
type ThemeHomeBanner,
|
|
10
13
|
type ThemeManifest,
|
|
11
14
|
} from "@nuvler/theme-sdk";
|
|
12
15
|
|
|
13
|
-
function Header({ site }: HeaderProps) {
|
|
16
|
+
function Header({ site, categories, pages, menu = [], headerButton }: HeaderProps) {
|
|
14
17
|
const name = site.settings?.siteName || site.tenant.name;
|
|
15
|
-
|
|
18
|
+
const links = menu.length ? menu : [
|
|
19
|
+
...categories.slice(0, 4).map((category) => ({ key: `category:${category.slug}`, label: category.name, href: `/${category.slug}`, openInNewTab: false })),
|
|
20
|
+
...pages.slice(0, 3).map((page) => ({ key: `page:${page.slug}`, label: page.title, href: `/${page.slug}`, openInNewTab: false })),
|
|
21
|
+
];
|
|
22
|
+
return <header className="theme-header">
|
|
23
|
+
<a href="/" className="theme-brand">{name}</a>
|
|
24
|
+
<nav className="theme-navigation" aria-label="Navegação principal">{links.map((item) => <a href={item.href} key={item.key} target={item.openInNewTab ? "_blank" : undefined} rel={item.openInNewTab ? "noreferrer" : undefined}>{item.label}</a>)}</nav>
|
|
25
|
+
{headerButton?.enabled && <a className="theme-header-button" href={headerButton.href} style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noreferrer" : undefined}>{headerButton.label}</a>}
|
|
26
|
+
<form action="/produtos"><input name="busca" placeholder="Buscar produtos" /><button>Buscar</button></form>
|
|
27
|
+
</header>;
|
|
16
28
|
}
|
|
17
29
|
|
|
18
30
|
function Footer({ site }: FooterProps) {
|
|
@@ -24,9 +36,23 @@ function ProductGrid({ products }: ProductGridProps) {
|
|
|
24
36
|
return <div className="theme-products">{products.map((product) => <article key={product.slug}><a href={productUrl(product)}><strong>{product.title}</strong><span>{product.sku || "Ver produto"}</span></a></article>)}</div>;
|
|
25
37
|
}
|
|
26
38
|
|
|
27
|
-
function
|
|
39
|
+
function bannerUrl(banner: ThemeHomeBanner, mobile = false): string {
|
|
40
|
+
return mobile ? banner.mobileImage?.url || banner.mobileImageUrl || "" : banner.image?.url || banner.imageUrl || "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Home({ products, site, sections }: HomeProps) {
|
|
28
44
|
const name = site.settings?.siteName || site.tenant.name;
|
|
29
|
-
|
|
45
|
+
const bannerSection = sections.find((section) => section.enabled && section.type === "banner-carousel");
|
|
46
|
+
const bannerData = bannerSection?.data as ThemeBannerCarouselData | undefined;
|
|
47
|
+
const banner = bannerData?.banners?.find((item) => bannerUrl(item));
|
|
48
|
+
return <main>
|
|
49
|
+
{banner && <section className="theme-banner" data-fit={bannerData?.imageFit || "COVER"} style={{ "--theme-banner-height": `${bannerData?.desktopHeight || 520}px`, "--theme-banner-mobile-height": `${bannerData?.mobileHeight || 360}px` } as CSSProperties}>
|
|
50
|
+
<picture>{bannerUrl(banner, true) && <source media="(max-width: 700px)" srcSet={bannerUrl(banner, true)} />}<img src={bannerUrl(banner)} alt={banner.imageAlt || banner.image?.alt || banner.title || "Banner"} /></picture>
|
|
51
|
+
{(banner.title || banner.description || (banner.buttonLabel && banner.buttonUrl)) && <div className="theme-banner-content">{banner.title && <h2>{banner.title}</h2>}{banner.description && <p>{banner.description}</p>}{banner.buttonLabel && banner.buttonUrl && <a href={banner.buttonUrl}>{banner.buttonLabel}</a>}</div>}
|
|
52
|
+
</section>}
|
|
53
|
+
<section className="theme-hero"><span>__NUVLER_THEME_NAME__</span><h1>{name}</h1><p>{site.settings?.description || "Uma nova experiência de compra."}</p><a href="/produtos">Explorar produtos</a></section>
|
|
54
|
+
<section className="theme-section"><h2>Produtos em destaque</h2><ProductGrid products={products} /></section>
|
|
55
|
+
</main>;
|
|
30
56
|
}
|
|
31
57
|
|
|
32
58
|
function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDetailProps) {
|