@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
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
ThemeProduct,
|
|
9
9
|
ThemeSiteColors,
|
|
10
10
|
} from "@nuvler/theme-sdk";
|
|
11
|
+
import { htmlToPlainText, productUrl } from "@nuvler/theme-sdk";
|
|
11
12
|
import type { DefaultThemeProps, ThemeRuntimeAdapters } from "./index.js";
|
|
12
13
|
import type { ThemeRoute } from "./index.js";
|
|
13
14
|
|
|
@@ -57,11 +58,7 @@ function dataLimit(data: Record<string, unknown>): number {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
function plainText(value: string): string {
|
|
60
|
-
return value
|
|
61
|
-
.replace(/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi, " ")
|
|
62
|
-
.replace(/<[^>]+>/g, " ")
|
|
63
|
-
.replace(/\s+/g, " ")
|
|
64
|
-
.trim();
|
|
61
|
+
return htmlToPlainText(value);
|
|
65
62
|
}
|
|
66
63
|
|
|
67
64
|
function moduleLinks(context: ThemeContext): Array<{ label: string; href: string }> {
|
|
@@ -77,7 +74,7 @@ function moduleLinks(context: ThemeContext): Array<{ label: string; href: string
|
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
function categoryUrl(path: string[]): string {
|
|
80
|
-
return
|
|
77
|
+
return `/${path.map(encodeURIComponent).join("/")}`;
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
function CategoryTree({
|
|
@@ -156,7 +153,7 @@ function SmartSearch({ adapters }: { adapters: ThemeRuntimeAdapters }) {
|
|
|
156
153
|
</form>
|
|
157
154
|
{open && value.trim().length >= 2 && <div className="search-suggestions">
|
|
158
155
|
<div className="search-suggestions-heading"><strong>{loading ? "Buscando..." : "Produtos encontrados"}</strong>{!loading && <span>{results.length} de 5</span>}</div>
|
|
159
|
-
{!loading && results.map((product) => <Link href={
|
|
156
|
+
{!loading && results.map((product) => <Link href={productUrl(product)} key={product.slug}>
|
|
160
157
|
<span className="search-suggestion-image"><Image image={product.image} fallbackAlt={product.title} /></span>
|
|
161
158
|
<span className="search-suggestion-copy"><strong>{product.title}</strong><small>{product.sku ? `Ref. ${product.sku}` : product.categories[0]?.name || "Produto"}</small></span>
|
|
162
159
|
{displayPrice(product) && <b>{displayPrice(product)}</b>}
|
|
@@ -265,9 +262,10 @@ function ProductCard({ product, context, adapters }: {
|
|
|
265
262
|
}) {
|
|
266
263
|
const { Link, Image } = adapters;
|
|
267
264
|
const catalog = context.site.settings?.catalog ?? fallbackCatalog;
|
|
265
|
+
const href = productUrl(product);
|
|
268
266
|
return (
|
|
269
267
|
<article className="product-card">
|
|
270
|
-
<Link className="product-card-image" href={
|
|
268
|
+
<Link className="product-card-image" href={href}>
|
|
271
269
|
<Image image={product.image} fallbackAlt={product.title} />
|
|
272
270
|
</Link>
|
|
273
271
|
<div className="product-card-content">
|
|
@@ -276,11 +274,11 @@ function ProductCard({ product, context, adapters }: {
|
|
|
276
274
|
{product.categories[0]?.name || "Sem categoria"}
|
|
277
275
|
</span>
|
|
278
276
|
)}
|
|
279
|
-
<h3><Link href={
|
|
277
|
+
<h3><Link href={href}>{product.title}</Link></h3>
|
|
280
278
|
{catalog.showDescription && product.description && (
|
|
281
279
|
<p className="product-card-description">{plainText(product.description)}</p>
|
|
282
280
|
)}
|
|
283
|
-
<Link className="button button-secondary button-block" href={
|
|
281
|
+
<Link className="button button-secondary button-block" href={href}>
|
|
284
282
|
Ver detalhes e orçar
|
|
285
283
|
</Link>
|
|
286
284
|
</div>
|
|
@@ -374,11 +372,14 @@ function TextSection({ section, adapters }: ThemeSectionRendererProps) {
|
|
|
374
372
|
function ProductsSection({ section, context, adapters }: ThemeSectionRendererProps) {
|
|
375
373
|
const categorySlug = dataString(section.data, "categorySlug");
|
|
376
374
|
const products = context.catalog.products
|
|
377
|
-
.filter((product) => !categorySlug || product.categories.some((category) => category.slug === categorySlug))
|
|
375
|
+
.filter((product) => !categorySlug || product.categories.some((category) => category.slug === categorySlug) || product.categoryPath?.includes(categorySlug))
|
|
378
376
|
.slice(0, dataLimit(section.data));
|
|
379
377
|
return <section className="store-section"><div className="store-container">
|
|
380
378
|
<div className="section-heading"><div><span>{dataString(section.data, "eyebrow", "Em destaque")}</span><h2>{dataString(section.data, "title", section.type === "products-grid" ? "Produtos em destaque" : "Vitrine de produtos")}</h2></div><adapters.Link href="/produtos">Ver todos</adapters.Link></div>
|
|
381
|
-
{products.length ?
|
|
379
|
+
{products.length ? section.type === "products-grid"
|
|
380
|
+
? <div className="product-grid" data-columns={context.site.settings?.catalog?.desktopColumns || 3}>{products.map((product) => <ProductCard adapters={adapters} context={context} product={product} key={product.slug} />)}</div>
|
|
381
|
+
: <div className="product-carousel"><div className="product-carousel-track">{products.map((product) => <div className="product-carousel-item" key={product.slug}><ProductCard adapters={adapters} context={context} product={product} /></div>)}</div></div>
|
|
382
|
+
: <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Escolha outra categoria ou publique produtos para esta vitrine.</p></div>}
|
|
382
383
|
</div></section>;
|
|
383
384
|
}
|
|
384
385
|
|