@nuvler/cli 0.5.10 → 0.5.12

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.
@@ -21,6 +21,7 @@ function MiniBanner({ item, ImageComponent }: { item: ThemeMiniBannerItem; Image
21
21
  <ImageComponent image={image} fallbackAlt={item.title || "Mini banner"} sizes="(max-width: 800px) 100vw, 50vw" fallbackWidth={800} fallbackHeight={450} />
22
22
  </span>
23
23
  {item.title && <strong>{item.title}</strong>}
24
+ {item.link && item.linkLabel && <span className="mini-banner-link-label">{item.linkLabel}</span>}
24
25
  </>
25
26
  );
26
27
  return item.link
@@ -85,7 +85,7 @@ export function ProductDetail({
85
85
  const information = <>
86
86
  {product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}
87
87
  <h1>{product.title}</h1>
88
- {showPrices && <div className="product-price-block">{previousPrice && <s>{previousPrice}</s>}{currentPrice ? <strong>{currentPrice}</strong> : <span>Consulte condições com a loja</span>}{discount && <small>{discount}% de desconto</small>}</div>}
88
+ {showPrices && <div className="product-price-block">{previousPrice && <s>De: {previousPrice}</s>}{currentPrice ? <strong>{previousPrice ? "por " : ""}{currentPrice}</strong> : <span>Consulte condições com a loja</span>}{discount && <small>{discount}% de desconto</small>}</div>}
89
89
  {stockLabel && <p className={`product-availability${product.stockQuantity === 0 ? " unavailable" : ""}`}>{stockLabel}</p>}
90
90
  {product.sku && <p className="product-reference">Ref. {product.sku}</p>}
91
91
  <div className="product-description">{descriptionContent}</div>
@@ -1,6 +1,6 @@
1
1
  import { productUrl, type ProductGridProps, type ThemeProduct } from "@nuvler/theme-sdk";
2
2
  import { ProductCardAction } from "./product-detail-interactive.js";
3
- import { displayPrice, plainText, ThemeImageView, type ThemeImageComponent } from "./shared.js";
3
+ import { displayPrice, effectivePrice, plainText, ThemeImageView, type ThemeImageComponent } from "./shared.js";
4
4
 
5
5
  function discountPercent(price: number | null, promotionalPrice: number | null) {
6
6
  if (price === null || promotionalPrice === null || promotionalPrice >= price || price <= 0) return null;
@@ -21,7 +21,7 @@ export function ProductCard({ product, showPrices = true, showCategory = true, s
21
21
  const previousPrice = product.promotionalPrice !== null && product.price !== null && product.promotionalPrice < product.price
22
22
  ? displayPrice({ ...product, promotionalPrice: null })
23
23
  : null;
24
- return <article className="product-card" data-unavailable={unavailable || undefined}><a className="product-card-image" href={href} aria-label={`Ver ${product.title}`}>{showPrices && discount && <span className="product-card-badge">-{discount}%</span>}{unavailable && <span className="product-card-stock">Indisponível</span>}<ImageComponent image={product.image} fallbackAlt={product.title} sizes="(max-width: 720px) 92vw, (max-width: 1100px) 45vw, 25vw" fallbackWidth={720} fallbackHeight={720} /></a><div className="product-card-content">{showCategory && <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>{product.categories[0]?.name || "Sem categoria"}</span>}<h3><a className="product-card-details-link" href={href}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}{showPrices && <div className="product-card-price">{previousPrice && <s>{previousPrice}</s>}{currentPrice ? <strong>{currentPrice}</strong> : <span>Consulte condições</span>}</div>}{product.sku && <small className="product-card-sku">Ref. {product.sku}</small>}<ProductCardAction href={href} hasVariants={product.variantOptions.length > 0} unavailable={unavailable} item={{ productSlug: product.slug, productUrl: href, title: product.title, sku: product.sku, image: product.image, unitPrice: showPrices ? product.promotionalPrice ?? product.price : null }} /></div></article>;
24
+ return <article className="product-card" data-unavailable={unavailable || undefined}><a className="product-card-image" href={href} aria-label={`Ver ${product.title}`}>{showPrices && discount && <span className="product-card-badge">-{discount}%</span>}{unavailable && <span className="product-card-stock">Indisponível</span>}<ImageComponent image={product.image} fallbackAlt={product.title} sizes="(max-width: 720px) 92vw, (max-width: 1100px) 45vw, 25vw" fallbackWidth={720} fallbackHeight={720} /></a><div className="product-card-content">{showCategory && <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>{product.categories[0]?.name || "Sem categoria"}</span>}<h3><a className="product-card-details-link" href={href}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}{showPrices && <div className="product-card-price">{previousPrice && <s>De: {previousPrice}</s>}{currentPrice ? <strong>{previousPrice ? "por " : ""}{currentPrice}</strong> : <span>Consulte condições</span>}</div>}{product.sku && <small className="product-card-sku">Ref. {product.sku}</small>}<ProductCardAction href={href} hasVariants={product.variantOptions.length > 0} unavailable={unavailable} item={{ productSlug: product.slug, productUrl: href, title: product.title, sku: product.sku, image: product.image, unitPrice: showPrices ? effectivePrice(product) : null }} /></div></article>;
25
25
  }
26
26
 
27
27
  export function ProductGrid({ products, columns = 4, showPrices = true, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: ProductGridProps & { ImageComponent?: ThemeImageComponent }) {
@@ -44,8 +44,16 @@ export function plainText(value: string): string {
44
44
  return htmlToPlainText(value);
45
45
  }
46
46
 
47
+ export function effectivePrice(product: ThemeProduct): number | null {
48
+ const promotionalPrice = product.promotionalPrice;
49
+ const price = product.price;
50
+ return typeof promotionalPrice === "number" && typeof price === "number" && promotionalPrice < price
51
+ ? promotionalPrice
52
+ : price;
53
+ }
54
+
47
55
  export function displayPrice(product: ThemeProduct): string | null {
48
- const price = product.promotionalPrice ?? product.price;
56
+ const price = effectivePrice(product);
49
57
  return typeof price === "number"
50
58
  ? new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(price)
51
59
  : null;