@nuvler/cli 0.4.1 → 0.4.3
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 +25 -2
- package/dist/commands/theme/create.js +2 -2
- package/dist/commands/theme/validate.js +21 -0
- package/dist/commands/theme/validate.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/migrate/generator.js +6 -5
- package/dist/migrate/generator.js.map +1 -1
- package/dist/nuvler.js +163 -10
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/nuvler.theme.json +1 -1
- package/dist/templates/nuvler-atelier/package.json +2 -2
- package/dist/templates/nuvler-atelier/src/definition.tsx +10 -9
- package/dist/templates/nuvler-atelier/src/theme.tsx +2 -2
- package/dist/templates/nuvler-default/README.md +50 -4
- package/dist/templates/nuvler-default/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-default/package.json +37 -5
- package/dist/templates/nuvler-default/src/banner-carousel.tsx +42 -12
- package/dist/templates/nuvler-default/src/carousel-frame.tsx +58 -0
- package/dist/templates/nuvler-default/src/definition.ts +9 -59
- package/dist/templates/nuvler-default/src/footer.tsx +7 -2
- package/dist/templates/nuvler-default/src/header-interactions.tsx +114 -12
- package/dist/templates/nuvler-default/src/header.tsx +7 -5
- package/dist/templates/nuvler-default/src/home.tsx +61 -20
- package/dist/templates/nuvler-default/src/index.ts +1 -0
- package/dist/templates/nuvler-default/src/product-carousel.tsx +13 -7
- package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +261 -0
- package/dist/templates/nuvler-default/src/product-detail.tsx +80 -55
- package/dist/templates/nuvler-default/src/products.tsx +9 -6
- package/dist/templates/nuvler-default/src/server-shell.tsx +91 -0
- package/dist/templates/nuvler-default/src/shared.tsx +28 -16
- package/dist/templates/nuvler-default/src/theme-component.tsx +6 -5
- package/dist/templates/nuvler-default/src/theme-config.ts +63 -0
- package/dist/templates/nuvler-default/src/theme.css +159 -3
- package/dist/templates/starter/nuvler.theme.json +1 -1
- package/dist/templates/starter/package.json +2 -2
- package/dist/templates/starter/src/definition.tsx +3 -2
- package/dist/theme/performance.js +126 -0
- package/dist/theme/performance.js.map +1 -0
- package/package.json +2 -2
- package/preview-host/package.json +1 -1
- package/preview-host/vendor/theme-runtime/default-theme.tsx +13 -12
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@nuvler/theme-sdk": "^1.2.
|
|
15
|
+
"@nuvler/theme-sdk": "^1.2.2"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "^19.0.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@nuvler/cli": "^0.4.
|
|
21
|
+
"@nuvler/cli": "^0.4.3",
|
|
22
22
|
"@types/react": "^19.0.0",
|
|
23
23
|
"react": "^19.0.0",
|
|
24
24
|
"typescript": "^5.9.0"
|
|
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import manifestData from "../nuvler.theme.json" with { type: "json" };
|
|
3
3
|
import {
|
|
4
4
|
defineTheme,
|
|
5
|
+
productUrl,
|
|
5
6
|
type FooterProps,
|
|
6
7
|
type HeaderProps,
|
|
7
8
|
type HomeProps,
|
|
@@ -67,7 +68,7 @@ function SmartSearch({ searchProducts }: Pick<HeaderProps, "searchProducts">) {
|
|
|
67
68
|
</form>
|
|
68
69
|
{normalized.length >= 2 && <div className="atelier-suggestions">
|
|
69
70
|
<small>{loading ? "Pesquisando…" : `${results.length} resultado(s)`}</small>
|
|
70
|
-
{!loading && results.map((product) => <a href={
|
|
71
|
+
{!loading && results.map((product) => <a href={productUrl(product)} key={product.slug}>
|
|
71
72
|
<AtelierImage image={product.image} alt={product.title} />
|
|
72
73
|
<span><strong>{product.title}</strong><em>{product.sku || product.categories[0]?.name || "Ver produto"}</em></span>
|
|
73
74
|
<b>→</b>
|
|
@@ -97,10 +98,10 @@ function Header({ site, categories, pages, cart, searchProducts, template }: Hea
|
|
|
97
98
|
</div>
|
|
98
99
|
<div className="atelier-nav-shell">
|
|
99
100
|
<nav className="atelier-container atelier-nav" aria-label="Categorias">
|
|
100
|
-
<details className="atelier-mobile-menu"><summary>Menu <span>+</span></summary><div>{categories.map((category) => <a href={
|
|
101
|
+
<details className="atelier-mobile-menu"><summary>Menu <span>+</span></summary><div>{categories.map((category) => <a href={`/${category.slug}`} key={category.slug}>{category.name}</a>)}{pages.map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</div></details>
|
|
101
102
|
<a className="atelier-all-products" href="/produtos"><span>◫</span> Catálogo completo</a>
|
|
102
|
-
{visibleCategories.map((category, index) => <a href={
|
|
103
|
-
<details className="atelier-more"><summary>Mais</summary><div>{categories.slice(6).map((category) => <a href={
|
|
103
|
+
{visibleCategories.map((category, index) => <a href={`/${category.slug}`} key={category.slug}><small>0{index + 1}</small>{category.name}</a>)}
|
|
104
|
+
<details className="atelier-more"><summary>Mais</summary><div>{categories.slice(6).map((category) => <a href={`/${category.slug}`} key={category.slug}>{category.name}</a>)}{pages.map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</div></details>
|
|
104
105
|
</nav>
|
|
105
106
|
</div>
|
|
106
107
|
</header>
|
|
@@ -123,12 +124,12 @@ function Footer({ site, pages }: FooterProps) {
|
|
|
123
124
|
|
|
124
125
|
function ProductGrid({ products, columns = 3, showCategory = true, showDescription = true }: ProductGridProps) {
|
|
125
126
|
return <div className="atelier-products" data-columns={columns}>{products.map((product, index) => <article className="atelier-product-card" key={product.slug}>
|
|
126
|
-
<a className="atelier-product-media" href={
|
|
127
|
+
<a className="atelier-product-media" href={productUrl(product)}><span className="atelier-product-index">{String(index + 1).padStart(2, "0")}</span><AtelierImage image={product.image} alt={product.title} /></a>
|
|
127
128
|
<div className="atelier-product-copy">
|
|
128
129
|
{showCategory && <small>{product.categories[0]?.name || product.brand || "Seleção"}</small>}
|
|
129
|
-
<h3><a href={
|
|
130
|
+
<h3><a href={productUrl(product)}>{product.title}</a></h3>
|
|
130
131
|
{showDescription && product.description && <p>{plainText(product.description)}</p>}
|
|
131
|
-
<div><span>{price(product) || (product.sku ? `Ref. ${product.sku}` : "Consulte condições")}</span><a href={
|
|
132
|
+
<div><span>{price(product) || (product.sku ? `Ref. ${product.sku}` : "Consulte condições")}</span><a href={productUrl(product)} aria-label={`Ver ${product.title}`}>↗</a></div>
|
|
132
133
|
</div>
|
|
133
134
|
</article>)}</div>;
|
|
134
135
|
}
|
|
@@ -147,7 +148,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
147
148
|
<div className="atelier-hero-visual">
|
|
148
149
|
<span className="atelier-orbit" /><span className="atelier-orbit second" />
|
|
149
150
|
<AtelierImage image={highlight?.image} alt={highlight?.title || heroTitle} />
|
|
150
|
-
{highlight && <a href={
|
|
151
|
+
{highlight && <a href={productUrl(highlight)}><small>Destaque da semana</small><strong>{highlight.title}</strong><span>{price(highlight) || "Conheça o produto"} →</span></a>}
|
|
151
152
|
</div>
|
|
152
153
|
</section>
|
|
153
154
|
<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>
|
|
@@ -173,7 +174,7 @@ function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDeta
|
|
|
173
174
|
<div className="atelier-gallery"><div className="atelier-gallery-main"><AtelierImage image={selectedImage} alt={product.title} /></div>{images.length > 1 && <div className="atelier-thumbnails">{images.map((image, index) => <button type="button" className={activeImage === image.url ? "active" : ""} onClick={() => setActiveImage(image.url)} key={`${image.url}-${index}`}><AtelierImage image={image} alt={`${product.title} ${index + 1}`} /></button>)}</div>}</div>
|
|
174
175
|
<div className="atelier-product-info"><span className="atelier-kicker">{product.categories[0]?.name || product.brand || "Produto selecionado"}</span><h1>{product.title}</h1><div className="atelier-product-meta"><span>{price(product) || "Preço sob consulta"}</span>{(variant?.sku || product.sku) && <small>Ref. {variant?.sku || product.sku}</small>}</div><div className="atelier-description">{descriptionContent}</div>
|
|
175
176
|
{product.variantOptions.map((option) => <fieldset key={option.name}><legend>{option.name}: <strong>{selected[option.name]}</strong></legend><div>{option.values.map((optionValue) => <button type="button" className={selected[option.name] === optionValue ? "active" : ""} onClick={() => setSelected((current) => ({ ...current, [option.name]: optionValue }))} key={optionValue}>{optionValue}</button>)}</div></fieldset>)}
|
|
176
|
-
<button className="atelier-button atelier-button-dark atelier-add" type="button" disabled={product.variantOptions.length > 0 && !variant} onClick={() => onAddToCart?.({ productSlug: product.slug, title: product.title, sku: variant?.sku || product.sku, variantId: variant?.id, variantName: variant?.name, image: variant?.image || product.image, unitPrice: product.promotionalPrice ?? product.price })}>Adicionar à seleção <b>+</b></button>
|
|
177
|
+
<button className="atelier-button atelier-button-dark atelier-add" type="button" disabled={product.variantOptions.length > 0 && !variant} onClick={() => onAddToCart?.({ productSlug: product.slug, productUrl: productUrl(product), title: product.title, sku: variant?.sku || product.sku, variantId: variant?.id, variantName: variant?.name, image: variant?.image || product.image, unitPrice: product.promotionalPrice ?? product.price })}>Adicionar à seleção <b>+</b></button>
|
|
177
178
|
<div className="atelier-detail-benefits"><span><b>01</b> Atendimento especializado</span><span><b>02</b> Orçamento pelo WhatsApp</span></div>
|
|
178
179
|
</div>
|
|
179
180
|
</article>;
|
|
@@ -22,7 +22,7 @@ function catalogHref(route: Extract<ThemeRoute, { type: "catalog" }>, page: numb
|
|
|
22
22
|
route.variants.forEach((variant) => params.append("variante", variant));
|
|
23
23
|
if (page > 1) params.set("pagina", String(page));
|
|
24
24
|
const pathname = route.categoryPath.length
|
|
25
|
-
?
|
|
25
|
+
? `/${route.categoryPath.map(encodeURIComponent).join("/")}`
|
|
26
26
|
: "/produtos";
|
|
27
27
|
return params.size ? `${pathname}?${params}` : pathname;
|
|
28
28
|
}
|
|
@@ -86,7 +86,7 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
|
|
|
86
86
|
<header className="atelier-page-heading"><span className="atelier-kicker">Catálogo editorial</span><h1>{route.search ? `Resultados para “${route.search}”` : "Todos os produtos"}</h1><p>{route.pagination.total} produto(s) encontrados para sua seleção.</p></header>
|
|
87
87
|
<div className="atelier-catalog-layout">
|
|
88
88
|
<aside className="atelier-filters">
|
|
89
|
-
<form action={route.categoryPath.length ?
|
|
89
|
+
<form action={route.categoryPath.length ? `/${route.categoryPath.join("/")}` : "/produtos"}><label htmlFor="atelier-catalog-search">Refine sua busca</label><div><input id="atelier-catalog-search" name="busca" defaultValue={route.search} placeholder="Nome, marca ou referência" /><button>↗</button></div></form>
|
|
90
90
|
{route.facets.map((facet) => <fieldset key={facet.name}><legend>{facet.name}</legend>{facet.values.map(({ value, count }) => { const token = `${facet.name}::${value}`; return <label key={token}><input type="checkbox" name="variante" value={token} defaultChecked={route.variants.includes(token)} /><span>{value}</span><small>{count}</small></label>; })}</fieldset>)}
|
|
91
91
|
</aside>
|
|
92
92
|
<section><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
# Nuvler Default
|
|
2
2
|
|
|
3
|
-
Fonte oficial do tema padrão.
|
|
4
|
-
|
|
3
|
+
Fonte oficial do tema padrão. O mesmo código possui duas distribuições:
|
|
4
|
+
|
|
5
|
+
- `@nuvler/theme-default`, instalado no build do Store para renderização SSR;
|
|
6
|
+
- artefato imutável do Theme Registry, usado pelo preview e pela transição de
|
|
7
|
+
temas que ainda dependem do runtime remoto.
|
|
5
8
|
|
|
6
9
|
Ele é a referência de compatibilidade entre o Store e temas externos:
|
|
7
10
|
|
|
8
11
|
- `nuvler.theme.json` declara identidade, versão, entrada e estilos;
|
|
9
12
|
- `runtimeVersion` e `sdkVersion` declaram a compatibilidade pública do tema;
|
|
10
13
|
- `src/theme.tsx` é a entrada do preview Vite;
|
|
14
|
+
- `@nuvler/theme-default/server` expõe `NuvlerDefaultShell` para Server
|
|
15
|
+
Components;
|
|
16
|
+
- `@nuvler/theme-default/config`, `/home`, `/products` e `/product-detail`
|
|
17
|
+
permitem que o Store importe apenas o renderer necessário para cada rota;
|
|
18
|
+
- `@nuvler/theme-default/client` expõe a ponte do carrinho para a ilha
|
|
19
|
+
interativa da página de produto;
|
|
11
20
|
- `src/index.ts` expõe `nuvlerDefaultTheme`, `manifest`, `Theme`, `Header`,
|
|
12
21
|
`Footer`, `Home`, `ProductGrid` e `ProductDetail`;
|
|
13
22
|
- `src/theme.css` contém o visual completo do Store, incluindo Home, catálogo,
|
|
@@ -16,6 +25,26 @@ Ele é a referência de compatibilidade entre o Store e temas externos:
|
|
|
16
25
|
React é `peerDependency`: o tema reutiliza a cópia fornecida pelo
|
|
17
26
|
Store/preview host. Seus contratos vêm de `@nuvler/theme-sdk`.
|
|
18
27
|
|
|
28
|
+
O shell, o conteúdo dos banners, cards, listagens e textos de produto são
|
|
29
|
+
renderizados no servidor. Header, controles de carrossel, galeria, variantes e
|
|
30
|
+
carrinho são ilhas client isoladas; passar Server Components pelo `children`
|
|
31
|
+
dessas ilhas não transforma o restante da página em Client Component.
|
|
32
|
+
|
|
33
|
+
O Store pode injetar seu componente de imagem nos renderizadores locais. Home,
|
|
34
|
+
cards, logo e galeria usam dimensões intrínsecas, `sizes` responsivo e lazy
|
|
35
|
+
loading; somente a imagem principal da primeira seção visual ou da página de
|
|
36
|
+
produto recebe prioridade de LCP. O bundle remoto mantém o `<img>` nativo com
|
|
37
|
+
os mesmos atributos como fallback portátil.
|
|
38
|
+
|
|
39
|
+
A tipografia padrão usa a pilha local `--nuvler-font-sans`, sem requisição de
|
|
40
|
+
fonte e sem bloquear a primeira renderização. O Store define esse token no
|
|
41
|
+
layout global; outros hosts podem sobrescrevê-lo. Quando o token não existir, o
|
|
42
|
+
tema recorre à mesma pilha de fontes de sistema.
|
|
43
|
+
|
|
44
|
+
O tema também serve como referência do performance budget inicial do CLI. Rode
|
|
45
|
+
o build do artefato antes de `theme validate` para incluir o JavaScript
|
|
46
|
+
entregue na medição; os avisos de budget são informativos nesta versão.
|
|
47
|
+
|
|
19
48
|
Para executar:
|
|
20
49
|
|
|
21
50
|
```bash
|
|
@@ -26,7 +55,7 @@ node packages/cli/dist/nuvler.js theme configure \
|
|
|
26
55
|
node packages/cli/dist/nuvler.js theme validate \
|
|
27
56
|
--theme themes/nuvler-default
|
|
28
57
|
|
|
29
|
-
npm run typecheck -w @nuvler/theme-
|
|
58
|
+
npm run typecheck -w @nuvler/theme-default
|
|
30
59
|
|
|
31
60
|
node packages/cli/dist/nuvler.js theme dev \
|
|
32
61
|
--theme themes/nuvler-default
|
|
@@ -35,12 +64,29 @@ node packages/cli/dist/nuvler.js theme dev \
|
|
|
35
64
|
Para compilar, gerar o artefato ou publicar, execute na raiz do tooling:
|
|
36
65
|
|
|
37
66
|
```bash
|
|
67
|
+
npm run pack:store
|
|
68
|
+
npm publish ./artifacts/nuvler-theme-default-1.0.4.tgz --access public
|
|
69
|
+
|
|
38
70
|
node packages/cli/dist/nuvler.js theme build --theme themes/nuvler-default
|
|
39
71
|
npm run pack:theme -- nuvler-default
|
|
40
72
|
node packages/cli/dist/nuvler.js theme publish --theme themes/nuvler-default --official
|
|
41
73
|
```
|
|
42
74
|
|
|
43
|
-
|
|
75
|
+
O pacote npm contém o renderer local e o CSS. O artefato do Theme Registry é
|
|
76
|
+
gerado separadamente como `artifacts/nuvler-default-1.0.4.nuvler-theme.tgz`.
|
|
77
|
+
|
|
78
|
+
Exemplo no App Router:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { NuvlerDefaultShell } from "@nuvler/theme-default/server";
|
|
82
|
+
import "@nuvler/theme-default/styles.css";
|
|
83
|
+
|
|
84
|
+
export default function StoreLayout({ children }) {
|
|
85
|
+
return <NuvlerDefaultShell site={site} categories={categories} pages={pages}>
|
|
86
|
+
{children}
|
|
87
|
+
</NuvlerDefaultShell>;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
44
90
|
|
|
45
91
|
`--official` exige uma sessão `PLATFORM_ADMIN` e publica o tema como
|
|
46
92
|
`PLATFORM/PUBLIC`. Para testar temporariamente outra loja autorizada, use
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"id": "nuvler-default",
|
|
4
4
|
"name": "Nuvler Default",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.4",
|
|
6
6
|
"runtimeVersion": "1",
|
|
7
|
-
"sdkVersion": "^1.2.
|
|
7
|
+
"sdkVersion": "^1.2.2",
|
|
8
8
|
"entry": "src/theme.tsx",
|
|
9
9
|
"styles": ["src/theme.css"],
|
|
10
10
|
"presentation": {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@nuvler/theme-
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"private": true,
|
|
2
|
+
"name": "@nuvler/theme-default",
|
|
3
|
+
"version": "1.0.4",
|
|
5
4
|
"description": "Tema padrão oficial da Nuvler",
|
|
6
5
|
"type": "module",
|
|
7
6
|
"sideEffects": ["**/*.css"],
|
|
@@ -13,6 +12,36 @@
|
|
|
13
12
|
"import": "./dist/src/index.js",
|
|
14
13
|
"default": "./dist/src/index.js"
|
|
15
14
|
},
|
|
15
|
+
"./server": {
|
|
16
|
+
"types": "./dist/src/server-shell.d.ts",
|
|
17
|
+
"import": "./dist/src/server-shell.js",
|
|
18
|
+
"default": "./dist/src/server-shell.js"
|
|
19
|
+
},
|
|
20
|
+
"./client": {
|
|
21
|
+
"types": "./dist/src/product-detail-interactive.d.ts",
|
|
22
|
+
"import": "./dist/src/product-detail-interactive.js",
|
|
23
|
+
"default": "./dist/src/product-detail-interactive.js"
|
|
24
|
+
},
|
|
25
|
+
"./config": {
|
|
26
|
+
"types": "./dist/src/theme-config.d.ts",
|
|
27
|
+
"import": "./dist/src/theme-config.js",
|
|
28
|
+
"default": "./dist/src/theme-config.js"
|
|
29
|
+
},
|
|
30
|
+
"./home": {
|
|
31
|
+
"types": "./dist/src/home.d.ts",
|
|
32
|
+
"import": "./dist/src/home.js",
|
|
33
|
+
"default": "./dist/src/home.js"
|
|
34
|
+
},
|
|
35
|
+
"./products": {
|
|
36
|
+
"types": "./dist/src/products.d.ts",
|
|
37
|
+
"import": "./dist/src/products.js",
|
|
38
|
+
"default": "./dist/src/products.js"
|
|
39
|
+
},
|
|
40
|
+
"./product-detail": {
|
|
41
|
+
"types": "./dist/src/product-detail.d.ts",
|
|
42
|
+
"import": "./dist/src/product-detail.js",
|
|
43
|
+
"default": "./dist/src/product-detail.js"
|
|
44
|
+
},
|
|
16
45
|
"./styles.css": "./dist/theme.css",
|
|
17
46
|
"./manifest": "./dist/nuvler.theme.json"
|
|
18
47
|
},
|
|
@@ -23,14 +52,14 @@
|
|
|
23
52
|
"build": "nuvler theme build --theme .",
|
|
24
53
|
"build:package": "node scripts/clean-dist.mjs && tsc -p tsconfig.json && node scripts/copy-assets.mjs",
|
|
25
54
|
"pack": "nuvler theme pack --theme .",
|
|
26
|
-
"publish": "nuvler theme publish --theme .",
|
|
55
|
+
"publish:registry": "nuvler theme publish --theme .",
|
|
27
56
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
28
57
|
},
|
|
29
58
|
"peerDependencies": {
|
|
30
59
|
"react": "^19.0.0"
|
|
31
60
|
},
|
|
32
61
|
"dependencies": {
|
|
33
|
-
"@nuvler/theme-sdk": "^1.2.
|
|
62
|
+
"@nuvler/theme-sdk": "^1.2.2"
|
|
34
63
|
},
|
|
35
64
|
"devDependencies": {
|
|
36
65
|
"@types/react": "^19.0.0",
|
|
@@ -38,5 +67,8 @@
|
|
|
38
67
|
},
|
|
39
68
|
"engines": {
|
|
40
69
|
"node": "^20.19.0 || >=22.12.0"
|
|
70
|
+
},
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public"
|
|
41
73
|
}
|
|
42
74
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { ThemeImageView } from "./shared.js";
|
|
1
|
+
import { BannerCarouselFrame } from "./carousel-frame.js";
|
|
2
|
+
import type { ThemeImage } from "@nuvler/theme-sdk";
|
|
3
|
+
import { ThemeImageView, type ThemeImageComponent } from "./shared.js";
|
|
5
4
|
|
|
6
5
|
export interface ThemeBanner {
|
|
7
6
|
imageUrl: string;
|
|
7
|
+
image?: ThemeImage | null;
|
|
8
8
|
imageAlt?: string;
|
|
9
9
|
title?: string;
|
|
10
10
|
description?: string;
|
|
@@ -12,13 +12,43 @@ export interface ThemeBanner {
|
|
|
12
12
|
buttonUrl?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export function BannerCarousel({ banners, autoplay
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, [autoplay, banners.length]);
|
|
15
|
+
export function BannerCarousel({ banners, autoplay, priority = false, ImageComponent = ThemeImageView }: {
|
|
16
|
+
banners: ThemeBanner[];
|
|
17
|
+
autoplay: boolean;
|
|
18
|
+
priority?: boolean;
|
|
19
|
+
ImageComponent?: ThemeImageComponent;
|
|
20
|
+
}) {
|
|
22
21
|
if (!banners.length) return null;
|
|
23
|
-
return
|
|
22
|
+
return (
|
|
23
|
+
<BannerCarouselFrame count={banners.length} autoplay={autoplay}>
|
|
24
|
+
{banners.map((banner, index) => (
|
|
25
|
+
<article className="banner-slide" data-banner-slide key={`${banner.imageUrl}-${index}`} aria-hidden={index !== 0}>
|
|
26
|
+
<ImageComponent
|
|
27
|
+
image={banner.image ?? {
|
|
28
|
+
url: banner.imageUrl,
|
|
29
|
+
alt: banner.imageAlt || banner.title || "Banner",
|
|
30
|
+
width: null,
|
|
31
|
+
height: null,
|
|
32
|
+
}}
|
|
33
|
+
fallbackAlt={banner.title || "Banner"}
|
|
34
|
+
priority={priority && index === 0}
|
|
35
|
+
sizes="100vw"
|
|
36
|
+
fallbackWidth={1600}
|
|
37
|
+
fallbackHeight={640}
|
|
38
|
+
/>
|
|
39
|
+
{(banner.title || banner.description || (banner.buttonLabel && banner.buttonUrl)) && (
|
|
40
|
+
<div className="banner-overlay">
|
|
41
|
+
<div className="store-container">
|
|
42
|
+
<div className="banner-copy">
|
|
43
|
+
{banner.title && <h2>{banner.title}</h2>}
|
|
44
|
+
{banner.description && <p>{banner.description}</p>}
|
|
45
|
+
{banner.buttonLabel && banner.buttonUrl && <a className="button button-primary" href={banner.buttonUrl}>{banner.buttonLabel}</a>}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
)}
|
|
50
|
+
</article>
|
|
51
|
+
))}
|
|
52
|
+
</BannerCarouselFrame>
|
|
53
|
+
);
|
|
24
54
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
export function BannerCarouselFrame({
|
|
6
|
+
children,
|
|
7
|
+
count,
|
|
8
|
+
autoplay,
|
|
9
|
+
}: {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
count: number;
|
|
12
|
+
autoplay: boolean;
|
|
13
|
+
}) {
|
|
14
|
+
const [active, setActive] = useState(0);
|
|
15
|
+
const track = useRef<HTMLDivElement>(null);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const slides = track.current?.querySelectorAll<HTMLElement>("[data-banner-slide]");
|
|
19
|
+
slides?.forEach((slide, index) => slide.setAttribute("aria-hidden", String(active !== index)));
|
|
20
|
+
}, [active]);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!autoplay || count < 2) return;
|
|
24
|
+
const timer = window.setInterval(() => setActive((current) => (current + 1) % count), 6000);
|
|
25
|
+
return () => window.clearInterval(timer);
|
|
26
|
+
}, [autoplay, count]);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<section className="banner-carousel" aria-roledescription="carrossel" aria-label="Banners da loja">
|
|
30
|
+
<div className="banner-track" ref={track} style={{ transform: `translateX(-${active * 100}%)` }}>
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
{count > 1 && <>
|
|
34
|
+
<button className="carousel-arrow carousel-arrow-prev" type="button" aria-label="Banner anterior" onClick={() => setActive((active - 1 + count) % count)}>‹</button>
|
|
35
|
+
<button className="carousel-arrow carousel-arrow-next" type="button" aria-label="Próximo banner" onClick={() => setActive((active + 1) % count)}>›</button>
|
|
36
|
+
<div className="carousel-dots">
|
|
37
|
+
{Array.from({ length: count }, (_, index) => <button key={index} type="button" className={index === active ? "active" : ""} aria-label={`Ir para banner ${index + 1}`} onClick={() => setActive(index)} />)}
|
|
38
|
+
</div>
|
|
39
|
+
</>}
|
|
40
|
+
</section>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function ProductCarouselFrame({ children }: { children: ReactNode }) {
|
|
45
|
+
const track = useRef<HTMLDivElement>(null);
|
|
46
|
+
const move = (direction: -1 | 1) => track.current?.scrollBy({
|
|
47
|
+
left: direction * Math.min(track.current.clientWidth, 900),
|
|
48
|
+
behavior: "smooth",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div className="product-carousel">
|
|
53
|
+
<div className="product-carousel-track" ref={track}>{children}</div>
|
|
54
|
+
<button type="button" className="carousel-arrow carousel-arrow-prev" onClick={() => move(-1)} aria-label="Produtos anteriores">‹</button>
|
|
55
|
+
<button type="button" className="carousel-arrow carousel-arrow-next" onClick={() => move(1)} aria-label="Próximos produtos">›</button>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -1,70 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
defineTheme,
|
|
4
|
-
type ThemeHomeSection,
|
|
5
|
-
type ThemeManifest,
|
|
6
|
-
} from "@nuvler/theme-sdk";
|
|
1
|
+
import { defineTheme } from "@nuvler/theme-sdk";
|
|
7
2
|
import { Footer } from "./footer.js";
|
|
8
3
|
import { Header } from "./header.js";
|
|
9
4
|
import { Home } from "./home.js";
|
|
10
5
|
import { ProductDetail } from "./product-detail.js";
|
|
11
6
|
import { ProductGrid } from "./products.js";
|
|
7
|
+
import {
|
|
8
|
+
manifest,
|
|
9
|
+
nuvlerDefaultTemplate,
|
|
10
|
+
nuvlerDefaultTokens,
|
|
11
|
+
} from "./theme-config.js";
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
return { id, type, enabled: true, order, data: {} };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const manifest = manifestData as ThemeManifest;
|
|
13
|
+
export { manifest } from "./theme-config.js";
|
|
18
14
|
|
|
19
15
|
export const nuvlerDefaultTheme = defineTheme({
|
|
20
16
|
manifest,
|
|
21
|
-
tokens:
|
|
22
|
-
|
|
23
|
-
primary: "#176b3a",
|
|
24
|
-
primaryText: "#ffffff",
|
|
25
|
-
secondary: "#d99b31",
|
|
26
|
-
secondaryText: "#18221b",
|
|
27
|
-
accent: "#b45309",
|
|
28
|
-
background: "#f7f7f2",
|
|
29
|
-
surface: "#ffffff",
|
|
30
|
-
surfaceAlt: "#eef2e9",
|
|
31
|
-
text: "#18221b",
|
|
32
|
-
textMuted: "#657068",
|
|
33
|
-
border: "#dfe4dd",
|
|
34
|
-
headerBackground: "#ffffff",
|
|
35
|
-
headerText: "#18221b",
|
|
36
|
-
footerBackground: "#14251a",
|
|
37
|
-
footerText: "#f7f7f2",
|
|
38
|
-
},
|
|
39
|
-
layout: { containerWidth: 1280, borderRadius: 18 },
|
|
40
|
-
},
|
|
41
|
-
template: {
|
|
42
|
-
announcement: "Soluções, conteúdo e atendimento para o seu negócio",
|
|
43
|
-
footerTagline: "Soluções, conteúdo e atendimento próximo para aproximar sua marca das pessoas.",
|
|
44
|
-
footerNavigationLabel: "Navegação",
|
|
45
|
-
footerNote: "Conteúdo e atendimento que geram confiança",
|
|
46
|
-
socialLabel: "Acompanhe a empresa",
|
|
47
|
-
benefits: [
|
|
48
|
-
{ title: "Soluções sob medida", description: "Serviços pensados para o seu momento" },
|
|
49
|
-
{ title: "Conteúdo relevante", description: "Informação para ajudar nas decisões" },
|
|
50
|
-
{ title: "Atendimento próximo", description: "Fale diretamente com a empresa" },
|
|
51
|
-
],
|
|
52
|
-
fallbackSections(modules) {
|
|
53
|
-
const sections = [section("default-hero", "hero", 0)];
|
|
54
|
-
let order = 1;
|
|
55
|
-
if (modules.includes("SERVICES")) sections.push(section("default-services", "services-grid", order++));
|
|
56
|
-
if (modules.includes("CASES")) sections.push(section("default-cases", "cases-grid", order++));
|
|
57
|
-
if (modules.includes("PRODUCTS")) sections.push(section("default-products", "products-carousel", order++));
|
|
58
|
-
if (modules.includes("BLOG")) sections.push(section("default-blog", "blog-grid", order));
|
|
59
|
-
return sections;
|
|
60
|
-
},
|
|
61
|
-
primaryAction(modules) {
|
|
62
|
-
if (modules.includes("SERVICES")) return { label: "Conheça nossos serviços", href: "/servicos" };
|
|
63
|
-
if (modules.includes("PRODUCTS")) return { label: "Ver produtos", href: "/produtos" };
|
|
64
|
-
if (modules.includes("CASES")) return { label: "Conheça nossos cases", href: "/cases" };
|
|
65
|
-
if (modules.includes("BLOG")) return { label: "Ver conteúdos", href: "/blog" };
|
|
66
|
-
return { label: "Conheça a empresa", href: "/" };
|
|
67
|
-
},
|
|
68
|
-
},
|
|
17
|
+
tokens: nuvlerDefaultTokens,
|
|
18
|
+
template: nuvlerDefaultTemplate,
|
|
69
19
|
components: { Header, Footer, Home, ProductGrid, ProductDetail },
|
|
70
20
|
});
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { FooterProps } from "@nuvler/theme-sdk";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
+
export interface NuvlerDefaultFooterProps extends FooterProps {
|
|
5
|
+
platformBrand?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function Footer({ site, pages, template, platformBrand }: NuvlerDefaultFooterProps) {
|
|
4
9
|
const settings = site.settings;
|
|
5
10
|
const name = settings?.siteName || site.tenant.name;
|
|
6
|
-
return <footer className="store-footer"><div className="store-container footer-grid"><div><strong className="footer-brand">{name}</strong><p>{settings?.description || template.footerTagline}</p></div><div><strong>{template.footerNavigationLabel}</strong>{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>}<a href="/">Início</a></div>{pages.length > 0 && <div><strong>Institucional</strong>{pages.slice(0, 6).map((page) => <a key={page.slug} href={`/${page.slug}`}>{page.title}</a>)}</div>}<div><strong>Atendimento</strong>{settings?.contact.email && <a href={`mailto:${settings.contact.email}`}>{settings.contact.email}</a>}{settings?.contact.phone && <a href={`tel:${settings.contact.phone}`}>{settings.contact.phone}</a>}{settings?.contact.address && <span>{settings.contact.address}</span>}</div>{settings?.social && Object.values(settings.social).some(Boolean) && <div className="footer-social"><strong>{template.socialLabel}</strong>{settings.social.instagram && <a href={settings.social.instagram} target="_blank" rel="noreferrer">Instagram</a>}{settings.social.facebook && <a href={settings.social.facebook} target="_blank" rel="noreferrer">Facebook</a>}{settings.social.youtube && <a href={settings.social.youtube} target="_blank" rel="noreferrer">YouTube</a>}{settings.social.tiktok && <a href={settings.social.tiktok} target="_blank" rel="noreferrer">TikTok</a>}</div>}</div><div className="store-container footer-bottom"><span>© {new Date().getFullYear()} {name}</span><span>{template.footerNote}</span
|
|
11
|
+
return <footer className="store-footer"><div className="store-container footer-grid"><div><strong className="footer-brand">{name}</strong><p>{settings?.description || template.footerTagline}</p></div><div><strong>{template.footerNavigationLabel}</strong>{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>}<a href="/">Início</a></div>{pages.length > 0 && <div><strong>Institucional</strong>{pages.slice(0, 6).map((page) => <a key={page.slug} href={`/${page.slug}`}>{page.title}</a>)}</div>}<div><strong>Atendimento</strong>{settings?.contact.email && <a href={`mailto:${settings.contact.email}`}>{settings.contact.email}</a>}{settings?.contact.phone && <a href={`tel:${settings.contact.phone}`}>{settings.contact.phone}</a>}{settings?.contact.address && <span>{settings.contact.address}</span>}</div>{settings?.social && Object.values(settings.social).some(Boolean) && <div className="footer-social"><strong>{template.socialLabel}</strong>{settings.social.instagram && <a href={settings.social.instagram} target="_blank" rel="noreferrer">Instagram</a>}{settings.social.facebook && <a href={settings.social.facebook} target="_blank" rel="noreferrer">Facebook</a>}{settings.social.youtube && <a href={settings.social.youtube} target="_blank" rel="noreferrer">YouTube</a>}{settings.social.tiktok && <a href={settings.social.tiktok} target="_blank" rel="noreferrer">TikTok</a>}</div>}</div><div className="store-container footer-bottom"><span>© {new Date().getFullYear()} {name}</span><span>{template.footerNote}</span>{platformBrand && <span data-nuvler-platform-brand-slot>{platformBrand}</span>}</div></footer>;
|
|
7
12
|
}
|