@nuvler/cli 0.4.1 → 0.4.2
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 +1 -1
- 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/nuvler.js +156 -4
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/package.json +1 -1
- package/dist/templates/nuvler-default/README.md +50 -4
- package/dist/templates/nuvler-default/package.json +34 -2
- 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 +1 -1
- package/dist/templates/nuvler-default/src/header.tsx +3 -3
- package/dist/templates/nuvler-default/src/home.tsx +41 -17
- 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 +230 -0
- package/dist/templates/nuvler-default/src/product-detail.tsx +80 -55
- package/dist/templates/nuvler-default/src/products.tsx +6 -5
- package/dist/templates/nuvler-default/src/server-shell.tsx +88 -0
- package/dist/templates/nuvler-default/src/shared.tsx +25 -9
- package/dist/templates/nuvler-default/src/theme-config.ts +63 -0
- package/dist/templates/nuvler-default/src/theme.css +21 -1
- package/dist/templates/starter/package.json +1 -1
- package/dist/theme/performance.js +126 -0
- package/dist/theme/performance.js.map +1 -0
- package/package.json +1 -1
|
@@ -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.2.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.2.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
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@nuvler/theme-
|
|
2
|
+
"name": "@nuvler/theme-default",
|
|
3
3
|
"version": "1.0.2",
|
|
4
|
-
"private": true,
|
|
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
|
},
|
|
@@ -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
|
}
|
|
@@ -159,7 +159,7 @@ export function SmartProductSearch({ endpoint = "/api/product-suggestions", quer
|
|
|
159
159
|
<div className="search-suggestions-heading"><strong>Sugestões para “{query}”</strong>{!loading && <span>{resultLabel}</span>}</div>
|
|
160
160
|
{loading && <div className="search-suggestions-loading"><span aria-hidden="true" /><p>Procurando os produtos mais próximos…</p></div>}
|
|
161
161
|
{!loading && results.map((product, index) => <a id={`theme-search-result-${index}`} className={activeIndex === index ? "active" : ""} href={`/produto/${product.slug}`} role="option" aria-selected={activeIndex === index} key={product.slug} onPointerEnter={() => setActiveIndex(index)}>
|
|
162
|
-
<span className="search-suggestion-image"><ThemeImageView image={product.image} fallbackAlt={product.title} /></span>
|
|
162
|
+
<span className="search-suggestion-image"><ThemeImageView image={product.image} fallbackAlt={product.title} sizes="56px" fallbackWidth={112} fallbackHeight={112} /></span>
|
|
163
163
|
<span className="search-suggestion-copy"><strong>{product.title}</strong><span className="search-suggestion-meta">{product.categories[0]?.name && <small>{product.categories[0].name}</small>}{product.sku && <small>Ref. {product.sku}</small>}</span></span>
|
|
164
164
|
{displayPrice(product) && <b>{displayPrice(product)}</b>}
|
|
165
165
|
<span className="search-suggestion-arrow" aria-hidden="true">→</span>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { HeaderProps } from "@nuvler/theme-sdk";
|
|
2
2
|
import { CategoryNavigation, MobileStoreMenu, SmartProductSearch } from "./header-interactions.js";
|
|
3
|
-
import { ThemeImageView } from "./shared.js";
|
|
3
|
+
import { ThemeImageView, type ThemeImageComponent } from "./shared.js";
|
|
4
4
|
|
|
5
5
|
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, template, cart, suggestionsEndpoint, suggestionsQueryParam, searchProducts }: HeaderProps) {
|
|
9
|
+
export function Header({ site, categories, pages, 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 hasExtra = site.modules.some((module) => ["BLOG", "SERVICES", "CASES"].includes(module)) || pages.length > 0;
|
|
13
|
-
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} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <
|
|
13
|
+
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} /><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>{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></>;
|
|
14
14
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { HomeProps, ThemeEditorialItem, ThemeHomeSection, ThemeSite } from "@nuvler/theme-sdk";
|
|
1
|
+
import type { HomeProps, ThemeEditorialItem, ThemeHomeSection, ThemeImage, ThemeSite } from "@nuvler/theme-sdk";
|
|
2
2
|
import { BannerCarousel, type ThemeBanner } from "./banner-carousel.js";
|
|
3
3
|
import { ProductCarousel } from "./product-carousel.js";
|
|
4
|
-
import { ThemeImageView } from "./shared.js";
|
|
4
|
+
import { ThemeImageView, type ThemeImageComponent } from "./shared.js";
|
|
5
5
|
|
|
6
6
|
function text(data: Record<string, unknown>, key: string, fallback = "") {
|
|
7
7
|
const value = data[key];
|
|
@@ -13,13 +13,37 @@ function limit(data: Record<string, unknown>) {
|
|
|
13
13
|
return Number.isInteger(value) ? Math.min(12, Math.max(1, value)) : 6;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
function imageValue(value: unknown): ThemeImage | null {
|
|
17
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
18
|
+
const image = value as Record<string, unknown>;
|
|
19
|
+
if (typeof image.url !== "string" || !image.url) return null;
|
|
20
|
+
return {
|
|
21
|
+
url: image.url,
|
|
22
|
+
alt: typeof image.alt === "string" ? image.alt : null,
|
|
23
|
+
width: typeof image.width === "number" ? image.width : null,
|
|
24
|
+
height: typeof image.height === "number" ? image.height : null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function sectionImage(data: Record<string, unknown>, fallbackAlt: string): ThemeImage | null {
|
|
29
|
+
const enriched = imageValue(data.image);
|
|
30
|
+
if (enriched) return enriched;
|
|
31
|
+
const imageUrl = text(data, "imageUrl");
|
|
32
|
+
return imageUrl ? {
|
|
33
|
+
url: imageUrl,
|
|
34
|
+
alt: text(data, "imageAlt", fallbackAlt),
|
|
35
|
+
width: null,
|
|
36
|
+
height: null,
|
|
37
|
+
} : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
16
40
|
function banners(data: Record<string, unknown>): ThemeBanner[] {
|
|
17
41
|
if (!Array.isArray(data.banners)) return [];
|
|
18
42
|
return data.banners.flatMap((entry) => {
|
|
19
43
|
if (!entry || typeof entry !== "object") return [];
|
|
20
44
|
const item = entry as Record<string, unknown>;
|
|
21
45
|
if (typeof item.imageUrl !== "string" || !item.imageUrl) return [];
|
|
22
|
-
return [{ imageUrl: item.imageUrl, imageAlt: typeof item.imageAlt === "string" ? item.imageAlt : 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 }];
|
|
46
|
+
return [{ imageUrl: item.imageUrl, image: imageValue(item.image), imageAlt: typeof item.imageAlt === "string" ? item.imageAlt : 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 }];
|
|
23
47
|
});
|
|
24
48
|
}
|
|
25
49
|
|
|
@@ -27,43 +51,43 @@ function Heading({ data, title, href }: { data: Record<string, unknown>; title:
|
|
|
27
51
|
return <div className="section-heading"><div><span>{text(data, "eyebrow", "Em destaque")}</span><h2>{text(data, "title", title)}</h2></div><a href={href}>Ver todos</a></div>;
|
|
28
52
|
}
|
|
29
53
|
|
|
30
|
-
function Hero({ section, site, action }: { section: ThemeHomeSection; site: ThemeSite; action: { label: string; href: string } }) {
|
|
54
|
+
function Hero({ section, site, action, priority, ImageComponent = ThemeImageView }: { section: ThemeHomeSection; site: ThemeSite; action: { label: string; href: string }; priority: boolean; ImageComponent?: ThemeImageComponent }) {
|
|
31
55
|
const name = site.settings?.siteName || site.tenant.name;
|
|
32
56
|
const title = text(section.data, "title", "Tudo o que você procura, em um só lugar.");
|
|
33
57
|
const description = text(section.data, "description", site.settings?.description || `Conheça a seleção de produtos da ${name}.`);
|
|
34
|
-
const
|
|
58
|
+
const image = sectionImage(section.data, title);
|
|
35
59
|
const copy = <div className="hero-copy"><span className="hero-eyebrow">{text(section.data, "eyebrow", "Bem-vindo à nossa loja")}</span><h1>{title}</h1><p>{description}</p><div className="hero-actions"><a className="button button-primary" href={text(section.data, "buttonUrl", action.href)}>{text(section.data, "buttonLabel", action.label)}</a>{site.modules.includes("PRODUCTS") && <a className="text-link" href="/produtos">Ver catálogo completo <span>→</span></a>}</div></div>;
|
|
36
|
-
if (
|
|
60
|
+
if (image) return <section className="hero-section hero-section-image"><ImageComponent image={image} fallbackAlt={title} className="hero-background-image" priority={priority} sizes="100vw" fallbackWidth={1600} fallbackHeight={700} /><div className="hero-background-overlay" aria-hidden="true" /><div className="store-container hero-image-content">{copy}</div></section>;
|
|
37
61
|
return <section className="hero-section"><div className="store-container hero-grid">{copy}<div className="hero-art" aria-hidden="true"><div className="hero-orbit hero-orbit-one" /><div className="hero-orbit hero-orbit-two" /><div className="hero-seven">7</div><span className="hero-card hero-card-top">Seleção especial</span><span className="hero-card hero-card-bottom">Atendimento humano</span></div></div></section>;
|
|
38
62
|
}
|
|
39
63
|
|
|
40
|
-
function EditorialGrid({ items, basePath }: { items: ThemeEditorialItem[]; basePath: string }) {
|
|
64
|
+
function EditorialGrid({ items, basePath, ImageComponent = ThemeImageView }: { items: ThemeEditorialItem[]; basePath: string; ImageComponent?: ThemeImageComponent }) {
|
|
41
65
|
if (!items.length) return <div className="empty-state"><span>7</span><h2>Nenhum conteúdo publicado</h2><p>As publicações aparecerão aqui quando estiverem disponíveis.</p></div>;
|
|
42
|
-
return <div className="editorial-grid">{items.map((item) => <article className="editorial-card" key={item.slug}><a className="editorial-card-image" href={`${basePath}/${item.slug}`}><
|
|
66
|
+
return <div className="editorial-grid">{items.map((item) => <article className="editorial-card" key={item.slug}><a className="editorial-card-image" href={`${basePath}/${item.slug}`}><ImageComponent image={item.image || item.thumbnail || item.coverImage} fallbackAlt={item.title} sizes="(max-width: 720px) 92vw, 33vw" fallbackWidth={720} fallbackHeight={480} /></a><div className="editorial-card-content">{(item.category?.title || item.category?.name) && <span>{item.category.title || item.category.name}</span>}<h2><a href={`${basePath}/${item.slug}`}>{item.title}</a></h2><p>{item.description}</p><a className="text-link" href={`${basePath}/${item.slug}`}>Saiba mais <span>→</span></a></div></article>)}</div>;
|
|
43
67
|
}
|
|
44
68
|
|
|
45
|
-
function TextSection({ section }: { section: ThemeHomeSection }) {
|
|
69
|
+
function TextSection({ section, ImageComponent = ThemeImageView }: { section: ThemeHomeSection; ImageComponent?: ThemeImageComponent }) {
|
|
46
70
|
const title = text(section.data, "title", "Conteúdo");
|
|
47
71
|
const description = text(section.data, "description", text(section.data, "text"));
|
|
48
|
-
const
|
|
49
|
-
if (section.type === "image-text") return <section className="store-section image-text-section"><div className="store-container image-text-layout" data-position={section.data.imagePosition === "right" ? "right" : "left"}>{
|
|
72
|
+
const image = sectionImage(section.data, title);
|
|
73
|
+
if (section.type === "image-text") return <section className="store-section image-text-section"><div className="store-container image-text-layout" data-position={section.data.imagePosition === "right" ? "right" : "left"}>{image && <div className="image-text-media"><ImageComponent image={image} fallbackAlt={title} sizes="(max-width: 900px) 100vw, 50vw" fallbackWidth={800} fallbackHeight={600} /></div>}<div className="image-text-copy">{text(section.data, "eyebrow") && <span>{text(section.data, "eyebrow")}</span>}<h2>{title}</h2>{description && <p>{description}</p>}</div></div></section>;
|
|
50
74
|
return <section className="store-section editorial-section"><div className="store-container editorial-content">{text(section.data, "eyebrow") && <span>{text(section.data, "eyebrow")}</span>}<h2>{title}</h2>{description && <p>{description}</p>}{section.type === "cta" && text(section.data, "buttonLabel") && text(section.data, "buttonUrl") && <a className="button button-primary" href={text(section.data, "buttonUrl")}>{text(section.data, "buttonLabel")}</a>}</div></section>;
|
|
51
75
|
}
|
|
52
76
|
|
|
53
|
-
export function Home({ sections, products, posts, services, cases, site, template }: HomeProps) {
|
|
77
|
+
export function Home({ sections, products, posts, services, cases, site, template, ImageComponent = ThemeImageView }: HomeProps & { ImageComponent?: ThemeImageComponent }) {
|
|
54
78
|
const visible = [...sections].filter((section) => section.enabled).sort((a, b) => a.order - b.order);
|
|
55
79
|
const rendered = visible.length ? visible : template.fallbackSections(site.modules);
|
|
56
80
|
const catalog = site.settings?.catalog ?? { showCategory: true, showDescription: true };
|
|
57
81
|
return <>{rendered.map((section, index) => {
|
|
58
|
-
if (section.type === "hero") return <Hero key={section.id || index} section={section} site={site} action={template.primaryAction(site.modules)} />;
|
|
59
|
-
if (section.type === "banner-carousel") return <BannerCarousel key={section.id || index} banners={banners(section.data)} autoplay={section.data.autoplay !== false} />;
|
|
60
|
-
if (["image-text", "rich-text", "cta"].includes(section.type)) return <TextSection key={section.id || index} section={section} />;
|
|
82
|
+
if (section.type === "hero") return <Hero key={section.id || index} section={section} site={site} action={template.primaryAction(site.modules)} priority={index === 0} ImageComponent={ImageComponent} />;
|
|
83
|
+
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} />;
|
|
84
|
+
if (["image-text", "rich-text", "cta"].includes(section.type)) return <TextSection key={section.id || index} section={section} ImageComponent={ImageComponent} />;
|
|
61
85
|
if (section.type === "products-grid" || section.type === "products-carousel") {
|
|
62
86
|
const category = text(section.data, "categorySlug");
|
|
63
87
|
const items = products.filter((product) => !category || product.categories.some(({ slug }) => slug === category)).slice(0, limit(section.data));
|
|
64
|
-
return <section className="store-section" key={section.id || index}><div className="store-container"><Heading data={section.data} title={section.type === "products-grid" ? "Produtos em destaque" : "Vitrine de produtos"} href="/produtos" /><ProductCarousel products={items} showCategory={catalog.showCategory} showDescription={catalog.showDescription} /></div></section>;
|
|
88
|
+
return <section className="store-section" key={section.id || index}><div className="store-container"><Heading data={section.data} title={section.type === "products-grid" ? "Produtos em destaque" : "Vitrine de produtos"} href="/produtos" /><ProductCarousel products={items} showCategory={catalog.showCategory} showDescription={catalog.showDescription} ImageComponent={ImageComponent} /></div></section>;
|
|
65
89
|
}
|
|
66
90
|
const map = section.type === "services-grid" ? { items: services, path: "/servicos", title: "Nossos serviços" } : section.type === "cases-grid" ? { items: cases, path: "/cases", title: "Cases e resultados" } : { items: posts, path: "/blog", title: "Conteúdos recentes" };
|
|
67
|
-
return <section className="store-section" key={section.id || index}><div className="store-container"><Heading data={section.data} title={map.title} href={map.path} /><EditorialGrid items={map.items.slice(0, limit(section.data))} basePath={map.path} /></div></section>;
|
|
91
|
+
return <section className="store-section" key={section.id || index}><div className="store-container"><Heading data={section.data} title={map.title} href={map.path} /><EditorialGrid items={map.items.slice(0, limit(section.data))} basePath={map.path} ImageComponent={ImageComponent} /></div></section>;
|
|
68
92
|
})}<section className="benefits-section"><div className="store-container benefits-grid">{template.benefits.map((benefit) => <div key={benefit.title}><strong>{benefit.title}</strong><span>{benefit.description}</span></div>)}</div></section></>;
|
|
69
93
|
}
|
|
@@ -3,6 +3,7 @@ export { Theme, createNuvlerDefaultRuntime } from "./theme-component.js";
|
|
|
3
3
|
export type { NuvlerDefaultThemeProps } from "./theme-component.js";
|
|
4
4
|
export { Header } from "./header.js";
|
|
5
5
|
export { Footer } from "./footer.js";
|
|
6
|
+
export type { NuvlerDefaultFooterProps } from "./footer.js";
|
|
6
7
|
export { Home } from "./home.js";
|
|
7
8
|
export { ProductGrid, ProductCard } from "./products.js";
|
|
8
9
|
export { ProductDetail } from "./product-detail.js";
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useRef } from "react";
|
|
4
1
|
import type { ThemeProduct } from "@nuvler/theme-sdk";
|
|
2
|
+
|
|
3
|
+
import { ProductCarouselFrame } from "./carousel-frame.js";
|
|
5
4
|
import { ProductCard } from "./products.js";
|
|
5
|
+
import type { ThemeImageComponent } from "./shared.js";
|
|
6
6
|
|
|
7
|
-
export function ProductCarousel({ products, showCategory, showDescription }: { products: ThemeProduct[]; showCategory: boolean; showDescription: boolean }) {
|
|
8
|
-
const track = useRef<HTMLDivElement>(null);
|
|
7
|
+
export function ProductCarousel({ products, showCategory, showDescription, ImageComponent }: { products: ThemeProduct[]; showCategory: boolean; showDescription: boolean; ImageComponent?: ThemeImageComponent }) {
|
|
9
8
|
if (!products.length) return <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Escolha outra categoria ou publique produtos para esta vitrine.</p></div>;
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
return (
|
|
10
|
+
<ProductCarouselFrame>
|
|
11
|
+
{products.map((product) => (
|
|
12
|
+
<div className="product-carousel-item" key={product.slug}>
|
|
13
|
+
<ProductCard product={product} showCategory={showCategory} showDescription={showDescription} ImageComponent={ImageComponent} />
|
|
14
|
+
</div>
|
|
15
|
+
))}
|
|
16
|
+
</ProductCarouselFrame>
|
|
17
|
+
);
|
|
12
18
|
}
|