@nuvler/cli 0.5.10 → 0.5.11

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.
@@ -13,13 +13,13 @@
13
13
  "typecheck": "tsc -p tsconfig.json --noEmit"
14
14
  },
15
15
  "dependencies": {
16
- "@nuvler/theme-sdk": "^1.3.3"
16
+ "@nuvler/theme-sdk": "^1.4.3"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": "^19.0.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@nuvler/cli": "^0.5.5",
22
+ "@nuvler/cli": "^0.5.11",
23
23
  "@types/react": "^19.0.0",
24
24
  "react": "^19.0.0",
25
25
  "typescript": "^5.9.0"
@@ -29,12 +29,19 @@ function value(data: Record<string, unknown> | undefined, key: string): string {
29
29
  }
30
30
 
31
31
  function price(product: ThemeProduct): string | null {
32
- const amount = product.promotionalPrice ?? product.price;
32
+ const amount = typeof product.promotionalPrice === "number" && typeof product.price === "number" && product.promotionalPrice < product.price
33
+ ? product.promotionalPrice
34
+ : product.price;
33
35
  return typeof amount === "number"
34
36
  ? new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(amount)
35
37
  : null;
36
38
  }
37
39
 
40
+ function originalPrice(product: ThemeProduct): string | null {
41
+ if (typeof product.price !== "number" || typeof product.promotionalPrice !== "number" || product.promotionalPrice >= product.price) return null;
42
+ return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(product.price);
43
+ }
44
+
38
45
  export function AtelierImage({ image, alt, className }: { image?: ThemeImage | null; alt: string; className?: string }) {
39
46
  if (!image?.url) return <span className={`atelier-image-placeholder ${className ?? ""}`} aria-hidden="true"><b>N</b></span>;
40
47
  return <img src={image.url} alt={image.alt || alt} width={image.width || 1000} height={image.height || 1000} className={className} loading="lazy" />;
@@ -163,7 +170,7 @@ function ProductGrid({ products, columns = 3, showPrices = true, showCategory =
163
170
  {showCategory && <small>{product.categories[0]?.name || product.brand || "Seleção"}</small>}
164
171
  <h3><a href={productUrl(product)}>{product.title}</a></h3>
165
172
  {showDescription && product.description && <p>{plainText(product.description)}</p>}
166
- <div>{showPrices && <span>{price(product) || "Preço sob consulta"}</span>}{!showPrices && product.sku && <span>Ref. {product.sku}</span>}<a href={productUrl(product)} aria-label={`Ver ${product.title}`}>↗</a></div>
173
+ <div>{showPrices && <span className="atelier-product-price">{originalPrice(product) && <s>De: {originalPrice(product)}</s>}<b>{originalPrice(product) ? "por " : ""}{price(product) || "Preço sob consulta"}</b></span>}{!showPrices && product.sku && <span>Ref. {product.sku}</span>}<a href={productUrl(product)} aria-label={`Ver ${product.title}`}>↗</a></div>
167
174
  </div>
168
175
  </article>)}</div>;
169
176
  }
@@ -126,6 +126,9 @@ body { margin: 0; }
126
126
  .atelier-product-copy h3 { min-height: 2.4em; margin: 9px 0; font-family: Georgia, serif; font-size: 22px; font-weight: 500; line-height: 1.15; }
127
127
  .atelier-product-copy > p { display: -webkit-box; min-height: 3.2em; margin: 0 0 18px; overflow: hidden; color: color-mix(in srgb, var(--atelier-text) 62%, transparent); font-size: 12px; line-height: 1.6; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
128
128
  .atelier-product-copy > div { display: flex; min-height: 38px; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--atelier-line); padding-top: 14px; font-size: 11px; font-weight: 800; }
129
+ .atelier-product-price { display: grid; gap: 2px; }
130
+ .atelier-product-price s { color: color-mix(in srgb, var(--atelier-text) 56%, transparent); font-size: 10px; font-weight: 600; text-decoration: line-through; }
131
+ .atelier-product-price b { font-size: 12px; }
129
132
  .atelier-product-copy > div a { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--atelier-primary); color: var(--atelier-primary-text); }
130
133
  .atelier-services { background: var(--atelier-primary); color: var(--atelier-primary-text); padding-block: clamp(72px, 9vw, 130px); }
131
134
  .atelier-services .atelier-kicker { color: var(--atelier-accent); }
@@ -65,7 +65,7 @@ Para compilar, gerar o artefato ou publicar, execute na raiz do tooling:
65
65
 
66
66
  ```bash
67
67
  npm run pack:store
68
- npm publish ./artifacts/nuvler-theme-default-1.1.2.tgz --access public
68
+ npm publish ./artifacts/nuvler-theme-default-1.1.4.tgz --access public
69
69
 
70
70
  node packages/cli/dist/nuvler.js theme build --theme themes/nuvler-default
71
71
  npm run pack:theme -- nuvler-default
@@ -73,7 +73,7 @@ node packages/cli/dist/nuvler.js theme publish --theme themes/nuvler-default --o
73
73
  ```
74
74
 
75
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.1.2.nuvler-theme.tgz`.
76
+ gerado separadamente como `artifacts/nuvler-default-1.1.4.nuvler-theme.tgz`.
77
77
 
78
78
  Exemplo no App Router:
79
79
 
@@ -2,13 +2,11 @@
2
2
  "schemaVersion": 1,
3
3
  "id": "nuvler-default",
4
4
  "name": "Nuvler Default",
5
- "version": "1.1.2",
5
+ "version": "1.1.4",
6
6
  "runtimeVersion": "1",
7
7
  "sdkVersion": "^1.3.3",
8
8
  "entry": "src/theme.tsx",
9
- "styles": [
10
- "src/theme.css"
11
- ],
9
+ "styles": ["src/theme.css"],
12
10
  "presentation": {
13
11
  "description": "Tema oficial completo, indicado para produção e usado como base confiável.",
14
12
  "templateId": "nuvler-default",
@@ -100,6 +98,26 @@
100
98
  "control": "text",
101
99
  "maxLength": 120
102
100
  },
101
+ {
102
+ "key": "layout",
103
+ "label": "Formato",
104
+ "control": "select",
105
+ "defaultValue": "grid",
106
+ "options": [
107
+ { "label": "Grid", "value": "grid" },
108
+ { "label": "Carrossel", "value": "carousel" }
109
+ ],
110
+ "help": "Escolha como as marcas serão exibidas."
111
+ },
112
+ {
113
+ "key": "gridColumns",
114
+ "label": "Imagens por linha",
115
+ "control": "number",
116
+ "defaultValue": 5,
117
+ "min": 1,
118
+ "max": 6,
119
+ "help": "Usado quando o formato for Grid."
120
+ },
103
121
  {
104
122
  "key": "items",
105
123
  "label": "Marcas",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvler/theme-default",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Tema padrão oficial da Nuvler",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -65,7 +65,7 @@
65
65
  "react": "^19.0.0"
66
66
  },
67
67
  "dependencies": {
68
- "@nuvler/theme-sdk": "^1.4.2"
68
+ "@nuvler/theme-sdk": "^1.4.3"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/react": "^19.0.0",
@@ -16,6 +16,10 @@ assert.equal(
16
16
  packageJson.version,
17
17
  "A versão do manifesto deve ser igual à versão do pacote do tema.",
18
18
  );
19
+ assert.ok(
20
+ manifest.presentation?.homeComponents?.some(({ key }) => key === "brands"),
21
+ "O manifesto da release não declara o componente brands.",
22
+ );
19
23
  assert.match(
20
24
  javascript,
21
25
  /mini-banners/,
@@ -27,4 +31,4 @@ assert.match(
27
31
  "O artefato CSS não contém os estilos de mini banners.",
28
32
  );
29
33
 
30
- console.log(`✓ Release ${manifest.id}@${manifest.version} contém suporte a mini banners.`);
34
+ console.log(`✓ Release ${manifest.id}@${manifest.version} contém brands e suporte a mini banners.`);
@@ -3,7 +3,13 @@
3
3
  import { useEffect, useRef, useState, type ReactNode } from "react";
4
4
 
5
5
  function ArrowIcon({ direction }: { direction: "previous" | "next" }) {
6
- return <svg viewBox="0 0 24 24" aria-hidden="true"><path d={direction === "previous" ? "m14.5 5-7 7 7 7" : "m9.5 5 7 7-7 7"} /></svg>;
6
+ return (
7
+ <svg viewBox="0 0 24 24" aria-hidden="true">
8
+ <path
9
+ d={direction === "previous" ? "m14.5 5-7 7 7 7" : "m9.5 5 7 7-7 7"}
10
+ />
11
+ </svg>
12
+ );
7
13
  }
8
14
 
9
15
  export function BannerCarouselFrame({
@@ -19,44 +25,143 @@ export function BannerCarouselFrame({
19
25
  const track = useRef<HTMLDivElement>(null);
20
26
 
21
27
  useEffect(() => {
22
- const slides = track.current?.querySelectorAll<HTMLElement>("[data-banner-slide]");
23
- slides?.forEach((slide, index) => slide.setAttribute("aria-hidden", String(active !== index)));
28
+ const slides = track.current?.querySelectorAll<HTMLElement>(
29
+ "[data-banner-slide]",
30
+ );
31
+ slides?.forEach((slide, index) =>
32
+ slide.setAttribute("aria-hidden", String(active !== index)),
33
+ );
24
34
  }, [active]);
25
35
 
26
36
  useEffect(() => {
27
37
  if (!autoplay || count < 2) return;
28
- const timer = window.setInterval(() => setActive((current) => (current + 1) % count), 6000);
38
+ const timer = window.setInterval(
39
+ () => setActive((current) => (current + 1) % count),
40
+ 6000,
41
+ );
29
42
  return () => window.clearInterval(timer);
30
43
  }, [autoplay, count]);
31
44
 
32
45
  return (
33
- <section className="banner-carousel" aria-roledescription="carrossel" aria-label="Banners da loja">
34
- <div className="banner-track" ref={track} style={{ transform: `translateX(-${active * 100}%)` }}>
46
+ <section
47
+ className="banner-carousel"
48
+ aria-roledescription="carrossel"
49
+ aria-label="Banners da loja"
50
+ >
51
+ <div
52
+ className="banner-track"
53
+ ref={track}
54
+ style={{ transform: `translateX(-${active * 100}%)` }}
55
+ >
35
56
  {children}
36
57
  </div>
37
- {count > 1 && <>
38
- <button className="carousel-arrow carousel-arrow-prev" type="button" aria-label="Banner anterior" onClick={() => setActive((active - 1 + count) % count)}><ArrowIcon direction="previous" /></button>
39
- <button className="carousel-arrow carousel-arrow-next" type="button" aria-label="Próximo banner" onClick={() => setActive((active + 1) % count)}><ArrowIcon direction="next" /></button>
40
- <div className="carousel-dots">
41
- {Array.from({ length: count }, (_, index) => <button key={index} type="button" className={index === active ? "active" : ""} aria-label={`Ir para banner ${index + 1}`} onClick={() => setActive(index)} />)}
42
- </div>
43
- </>}
58
+ {count > 1 && (
59
+ <>
60
+ <button
61
+ className="carousel-arrow carousel-arrow-prev"
62
+ type="button"
63
+ aria-label="Banner anterior"
64
+ onClick={() => setActive((active - 1 + count) % count)}
65
+ >
66
+ <ArrowIcon direction="previous" />
67
+ </button>
68
+ <button
69
+ className="carousel-arrow carousel-arrow-next"
70
+ type="button"
71
+ aria-label="Próximo banner"
72
+ onClick={() => setActive((active + 1) % count)}
73
+ >
74
+ <ArrowIcon direction="next" />
75
+ </button>
76
+ <div className="carousel-dots">
77
+ {Array.from({ length: count }, (_, index) => (
78
+ <button
79
+ key={index}
80
+ type="button"
81
+ className={index === active ? "active" : ""}
82
+ aria-label={`Ir para banner ${index + 1}`}
83
+ onClick={() => setActive(index)}
84
+ />
85
+ ))}
86
+ </div>
87
+ </>
88
+ )}
44
89
  </section>
45
90
  );
46
91
  }
47
92
 
48
93
  export function ProductCarouselFrame({ children }: { children: ReactNode }) {
49
94
  const track = useRef<HTMLDivElement>(null);
50
- const move = (direction: -1 | 1) => track.current?.scrollBy({
51
- left: direction * Math.min(track.current.clientWidth, 900),
52
- behavior: "smooth",
53
- });
95
+ const move = (direction: -1 | 1) =>
96
+ track.current?.scrollBy({
97
+ left: direction * Math.min(track.current.clientWidth, 900),
98
+ behavior: "smooth",
99
+ });
54
100
 
55
101
  return (
56
102
  <div className="product-carousel">
57
- <div className="product-carousel-track" ref={track}>{children}</div>
58
- <button type="button" className="carousel-arrow carousel-arrow-prev" onClick={() => move(-1)} aria-label="Produtos anteriores"><ArrowIcon direction="previous" /></button>
59
- <button type="button" className="carousel-arrow carousel-arrow-next" onClick={() => move(1)} aria-label="Próximos produtos"><ArrowIcon direction="next" /></button>
103
+ <div className="product-carousel-track" ref={track}>
104
+ {children}
105
+ </div>
106
+ <button
107
+ type="button"
108
+ className="carousel-arrow carousel-arrow-prev"
109
+ onClick={() => move(-1)}
110
+ aria-label="Produtos anteriores"
111
+ >
112
+ <ArrowIcon direction="previous" />
113
+ </button>
114
+ <button
115
+ type="button"
116
+ className="carousel-arrow carousel-arrow-next"
117
+ onClick={() => move(1)}
118
+ aria-label="Próximos produtos"
119
+ >
120
+ <ArrowIcon direction="next" />
121
+ </button>
122
+ </div>
123
+ );
124
+ }
125
+
126
+ export function BrandsCarouselFrame({
127
+ children,
128
+ count,
129
+ }: {
130
+ children: ReactNode;
131
+ count: number;
132
+ }) {
133
+ const track = useRef<HTMLDivElement>(null);
134
+ const move = (direction: -1 | 1) =>
135
+ track.current?.scrollBy({
136
+ left: direction * Math.min(track.current.clientWidth, 900),
137
+ behavior: "smooth",
138
+ });
139
+
140
+ return (
141
+ <div className="brands-carousel">
142
+ <div className="brands-carousel-track" ref={track}>
143
+ {children}
144
+ </div>
145
+ {count > 1 && (
146
+ <>
147
+ <button
148
+ type="button"
149
+ className="carousel-arrow carousel-arrow-prev"
150
+ onClick={() => move(-1)}
151
+ aria-label="Marcas anteriores"
152
+ >
153
+ <ArrowIcon direction="previous" />
154
+ </button>
155
+ <button
156
+ type="button"
157
+ className="carousel-arrow carousel-arrow-next"
158
+ onClick={() => move(1)}
159
+ aria-label="Próximas marcas"
160
+ >
161
+ <ArrowIcon direction="next" />
162
+ </button>
163
+ </>
164
+ )}
60
165
  </div>
61
166
  );
62
167
  }