@nuvler/cli 0.4.0 → 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.
Files changed (51) hide show
  1. package/README.md +25 -2
  2. package/dist/commands/theme/create.js +2 -2
  3. package/dist/commands/theme/validate.js +21 -0
  4. package/dist/commands/theme/validate.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/migrate/generator.js +49 -8
  7. package/dist/migrate/generator.js.map +1 -1
  8. package/dist/migrate/transformer.js +20 -4
  9. package/dist/migrate/transformer.js.map +1 -1
  10. package/dist/nuvler.js +279 -47
  11. package/dist/nuvler.js.map +1 -1
  12. package/dist/templates/nuvler-atelier/nuvler.theme.json +10 -3
  13. package/dist/templates/nuvler-atelier/package.json +3 -3
  14. package/dist/templates/nuvler-atelier/src/definition.tsx +11 -1
  15. package/dist/templates/nuvler-atelier/src/theme.css +26 -26
  16. package/dist/templates/nuvler-atelier/src/theme.tsx +12 -1
  17. package/dist/templates/nuvler-default/README.md +50 -4
  18. package/dist/templates/nuvler-default/nuvler.theme.json +10 -3
  19. package/dist/templates/nuvler-default/package.json +36 -4
  20. package/dist/templates/nuvler-default/src/banner-carousel.tsx +42 -12
  21. package/dist/templates/nuvler-default/src/carousel-frame.tsx +58 -0
  22. package/dist/templates/nuvler-default/src/definition.ts +9 -48
  23. package/dist/templates/nuvler-default/src/footer.tsx +7 -2
  24. package/dist/templates/nuvler-default/src/header-interactions.tsx +1 -1
  25. package/dist/templates/nuvler-default/src/header.tsx +3 -3
  26. package/dist/templates/nuvler-default/src/home.tsx +41 -17
  27. package/dist/templates/nuvler-default/src/index.ts +1 -0
  28. package/dist/templates/nuvler-default/src/product-carousel.tsx +13 -7
  29. package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +230 -0
  30. package/dist/templates/nuvler-default/src/product-detail.tsx +80 -55
  31. package/dist/templates/nuvler-default/src/products.tsx +6 -5
  32. package/dist/templates/nuvler-default/src/server-shell.tsx +88 -0
  33. package/dist/templates/nuvler-default/src/shared.tsx +25 -9
  34. package/dist/templates/nuvler-default/src/theme-component.tsx +11 -0
  35. package/dist/templates/nuvler-default/src/theme-config.ts +63 -0
  36. package/dist/templates/nuvler-default/src/theme.css +48 -17
  37. package/dist/templates/starter/nuvler.theme.json +9 -2
  38. package/dist/templates/starter/package.json +2 -2
  39. package/dist/templates/starter/src/definition.tsx +8 -1
  40. package/dist/templates/starter/src/theme.css +10 -10
  41. package/dist/templates/starter/src/theme.tsx +11 -0
  42. package/dist/theme/performance.js +126 -0
  43. package/dist/theme/performance.js.map +1 -0
  44. package/package.json +3 -3
  45. package/preview-host/index.html +1 -0
  46. package/preview-host/package.json +1 -1
  47. package/preview-host/public/nuvler-icon.ico +0 -0
  48. package/preview-host/public/nuvler-logo-white.png +0 -0
  49. package/preview-host/src/app/globals.css +28 -0
  50. package/preview-host/src/main.tsx +11 -1
  51. package/preview-host/vendor/theme-runtime/default-theme.tsx +24 -2
@@ -1,7 +1,12 @@
1
1
  import type { FooterProps } from "@nuvler/theme-sdk";
2
+ import type { ReactNode } from "react";
2
3
 
3
- export function Footer({ site, pages, template }: FooterProps) {
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></div></footer>;
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 ? <ThemeImageView image={site.settings.logo} fallbackAlt={name} className="brand-logo" priority /> : <><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></>;
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 imageUrl = text(section.data, "imageUrl");
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 (imageUrl) return <section className="hero-section hero-section-image"><ThemeImageView image={{ url: imageUrl, alt: text(section.data, "imageAlt", title), width: null, height: null }} fallbackAlt={title} className="hero-background-image" priority /><div className="hero-background-overlay" aria-hidden="true" /><div className="store-container hero-image-content">{copy}</div></section>;
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}`}><ThemeImageView image={item.image || item.thumbnail || item.coverImage} fallbackAlt={item.title} /></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>;
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 imageUrl = text(section.data, "imageUrl");
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"}>{imageUrl && <div className="image-text-media"><ThemeImageView image={{ url: imageUrl, alt: title, width: null, height: null }} fallbackAlt={title} /></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>;
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
- const move = (direction: -1 | 1) => track.current?.scrollBy({ left: direction * Math.min(track.current.clientWidth, 900), behavior: "smooth" });
11
- return <div className="product-carousel"><div className="product-carousel-track" ref={track}>{products.map((product) => <div className="product-carousel-item" key={product.slug}><ProductCard product={product} showCategory={showCategory} showDescription={showDescription} /></div>)}</div><button type="button" className="carousel-arrow carousel-arrow-prev" onClick={() => move(-1)} aria-label="Produtos anteriores">‹</button><button type="button" className="carousel-arrow carousel-arrow-next" onClick={() => move(1)} aria-label="Próximos produtos">›</button></div>;
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
  }
@@ -0,0 +1,230 @@
1
+ "use client";
2
+
3
+ import {
4
+ createContext,
5
+ useEffect,
6
+ useContext,
7
+ useMemo,
8
+ useRef,
9
+ useState,
10
+ type PointerEvent,
11
+ type ReactNode,
12
+ } from "react";
13
+ import type { ProductDetailProps, ThemeImage } from "@nuvler/theme-sdk";
14
+
15
+ type AddToCart = NonNullable<ProductDetailProps["onAddToCart"]>;
16
+
17
+ const ThemeInteractionContext = createContext<{ onAddToCart?: AddToCart }>({});
18
+
19
+ export function ThemeInteractionProvider({
20
+ children,
21
+ onAddToCart,
22
+ }: {
23
+ children: ReactNode;
24
+ onAddToCart?: AddToCart;
25
+ }) {
26
+ const value = useMemo(() => ({ onAddToCart }), [onAddToCart]);
27
+ return <ThemeInteractionContext.Provider value={value}>{children}</ThemeInteractionContext.Provider>;
28
+ }
29
+
30
+ interface ProductDetailInteractiveProps extends Omit<ProductDetailProps, "descriptionContent"> {
31
+ information: ReactNode;
32
+ benefits: ReactNode;
33
+ galleryImages: ReactNode;
34
+ galleryThumbnails: ReactNode;
35
+ }
36
+
37
+ export function ProductDetailInteractive({
38
+ product,
39
+ contact,
40
+ productUrl,
41
+ onAddToCart,
42
+ information,
43
+ benefits,
44
+ galleryImages,
45
+ galleryThumbnails,
46
+ }: ProductDetailInteractiveProps) {
47
+ const context = useContext(ThemeInteractionContext);
48
+ const addToCart = onAddToCart ?? context.onAddToCart;
49
+ const initialVariant = product.variants.find((item) => item.active);
50
+ const [selected, setSelected] = useState<Record<string, string>>(() => Object.fromEntries(
51
+ product.variantOptions.map((option) => [
52
+ option.name,
53
+ initialVariant?.values.find(({ name }) => name === option.name)?.value ?? option.values[0] ?? "",
54
+ ]),
55
+ ));
56
+ const [imageUrl, setImageUrl] = useState<string>();
57
+ const galleryRef = useRef<HTMLDivElement>(null);
58
+ const [zoomEnabled, setZoomEnabled] = useState(true);
59
+ const [zoom, setZoom] = useState({
60
+ visible: false,
61
+ x: 50,
62
+ y: 50,
63
+ size: 220,
64
+ backgroundX: 0,
65
+ backgroundY: 0,
66
+ backgroundWidth: 0,
67
+ backgroundHeight: 0,
68
+ });
69
+ const variant = useMemo(() => product.variants.find((item) => (
70
+ item.active && item.values.every(({ name, value }) => selected[name] === value)
71
+ )), [product.variants, selected]);
72
+ const images = useMemo(() => {
73
+ if (variant?.image?.url) return [variant.image];
74
+ const unique = new Map<string, ThemeImage>();
75
+ [product.image, ...(product.images || [])].forEach((image) => {
76
+ if (image?.url) unique.set(image.url, image);
77
+ });
78
+ return [...unique.values()];
79
+ }, [product.image, product.images, variant]);
80
+ const selectedImage = images.find((image) => image.url === imageUrl) || images[0] || product.image;
81
+ const phone = contact?.whatsapp?.replace(/\D/g, "");
82
+ const variantDescription = variant?.values.map(({ name, value }) => `${name}: ${value}`).join(", ") || "";
83
+ const message = `Olá! Gostaria de solicitar um orçamento para ${product.title}${variantDescription ? ` (${variantDescription})` : ""}${variant?.sku ? ` — ref. ${variant.sku}` : ""}.${productUrl ? ` ${productUrl}` : ""}`;
84
+ const whatsapp = phone ? `https://wa.me/${phone}?text=${encodeURIComponent(message)}` : null;
85
+ const hasVariants = product.variantOptions.length > 0;
86
+ const canPurchase = !hasVariants || Boolean(variant);
87
+
88
+ useEffect(() => {
89
+ const gallery = galleryRef.current;
90
+ if (!gallery) return;
91
+ const selectedUrl = selectedImage?.url ?? "";
92
+ const allowedUrls = new Set(images.flatMap((image) => image.url ? [image.url] : []));
93
+
94
+ gallery.querySelectorAll<HTMLElement>("[data-product-main-image]").forEach((node) => {
95
+ node.hidden = node.dataset.productMainImage !== selectedUrl;
96
+ });
97
+ gallery.querySelectorAll<HTMLButtonElement>("[data-product-thumbnail]").forEach((button) => {
98
+ const url = button.dataset.productThumbnail ?? "";
99
+ button.hidden = !allowedUrls.has(url);
100
+ button.classList.toggle("active", url === selectedUrl);
101
+ button.setAttribute("aria-pressed", String(url === selectedUrl));
102
+ });
103
+ }, [images, selectedImage?.url]);
104
+
105
+ function moveZoom(event: PointerEvent<HTMLDivElement>) {
106
+ if (event.pointerType !== "mouse" || !selectedImage?.url || !zoomEnabled || (event.target as Element).closest(".product-zoom-toggle")) {
107
+ setZoom((current) => ({ ...current, visible: false }));
108
+ return;
109
+ }
110
+ const bounds = event.currentTarget.getBoundingClientRect();
111
+ const image = event.currentTarget.querySelector<HTMLImageElement>("[data-product-main-image]:not([hidden]) img");
112
+ const naturalWidth = image?.naturalWidth || selectedImage.width || bounds.width;
113
+ const naturalHeight = image?.naturalHeight || selectedImage.height || bounds.height;
114
+ const imageAspect = naturalWidth / naturalHeight;
115
+ const containerAspect = bounds.width / bounds.height;
116
+ const renderedWidth = imageAspect > containerAspect ? bounds.width : bounds.height * imageAspect;
117
+ const renderedHeight = imageAspect > containerAspect ? bounds.width / imageAspect : bounds.height;
118
+ const left = (bounds.width - renderedWidth) / 2;
119
+ const top = (bounds.height - renderedHeight) / 2;
120
+ const pointerX = Math.max(left, Math.min(left + renderedWidth, event.clientX - bounds.left));
121
+ const pointerY = Math.max(top, Math.min(top + renderedHeight, event.clientY - bounds.top));
122
+ const size = Math.min(280, Math.max(210, bounds.width * 0.42));
123
+ const scale = 2.5;
124
+ const backgroundWidth = renderedWidth * scale;
125
+ const backgroundHeight = renderedHeight * scale;
126
+ setZoom({
127
+ visible: true,
128
+ x: pointerX / bounds.width * 100,
129
+ y: pointerY / bounds.height * 100,
130
+ size,
131
+ backgroundX: size / 2 - (pointerX - left) / renderedWidth * backgroundWidth,
132
+ backgroundY: size / 2 - (pointerY - top) / renderedHeight * backgroundHeight,
133
+ backgroundWidth,
134
+ backgroundHeight,
135
+ });
136
+ }
137
+
138
+ return (
139
+ <div className="product-detail">
140
+ <div className="product-gallery" ref={galleryRef}>
141
+ <div
142
+ className="product-main-image product-image-magnifier"
143
+ data-zoom-enabled={zoomEnabled}
144
+ onPointerEnter={moveZoom}
145
+ onPointerMove={moveZoom}
146
+ onPointerLeave={() => setZoom((current) => ({ ...current, visible: false }))}
147
+ >
148
+ {galleryImages}
149
+ {selectedImage?.url && <button
150
+ className={`product-zoom-toggle${zoomEnabled ? " active" : ""}`}
151
+ type="button"
152
+ aria-pressed={zoomEnabled}
153
+ aria-label={zoomEnabled ? "Desativar lupa" : "Ativar lupa"}
154
+ onClick={() => {
155
+ setZoomEnabled((enabled) => !enabled);
156
+ setZoom((current) => ({ ...current, visible: false }));
157
+ }}
158
+ >
159
+ <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6.5" /><path d="m15.5 15.5 5 5M10.5 7.5v6M7.5 10.5h6" />{!zoomEnabled && <path className="zoom-off-line" d="M3 3l18 18" />}</svg>
160
+ <span>Lupa</span>
161
+ </button>}
162
+ {selectedImage?.url && <span
163
+ className={`product-zoom-lens${zoom.visible ? " visible" : ""}`}
164
+ aria-hidden="true"
165
+ style={{
166
+ left: `${zoom.x}%`,
167
+ top: `${zoom.y}%`,
168
+ width: zoom.size,
169
+ height: zoom.size,
170
+ backgroundImage: `url(${JSON.stringify(selectedImage.url)})`,
171
+ backgroundPosition: `${zoom.backgroundX}px ${zoom.backgroundY}px`,
172
+ backgroundSize: `${zoom.backgroundWidth}px ${zoom.backgroundHeight}px`,
173
+ }}
174
+ />}
175
+ </div>
176
+ <div
177
+ className="product-thumbnails"
178
+ onClick={(event) => {
179
+ const button = (event.target as Element).closest<HTMLButtonElement>("[data-product-thumbnail]");
180
+ if (button?.dataset.productThumbnail) setImageUrl(button.dataset.productThumbnail);
181
+ }}
182
+ >
183
+ {galleryThumbnails}
184
+ </div>
185
+ </div>
186
+ <div className="product-info">
187
+ {information}
188
+ <div className="product-purchase">
189
+ {hasVariants && <div className="variant-selector">
190
+ {product.variantOptions.map((option) => <fieldset key={option.name}>
191
+ <legend>{option.name}: <strong>{selected[option.name]}</strong></legend>
192
+ <div className="variant-values">
193
+ {option.values.map((value) => <button
194
+ key={value}
195
+ type="button"
196
+ className={selected[option.name] === value ? "active" : ""}
197
+ aria-pressed={selected[option.name] === value}
198
+ onClick={() => {
199
+ setSelected((current) => ({ ...current, [option.name]: value }));
200
+ setImageUrl(undefined);
201
+ }}
202
+ >{value}</button>)}
203
+ </div>
204
+ </fieldset>)}
205
+ {variant
206
+ ? <p className="selected-variant"><strong>{variant.name || variantDescription}</strong>{variant.sku && <span>Referência: {variant.sku}</span>}</p>
207
+ : <p className="variant-unavailable">Esta combinação não está disponível.</p>}
208
+ </div>}
209
+ {canPurchase && addToCart && <button
210
+ type="button"
211
+ className="button button-primary button-block"
212
+ onClick={() => addToCart({
213
+ productSlug: product.slug,
214
+ title: product.title,
215
+ sku: variant?.sku || product.sku,
216
+ variantId: variant?.id,
217
+ variantName: variantDescription,
218
+ image: variant?.image || product.image,
219
+ unitPrice: variant ? null : product.promotionalPrice ?? product.price,
220
+ })}
221
+ >Adicionar ao orçamento</button>}
222
+ {canPurchase && whatsapp && <a className={`button ${addToCart ? "button-secondary" : "button-primary"} button-block`} href={whatsapp} target="_blank" rel="noreferrer">Orçar somente este item</a>}
223
+ {canPurchase && !whatsapp && contact?.email && <a className="button button-primary button-block" href={`mailto:${contact.email}?subject=${encodeURIComponent(`Orçamento: ${product.title}`)}&body=${encodeURIComponent(message)}`}>Solicitar orçamento por e-mail</a>}
224
+ {canPurchase && !whatsapp && !contact?.email && contact?.phone && <a className="button button-primary button-block" href={`tel:${contact.phone}`}>Ligar e solicitar orçamento</a>}
225
+ </div>
226
+ {benefits}
227
+ </div>
228
+ </div>
229
+ );
230
+ }
@@ -1,60 +1,85 @@
1
- "use client";
2
-
3
- import { useMemo, useState, type PointerEvent } from "react";
4
1
  import type { ProductDetailProps, ThemeImage } from "@nuvler/theme-sdk";
5
- import { ThemeImageView } from "./shared.js";
6
2
 
7
- export function ProductDetail({ product, contact, productUrl, descriptionContent, onAddToCart }: ProductDetailProps) {
8
- const initialVariant = product.variants.find((item) => item.active);
9
- const [selected, setSelected] = useState<Record<string, string>>(() => Object.fromEntries(
10
- product.variantOptions.map((option) => [
11
- option.name,
12
- initialVariant?.values.find(({ name }) => name === option.name)?.value ?? option.values[0] ?? "",
13
- ]),
14
- ));
15
- const [imageUrl, setImageUrl] = useState<string>();
16
- const [zoomEnabled, setZoomEnabled] = useState(true);
17
- const [zoom, setZoom] = useState({ visible: false, x: 50, y: 50, size: 220, backgroundX: 0, backgroundY: 0, backgroundWidth: 0, backgroundHeight: 0 });
18
- const variant = useMemo(() => product.variants.find((item) => (
19
- item.active && item.values.every(({ name, value }) => selected[name] === value)
20
- )), [product.variants, selected]);
21
- const images = useMemo(() => {
22
- if (variant?.image?.url) return [variant.image];
23
- const unique = new Map<string, ThemeImage>();
24
- [product.image, ...(product.images || [])].forEach((image) => { if (image?.url) unique.set(image.url, image); });
25
- return [...unique.values()];
26
- }, [product.image, product.images, variant]);
27
- const selectedImage = images.find((image) => image.url === imageUrl) || images[0] || product.image;
28
- const phone = contact?.whatsapp?.replace(/\D/g, "");
29
- const variantDescription = variant?.values.map(({ name, value }) => `${name}: ${value}`).join(", ") || "";
30
- const message = `Olá! Gostaria de solicitar um orçamento para ${product.title}${variantDescription ? ` (${variantDescription})` : ""}${variant?.sku ? ` — ref. ${variant.sku}` : ""}.${productUrl ? ` ${productUrl}` : ""}`;
31
- const whatsapp = phone ? `https://wa.me/${phone}?text=${encodeURIComponent(message)}` : null;
32
- const hasVariants = product.variantOptions.length > 0;
33
- const canPurchase = !hasVariants || Boolean(variant);
3
+ import { ProductDetailInteractive } from "./product-detail-interactive.js";
4
+ import { ThemeImageView, type ThemeImageComponent } from "./shared.js";
34
5
 
35
- function moveZoom(event: PointerEvent<HTMLDivElement>) {
36
- if (event.pointerType !== "mouse" || !selectedImage?.url || !zoomEnabled || (event.target as Element).closest(".product-zoom-toggle")) {
37
- setZoom((current) => ({ ...current, visible: false }));
38
- return;
39
- }
40
- const bounds = event.currentTarget.getBoundingClientRect();
41
- const image = event.currentTarget.querySelector("img");
42
- const naturalWidth = image?.naturalWidth || selectedImage.width || bounds.width;
43
- const naturalHeight = image?.naturalHeight || selectedImage.height || bounds.height;
44
- const imageAspect = naturalWidth / naturalHeight;
45
- const containerAspect = bounds.width / bounds.height;
46
- const renderedWidth = imageAspect > containerAspect ? bounds.width : bounds.height * imageAspect;
47
- const renderedHeight = imageAspect > containerAspect ? bounds.width / imageAspect : bounds.height;
48
- const left = (bounds.width - renderedWidth) / 2;
49
- const top = (bounds.height - renderedHeight) / 2;
50
- const pointerX = Math.max(left, Math.min(left + renderedWidth, event.clientX - bounds.left));
51
- const pointerY = Math.max(top, Math.min(top + renderedHeight, event.clientY - bounds.top));
52
- const size = Math.min(280, Math.max(210, bounds.width * 0.42));
53
- const scale = 2.5;
54
- const backgroundWidth = renderedWidth * scale;
55
- const backgroundHeight = renderedHeight * scale;
56
- setZoom({ visible: true, x: pointerX / bounds.width * 100, y: pointerY / bounds.height * 100, size, backgroundX: size / 2 - (pointerX - left) / renderedWidth * backgroundWidth, backgroundY: size / 2 - (pointerY - top) / renderedHeight * backgroundHeight, backgroundWidth, backgroundHeight });
57
- }
6
+ export function ProductDetail({
7
+ product,
8
+ contact,
9
+ productUrl,
10
+ descriptionContent,
11
+ onAddToCart,
12
+ ImageComponent = ThemeImageView,
13
+ }: ProductDetailProps & { ImageComponent?: ThemeImageComponent }) {
14
+ const initialVariant = product.variants.find((variant) => variant.active);
15
+ const uniqueImages = new Map<string, ThemeImage>();
16
+ [
17
+ initialVariant?.image,
18
+ product.image,
19
+ ...(product.images ?? []),
20
+ ...product.variants.map((variant) => variant.image),
21
+ ].forEach((image) => {
22
+ if (image?.url) uniqueImages.set(image.url, image);
23
+ });
24
+ const images = [...uniqueImages.values()];
25
+ const galleryImages = images.length > 0
26
+ ? images.map((image, index) => (
27
+ <span
28
+ data-product-main-image={image.url}
29
+ hidden={index !== 0}
30
+ key={image.url}
31
+ >
32
+ <ImageComponent
33
+ image={image}
34
+ fallbackAlt={initialVariant?.name || product.title}
35
+ priority={index === 0}
36
+ sizes="(max-width: 900px) 100vw, 50vw"
37
+ fallbackWidth={1000}
38
+ fallbackHeight={1000}
39
+ />
40
+ </span>
41
+ ))
42
+ : <span data-product-main-image=""><ImageComponent image={null} fallbackAlt={product.title} /></span>;
43
+ const galleryThumbnails = images.length > 1
44
+ ? images.map((image, index) => (
45
+ <button
46
+ className={index === 0 ? "active" : ""}
47
+ type="button"
48
+ aria-pressed={index === 0}
49
+ aria-label={`Exibir imagem ${index + 1} de ${product.title}`}
50
+ data-product-thumbnail={image.url}
51
+ key={`${image.url}-${index}`}
52
+ >
53
+ <ImageComponent
54
+ image={image}
55
+ fallbackAlt={`${product.title} ${index + 1}`}
56
+ sizes="96px"
57
+ fallbackWidth={192}
58
+ fallbackHeight={192}
59
+ />
60
+ </button>
61
+ ))
62
+ : null;
63
+ const information = <>
64
+ {product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}
65
+ <h1>{product.title}</h1>
66
+ <div className="product-description">{descriptionContent}</div>
67
+ </>;
68
+ const benefits = <div className="purchase-benefits">
69
+ <span><strong>Atendimento direto</strong> Fale com quem entende do produto</span>
70
+ <span><strong>Orçamento personalizado</strong> Condições para a sua necessidade</span>
71
+ </div>;
58
72
 
59
- return <div className="product-detail"><div className="product-gallery"><div className="product-main-image product-image-magnifier" data-zoom-enabled={zoomEnabled} onPointerEnter={moveZoom} onPointerMove={moveZoom} onPointerLeave={() => setZoom((current) => ({ ...current, visible: false }))}><ThemeImageView image={selectedImage} fallbackAlt={variant?.name || product.title} priority />{selectedImage?.url && <button className={`product-zoom-toggle${zoomEnabled ? " active" : ""}`} type="button" aria-pressed={zoomEnabled} aria-label={zoomEnabled ? "Desativar lupa" : "Ativar lupa"} onClick={() => { setZoomEnabled((enabled) => !enabled); setZoom((current) => ({ ...current, visible: false })); }}><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6.5" /><path d="m15.5 15.5 5 5M10.5 7.5v6M7.5 10.5h6" />{!zoomEnabled && <path className="zoom-off-line" d="M3 3l18 18" />}</svg><span>Lupa</span></button>}{selectedImage?.url && <span className={`product-zoom-lens${zoom.visible ? " visible" : ""}`} aria-hidden="true" style={{ left: `${zoom.x}%`, top: `${zoom.y}%`, width: zoom.size, height: zoom.size, backgroundImage: `url(${JSON.stringify(selectedImage.url)})`, backgroundPosition: `${zoom.backgroundX}px ${zoom.backgroundY}px`, backgroundSize: `${zoom.backgroundWidth}px ${zoom.backgroundHeight}px` }} />}</div>{images.length > 1 && <div className="product-thumbnails">{images.map((image, index) => <button className={selectedImage?.url === image.url ? "active" : ""} type="button" aria-pressed={selectedImage?.url === image.url} aria-label={`Exibir imagem ${index + 1} de ${product.title}`} onClick={() => setImageUrl(image.url || undefined)} key={`${image.url}-${index}`}><ThemeImageView image={image} fallbackAlt={`${product.title} ${index + 1}`} /></button>)}</div>}</div><div className="product-info">{product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}<h1>{product.title}</h1><div className="product-description">{descriptionContent}</div><div className="product-purchase">{hasVariants && <div className="variant-selector">{product.variantOptions.map((option) => <fieldset key={option.name}><legend>{option.name}: <strong>{selected[option.name]}</strong></legend><div className="variant-values">{option.values.map((value) => <button key={value} type="button" className={selected[option.name] === value ? "active" : ""} aria-pressed={selected[option.name] === value} onClick={() => { setSelected((current) => ({ ...current, [option.name]: value })); setImageUrl(undefined); }}>{value}</button>)}</div></fieldset>)}{variant ? <p className="selected-variant"><strong>{variant.name || variantDescription}</strong>{variant.sku && <span>Referência: {variant.sku}</span>}</p> : <p className="variant-unavailable">Esta combinação não está disponível.</p>}</div>}{canPurchase && onAddToCart && <button type="button" className="button button-primary button-block" onClick={() => onAddToCart({ productSlug: product.slug, title: product.title, sku: variant?.sku || product.sku, variantId: variant?.id, variantName: variantDescription, image: variant?.image || product.image, unitPrice: variant ? null : product.promotionalPrice ?? product.price })}>Adicionar ao orçamento</button>}{canPurchase && whatsapp && <a className={`button ${onAddToCart ? "button-secondary" : "button-primary"} button-block`} href={whatsapp} target="_blank" rel="noreferrer">Orçar somente este item</a>}{canPurchase && !whatsapp && contact?.email && <a className="button button-primary button-block" href={`mailto:${contact.email}?subject=${encodeURIComponent(`Orçamento: ${product.title}`)}&body=${encodeURIComponent(message)}`}>Solicitar orçamento por e-mail</a>}{canPurchase && !whatsapp && !contact?.email && contact?.phone && <a className="button button-primary button-block" href={`tel:${contact.phone}`}>Ligar e solicitar orçamento</a>}</div><div className="purchase-benefits"><span><strong>Atendimento direto</strong> Fale com quem entende do produto</span><span><strong>Orçamento personalizado</strong> Condições para a sua necessidade</span></div></div></div>;
73
+ return (
74
+ <ProductDetailInteractive
75
+ product={product}
76
+ contact={contact}
77
+ productUrl={productUrl}
78
+ onAddToCart={onAddToCart}
79
+ information={information}
80
+ benefits={benefits}
81
+ galleryImages={galleryImages}
82
+ galleryThumbnails={galleryThumbnails}
83
+ />
84
+ );
60
85
  }