@nuvler/cli 0.5.13 → 0.5.15
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 +6 -0
- package/dist/api/theme-context.js +5 -1
- package/dist/api/theme-context.js.map +1 -1
- package/dist/commands/theme/build.js +11 -6
- package/dist/commands/theme/build.js.map +1 -1
- package/dist/commands/theme/validate.js +69 -26
- package/dist/commands/theme/validate.js.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/nuvler.js +147 -39
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/src/definition.tsx +3 -3
- package/dist/templates/nuvler-atelier/src/theme.tsx +34 -1
- package/dist/templates/nuvler-default/README.md +3 -1
- package/dist/templates/nuvler-default/nuvler.theme.json +15 -4
- package/dist/templates/nuvler-default/package.json +2 -2
- package/dist/templates/nuvler-default/src/custom-html-content.tsx +26 -0
- package/dist/templates/nuvler-default/src/footer.tsx +2 -1
- package/dist/templates/nuvler-default/src/home.tsx +5 -0
- package/dist/templates/nuvler-default/src/theme-component.tsx +305 -46
- package/dist/templates/nuvler-default/src/theme.css +1007 -259
- package/dist/templates/nuvler-default/test/editorial-content.test.mjs +47 -0
- package/dist/templates/nuvler-default/test/home-reference.test.mjs +42 -0
- package/dist/templates/starter/src/theme.tsx +20 -2
- package/dist/theme/artifact.js +3 -2
- package/dist/theme/artifact.js.map +1 -1
- package/package.json +3 -3
- package/preview-host/src/main.tsx +14 -0
- package/preview-host/vendor/theme-runtime/default-theme.tsx +1611 -334
|
@@ -154,7 +154,7 @@ function Footer({ site, pages }: FooterProps) {
|
|
|
154
154
|
const contact = site.settings?.contact;
|
|
155
155
|
return <footer className="atelier-footer">
|
|
156
156
|
<div className="atelier-container atelier-footer-grid">
|
|
157
|
-
<div className="atelier-footer-brand"
|
|
157
|
+
<div className="atelier-footer-brand">{(site.settings?.footerLogo ?? site.settings?.logo)?.url ? <AtelierImage image={site.settings?.footerLogo ?? site.settings?.logo} alt={name} /> : <span className="atelier-brand-mark">N</span>}<h2>{name}</h2><p>{site.settings?.description || "Produtos selecionados, informação clara e atendimento próximo."}</p></div>
|
|
158
158
|
<div><small>Explore</small><a href="/produtos">Produtos</a><a href="/blog">Conteúdo</a><a href="/servicos">Serviços</a><a href="/cases">Cases</a></div>
|
|
159
159
|
<div><small>Institucional</small>{pages.slice(0, 5).map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</div>
|
|
160
160
|
<div><small>Atendimento</small>{contact?.whatsapp && <a href={`https://wa.me/${contact.whatsapp.replace(/\D/g, "")}`}>WhatsApp</a>}{contact?.email && <a href={`mailto:${contact.email}`}>{contact.email}</a>}{contact?.phone && <a href={`tel:${contact.phone}`}>{contact.phone}</a>}<p>{contact?.address}</p></div>
|
|
@@ -186,7 +186,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
186
186
|
const editorial = [...posts, ...cases].slice(0, 3);
|
|
187
187
|
const bannerSections = sections.filter((section) => section.enabled && section.type === "banner-carousel");
|
|
188
188
|
return <main>
|
|
189
|
-
<section className="atelier-hero atelier-container">
|
|
189
|
+
<section id={hero?.reference} style={{ scrollMarginTop: "100px" }} className="atelier-hero atelier-container">
|
|
190
190
|
<div className="atelier-hero-copy"><span className="atelier-kicker">Nuvler Atelier · edição 01</span><h1>{heroTitle}</h1><p>{heroDescription}</p><div><a className="atelier-button atelier-button-light" href={heroUrl}>{heroButton}<b>↗</b></a><a className="atelier-text-link" href="/produtos">Ver catálogo completo →</a></div></div>
|
|
191
191
|
<div className="atelier-hero-visual">
|
|
192
192
|
<span className="atelier-orbit" /><span className="atelier-orbit second" />
|
|
@@ -194,7 +194,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
194
194
|
{highlight && <a href={productUrl(highlight)}><small>Destaque da semana</small><strong>{highlight.title}</strong><span>{showPrices ? price(highlight) || "Conheça o produto" : "Conheça o produto"} →</span></a>}
|
|
195
195
|
</div>
|
|
196
196
|
</section>
|
|
197
|
-
{bannerSections.map((section, index) => <AtelierBannerCarousel section={section} key={section.id || index} />)}
|
|
197
|
+
{bannerSections.map((section, index) => section.reference ? <div id={section.reference} style={{ scrollMarginTop: "100px" }} key={section.id || index}><AtelierBannerCarousel section={section} /></div> : <AtelierBannerCarousel section={section} key={section.id || index} />)}
|
|
198
198
|
<section className="atelier-marquee"><div>{template.benefits.concat(template.benefits).map((benefit, index) => <span key={`${benefit.title}-${index}`}><b>✦</b>{benefit.title}<small>{benefit.description}</small></span>)}</div></section>
|
|
199
199
|
<section className="atelier-section atelier-container">
|
|
200
200
|
<header className="atelier-section-heading"><div><span className="atelier-kicker">Seleção essencial</span><h2>Produtos que merecem atenção</h2></div><p>Uma vitrine com mais respiro, imagens protagonistas e as informações certas para decidir.</p><a href="/produtos">Explorar tudo ↗</a></header>
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ThemeCartItem,
|
|
5
5
|
ThemeEditorialItem,
|
|
6
6
|
ThemeRoute,
|
|
7
|
+
ThemePageContent,
|
|
7
8
|
ThemeSite,
|
|
8
9
|
} from "@nuvler/theme-sdk";
|
|
9
10
|
import { AtelierImage, plainText, themeDefinition } from "./definition.js";
|
|
@@ -31,6 +32,38 @@ function catalogHref(route: Extract<ThemeRoute, { type: "catalog" }>, page: numb
|
|
|
31
32
|
return params.size ? `${pathname}?${params}` : pathname;
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
function PageBlocks({ content }: { content: ThemePageContent }) {
|
|
36
|
+
return <div className="atelier-page-content">{content.blocks.map((block, index) => {
|
|
37
|
+
const data = block.data;
|
|
38
|
+
const key = block.id || `${block.type}-${index}`;
|
|
39
|
+
const text = (value: unknown) => typeof value === "string" ? plainText(value) : "";
|
|
40
|
+
if (block.type === "header") return <h2 key={key}>{text(data.text)}</h2>;
|
|
41
|
+
if (block.type === "paragraph") return <p key={key}>{text(data.text)}</p>;
|
|
42
|
+
if (block.type === "delimiter") return <hr key={key} />;
|
|
43
|
+
if (block.type === "quote") return <blockquote key={key}><p>{text(data.text)}</p>{text(data.caption) && <cite>{text(data.caption)}</cite>}</blockquote>;
|
|
44
|
+
if (block.type === "list") {
|
|
45
|
+
const items = Array.isArray(data.items) ? data.items : [];
|
|
46
|
+
const List = data.style === "ordered" ? "ol" : "ul";
|
|
47
|
+
return <List key={key}>{items.map((item, itemIndex) => <li key={itemIndex}>{text(item && typeof item === "object" && "content" in item ? (item as { content: unknown }).content : item)}</li>)}</List>;
|
|
48
|
+
}
|
|
49
|
+
if (block.type === "image") {
|
|
50
|
+
const image = data.file && typeof data.file === "object" ? data.file as Record<string, unknown> : {};
|
|
51
|
+
const url = typeof image.url === "string" ? image.url : "";
|
|
52
|
+
return url ? <figure key={key}><img src={url} alt={text(data.caption)} loading="lazy" />{text(data.caption) && <figcaption>{text(data.caption)}</figcaption>}</figure> : null;
|
|
53
|
+
}
|
|
54
|
+
if (block.type === "imageText") {
|
|
55
|
+
const image = data.image && typeof data.image === "object" ? data.image as Record<string, unknown> : {};
|
|
56
|
+
const url = typeof image.url === "string" ? image.url : "";
|
|
57
|
+
return <section className="atelier-page-image-text" key={key}>{url && <img src={url} alt={text(image.alt)} loading="lazy" />}<div>{text(data.title) && <h2>{text(data.title)}</h2>}{text(data.text) && <p>{text(data.text)}</p>}</div></section>;
|
|
58
|
+
}
|
|
59
|
+
if (block.type === "table") {
|
|
60
|
+
const rows = Array.isArray(data.content) ? data.content : [];
|
|
61
|
+
return <div className="atelier-page-table" key={key}><table><tbody>{rows.map((row, rowIndex) => <tr key={rowIndex}>{Array.isArray(row) ? row.map((cell, cellIndex) => <td key={cellIndex}>{text(cell)}</td>) : null}</tr>)}</tbody></table></div>;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
})}</div>;
|
|
65
|
+
}
|
|
66
|
+
|
|
34
67
|
function EditorialList({ title, basePath, items }: { title: string; basePath: string; items: ThemeEditorialItem[] }) {
|
|
35
68
|
return <main className="atelier-page atelier-container">
|
|
36
69
|
<header className="atelier-page-heading"><span className="atelier-kicker">Caderno Nuvler</span><h1>{title}</h1><p>Ideias, referências e histórias selecionadas para ajudar em cada escolha.</p></header>
|
|
@@ -115,7 +148,7 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
|
|
|
115
148
|
} else if (route.type === "editorial-detail") {
|
|
116
149
|
content = <main className="atelier-page atelier-container"><article className="atelier-article"><span className="atelier-kicker">Caderno Nuvler</span><h1>{route.item.title}</h1><AtelierImage image={route.item.image || route.item.thumbnail || route.item.coverImage} alt={route.item.title} /><p>{route.item.description}</p><a href={route.basePath}>← Voltar</a></article></main>;
|
|
117
150
|
} else if (route.type === "page") {
|
|
118
|
-
content = <main className="atelier-page atelier-container"><header className="atelier-page-heading"><span className="atelier-kicker">Institucional</span><h1>{route.title}</h1></header
|
|
151
|
+
content = <main className="atelier-page atelier-container"><header className="atelier-page-heading"><span className="atelier-kicker">Institucional</span><h1>{route.title}</h1></header><PageBlocks content={route.content} /></main>;
|
|
119
152
|
} else {
|
|
120
153
|
content = <main className="atelier-page atelier-container"><header className="atelier-page-heading"><span className="atelier-kicker">{route.type === "loading" ? "Carregando" : "404"}</span><h1>{route.type === "loading" ? "Preparando sua experiência…" : "Essa página não foi encontrada."}</h1><a className="atelier-button atelier-button-dark" href="/">Voltar ao início</a></header></main>;
|
|
121
154
|
}
|
|
@@ -64,7 +64,9 @@ node packages/cli/dist/nuvler.js theme dev \
|
|
|
64
64
|
Para compilar, gerar o artefato ou publicar, execute na raiz do tooling:
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
-
npm run pack:
|
|
67
|
+
npm run pack:cli
|
|
68
|
+
npm run pack:default
|
|
69
|
+
npm publish ./artifacts/nuvler-cli-0.5.13.tgz --access public
|
|
68
70
|
npm publish ./artifacts/nuvler-theme-default-1.1.7.tgz --access public
|
|
69
71
|
|
|
70
72
|
node packages/cli/dist/nuvler.js theme build --theme themes/nuvler-default
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
+
"capabilities": {
|
|
3
|
+
"pageListings": 1
|
|
4
|
+
},
|
|
2
5
|
"schemaVersion": 1,
|
|
3
6
|
"id": "nuvler-default",
|
|
4
7
|
"name": "Nuvler Default",
|
|
5
|
-
"version": "1.1.
|
|
8
|
+
"version": "1.1.14",
|
|
6
9
|
"runtimeVersion": "1",
|
|
7
10
|
"sdkVersion": "^1.3.3",
|
|
8
11
|
"entry": "src/theme.tsx",
|
|
9
|
-
"styles": [
|
|
12
|
+
"styles": [
|
|
13
|
+
"src/theme.css"
|
|
14
|
+
],
|
|
10
15
|
"presentation": {
|
|
11
16
|
"description": "Tema oficial completo, indicado para produção e usado como base confiável.",
|
|
12
17
|
"templateId": "nuvler-default",
|
|
@@ -104,8 +109,14 @@
|
|
|
104
109
|
"control": "select",
|
|
105
110
|
"defaultValue": "grid",
|
|
106
111
|
"options": [
|
|
107
|
-
{
|
|
108
|
-
|
|
112
|
+
{
|
|
113
|
+
"label": "Grid",
|
|
114
|
+
"value": "grid"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"label": "Carrossel",
|
|
118
|
+
"value": "carousel"
|
|
119
|
+
}
|
|
109
120
|
],
|
|
110
121
|
"help": "Escolha como as marcas serão exibidas."
|
|
111
122
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/theme-default",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
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.
|
|
68
|
+
"@nuvler/theme-sdk": "^1.4.5"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/react": "^19.0.0",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
|
|
5
|
+
/** API-sanitized editorial HTML; the shadow root keeps imported CSS inside this block. */
|
|
6
|
+
export function CustomHtmlContent({ html, css = "" }: { html: string; css?: string }) {
|
|
7
|
+
const host = useRef<HTMLDivElement>(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!host.current) return;
|
|
10
|
+
const shadow = host.current.shadowRoot ?? host.current.attachShadow({ mode: "open" });
|
|
11
|
+
const style = document.createElement("style");
|
|
12
|
+
style.textContent = ':host{display:block;contain:layout paint}img{max-width:100%}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.text-justify{text-align:justify}\n' + css;
|
|
13
|
+
const content = document.createElement("div");
|
|
14
|
+
content.innerHTML = html;
|
|
15
|
+
// Defense for older stored documents that predate the current API policy.
|
|
16
|
+
content.querySelectorAll("script,style,iframe,object,embed,link,meta,base,form").forEach(element => element.remove());
|
|
17
|
+
content.querySelectorAll("*").forEach(element => {
|
|
18
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
19
|
+
if (/^on/i.test(attribute.name) || attribute.name === "style"
|
|
20
|
+
|| (["href", "src"].includes(attribute.name) && !/^(?:https?:|mailto:|tel:|\/|#)/i.test(attribute.value.trim()))) element.removeAttribute(attribute.name);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
shadow.replaceChildren(style, content);
|
|
24
|
+
}, [html, css]);
|
|
25
|
+
return <div ref={host} data-editorial-html style={{ display: "block", contain: "layout paint" }} />;
|
|
26
|
+
}
|
|
@@ -10,5 +10,6 @@ export interface NuvlerDefaultFooterProps extends FooterProps {
|
|
|
10
10
|
export function Footer({ site, pages, template, platformBrand, ImageComponent = ThemeImageView }: NuvlerDefaultFooterProps) {
|
|
11
11
|
const settings = site.settings;
|
|
12
12
|
const name = settings?.siteName || site.tenant.name;
|
|
13
|
-
|
|
13
|
+
const logo = settings?.footerLogo ?? settings?.logo;
|
|
14
|
+
return <footer className="store-footer"><div className="store-container footer-grid"><div className="footer-intro"><a className="footer-brand" href="/" aria-label={`${name} — início`}>{logo?.url ? <ImageComponent image={logo} fallbackAlt={name} className="footer-logo" sizes="200px" fallbackWidth={240} fallbackHeight={96} /> : name}</a><p>{settings?.description || template.footerTagline}</p>{settings?.contact.whatsapp && <a className="footer-contact-cta" href={`https://wa.me/${settings.contact.whatsapp.replace(/\D/g, "")}`} target="_blank" rel="noreferrer">Fale pelo WhatsApp <span aria-hidden="true">→</span></a>}</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>;
|
|
14
15
|
}
|
|
@@ -673,6 +673,7 @@ export function Home({
|
|
|
673
673
|
return (
|
|
674
674
|
<>
|
|
675
675
|
{visible.map((section, index) => {
|
|
676
|
+
const content = (() => {
|
|
676
677
|
if (section.type === "hero")
|
|
677
678
|
return (
|
|
678
679
|
<Hero
|
|
@@ -814,6 +815,10 @@ export function Home({
|
|
|
814
815
|
</div>
|
|
815
816
|
</section>
|
|
816
817
|
);
|
|
818
|
+
})();
|
|
819
|
+
return section.reference
|
|
820
|
+
? <div key={section.id || index} id={section.reference} style={{ scrollMarginTop: "100px" }}>{content}</div>
|
|
821
|
+
: content;
|
|
817
822
|
})}
|
|
818
823
|
</>
|
|
819
824
|
);
|