diff --git a/CHANGELOG.md b/CHANGELOG.md index 69080d8..366acf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,35 @@ # Changelog +## 0.12.0 — 2026-09-30 + +Import & Modernize, and 90 layouts. See the [release notes](docs/RELEASE-0.12.0.md). + +- **Modernize tab.** Paste or import any Bricks JSON and BricksSnap rebuilds it on its design system. See [Modernize](docs/MODERNIZE.md). + - Colors become tokens by role, and the source's brand colors are replaced by the kit's. + - Font sizes, spacing and corners land on the kit's fluid scale. + - Repeated inline styles become `bs--` classes. + - Missing mobile rules are added. + - The brand kit restyles the result. + - Compare before and after at three widths, read the report, then download, copy or open it in Staging. It runs locally. +- **MCP.** New tool `bricks_modernize_template` (eleven tools). +- **50 new layouts (90 in total)** for every section type, among them: + - bento hero, hero with form, hero with numbers; + - photo service cards and service tabs; + - vertical steps; + - pricing switch, plans as rows, price tiles; + - quote wall; + - team photo cards; + - portfolio bento and project index; + - FAQ accordion; + - logo tiles and marquee; + - masonry and bento gallery; + - CTA with background image; + - big-name footer; + - split login, 404 and coming-soon pages. +- **Native tabs and accordion.** The pricing switch and service tabs use Bricks' nested tabs, and the FAQ accordion uses Bricks' nested accordion with FAQ schema. The preview shows them as Bricks does (first tab open), and the validator accepts their `_hidden` classes. +- **Remote library.** 206 templates: 13 designs as pages and all 90 layouts as sections, in German and English. +- **Roadmap.** "Open in BricksSnap" cooperation with template libraries and a community gallery with an explicit open license are planned for later. + ## 0.11.1 — 2026-09-30 - **Pointer cursor.** Everything clickable (buttons, tabs, filter chips, cards, selects, checkboxes, expandable sections) shows the hand cursor again. Tailwind CSS v4 gives buttons the default arrow; disabled controls now show "not allowed". Suggested on the Bricks forum. diff --git a/README.md b/README.md index ac54e0a..d4bf0fb 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ A Next.js tool that creates editable **Bricks Builder JSON templates**. Build mo Free for your own and your clients' websites. You may not offer BricksSnap itself to others as a hosted app or sell it; see [licensing](LICENSING.md). +**v0.12: [Import & Modernize](docs/MODERNIZE.md) and 90 layouts** ([release notes](docs/RELEASE-0.12.0.md)). Paste any Bricks JSON and get it back on your design system: tokens instead of fixed colors, fluid sizes, clean `bs-` classes and mobile rules, restyled by your brand kit. The Studio grows from 40 to 90 layouts, including bento grids, a pricing switch and a FAQ accordion built on Bricks' native tabs and accordion. + **v0.9: Library of ready-made designs.** 12 complete designs for different industries and styles, as pages and sections, in the app and in Bricks' remote library ([release notes](docs/RELEASE-0.9.0.md)). **v0.8: [Studio](docs/STUDIO.md)** ([release notes](docs/RELEASE-0.8.0.md)). Pick from 40 layouts in five style directions, set your brand color, fonts, corners and spacing, and get copy written for your industry in German or English. Export native Bricks JSON whose global classes follow one design system, and install that system's palette and variables on a connected site. @@ -27,7 +29,8 @@ v0.5 builds on v0.4's [read-only connection](docs/RELEASE-0.4.0.md) and v0.3's [ ## Features -- Studio: 40 layouts in 22 section types and five style directions, a brand kit (color, fonts, corners, spacing, light/dark), industry copy in German or English, live preview at three widths, quality checks +- Studio: 90 layouts in 22 section types and five style directions, a brand kit (color, fonts, corners, spacing, light/dark), industry copy in German or English, live preview at three widths, quality checks +- Modernize: any Bricks JSON rebuilt on the design system (tokens, fluid scale, `bs-` classes, mobile rules), locally in the browser - Design system: `bs-` global classes with `var(--bs-*, fallback)` values; palette and variables installable on a connected site with ownership guards - Pre-built template library (Hero, Navbar, Features, Pricing, Testimonials, Footer and more) - Full page presets @@ -38,7 +41,7 @@ v0.5 builds on v0.4's [read-only connection](docs/RELEASE-0.4.0.md) and v0.3's [ - Bricks 2.4.1 native element/control registry, reference repair and responsive defaults - Export types and preservation of global classes/component metadata - Staging workspace: prepend/append sections or insert after a root, with ID collision handling and structural comparison -- Ten MCP tools over optional HTTP or local stdio; Studio pages, section generation, page assembly, merge and comparison +- Eleven MCP tools over optional HTTP or local stdio; Studio pages, modernizing Bricks JSON, section generation, page assembly, merge and comparison - Local WordPress connection: page search, live page import with Bricks' document digest, site class and palette import, class conflict warnings - Bricks-rendered before/after preview (1280/390 px), guarded apply with read-back verification and revision restore - Import of external images into the site's media library and guarded creation of missing global classes before applying diff --git a/docs/CLIENTS.md b/docs/CLIENTS.md index 2febc51..f1332c8 100644 --- a/docs/CLIENTS.md +++ b/docs/CLIENTS.md @@ -52,7 +52,7 @@ Other clients use the same command and environment in their JSON format. ## Tool discovery - **Bricks tools.** The site exposes a few Bricks abilities as direct tools, for example `bricks-get-design-context`. Others are called through `mcp-adapter-execute-ability` with `{ "ability_name": "bricks/…", "parameters": {…} }`. Use `mcp-adapter-get-ability-info` for exact parameters: Bricks rejects unknown keys. -- **BricksSnap tools.** BricksSnap's ten tools start with `bricks_` (underscores), for example `bricks_kit_page` or `bricks_merge_templates`. +- **BricksSnap tools.** BricksSnap's eleven tools start with `bricks_` (underscores), for example `bricks_kit_page` or `bricks_merge_templates`. ## Workflows that combine both diff --git a/docs/MODERNIZE.md b/docs/MODERNIZE.md new file mode 100644 index 0000000..740b2d5 --- /dev/null +++ b/docs/MODERNIZE.md @@ -0,0 +1,78 @@ +# Import & Modernize: bring any section onto your design system + +The **Modernize** tab takes Bricks JSON you already have and rebuilds it on BricksSnap's design system. Sources include a section copied from a client site, an old project or a template you own. Afterwards the brand kit restyles it like any Studio layout: color, fonts, corners, spacing and dark mode. + +It runs in your browser. Nothing is uploaded and nothing is fetched from other sites: you bring the JSON. + +## What it changes + +| Before | After | +|---|---| +| Fixed colors (`#7c3aed`, `rgba(…)`) | Design tokens by role: section and card backgrounds, headings, text, muted text, borders, buttons, icons, shadows. Alpha stays as `color-mix(in srgb, var(--bs-…) N%, transparent)`. | +| Font sizes in px or rem | The kit's type scale (`--bs-text-s` … `--bs-text-display`), fluid with `clamp()` | +| Spacing and corners | The kit's spacing and radius tokens (`--bs-space-*`, `--bs-radius-*`, `--bs-radius-btn`), sections on `--bs-space-section` and `--bs-gutter` | +| The same inline styles on many elements | One global class per role, `bs--`, shared by every element that looked the same | +| Source classes (for example `feature-card`) | Merged into the new classes; the element keeps its own overrides | +| Font families | The kit's heading and body fonts | +| Framework variables (Automatic CSS, Core Framework) | Mapped by name to BricksSnap tokens where the meaning is clear; unknown ones are kept and listed | +| Custom CSS with `%root%`, `#brxe-…` or old class names | Rewritten to the new class; colors and sizes inside mapped like the controls | + +**Brand colors.** Modernize detects the source's brand colors: saturated mid-tone colors, weighted by how often they are used. They become `primary` and `accent`, so your kit's brand color replaces them everywhere. Tints and near-whites are not mistaken for the brand. + +**Buttons.** Bricks button presets (style, size, outline) become explicit, token-based buttons: the primary fill with readable text, outlines with the kit's border color, and the kit's button radius. + +## Mobile rules it adds + +Many library sections were built for desktop only. Modernize adds what is missing and lists each rule in the report: + +- **Sections:** vertical rhythm from `--bs-space-section` and side gutters when they have none. +- **Containers:** full width up to the kit's container width. +- **Grids:** with three or more columns, two columns on tablets; one column on phones. +- **Button rows:** wrap, and stack at full width on phones. +- **Rows of cards or blocks:** stack on phones. +- **Stacks without gaps:** spacing from the kit. +- **Fixed widths over 480 px:** become a maximum width, so they shrink on small screens. + +## How to use it + +1. **Paste Bricks JSON** or **Import JSON file** (up to 2 MB). Bricks' clipboard format, template exports and plain element arrays work. **Load example** shows a feature section written the way many libraries ship them. +2. Optionally set the **class prefix**, for example `features` for `bs-features-card`. By default it comes from the section's label or first heading. +3. Set the brand kit on the left. It starts with your Studio kit. +4. Compare **After**, **Before** or **Side by side** at desktop, tablet and phone width. +5. Read **What changed**: + - colors and the token each became; + - font sizes; + - spacing and radii; + - created classes; + - mobile rules; + - warnings; + - quality checks. +6. **Take it to Bricks:** download the import file, copy it for Ctrl+V, or **Open in Staging** to compare it against a page on your site, save it there and install the design system. + +## Limits + +- **Images** keep their source URLs. Replace them or import them into the media library (Staging → Before saving). +- **Framework utility classes without styles in the file** (for example Automatic CSS utilities) are listed. Their look is not in the JSON, so it cannot be carried over. +- **Unknown variables** stay as they are. Define them on the site or replace them. +- **Interactions, queries and dynamic data** are kept, not modernized. +- Always review the result in Bricks before publishing. + +## Only import what you may use + +Modernize changes the design, not the rights. Use it on JSON you created, received from a client, or licensed. Do not use it to repackage other people's templates. Free libraries such as BricksBoard or DigiSavvy's templates have their own terms. + +## From MCP clients + +**`bricks_modernize_template`** takes: + +- `json`: the Bricks JSON as a string, up to 2 MB; +- optionally `kit`, `block` (the class prefix) and `title`. + +It returns: + +- the modernized template; +- the design system; +- the report; +- the quality checks. + +For example: "Modernize this Bricks section with BricksSnap in the Soft style with my brand color #0f766e and give me the JSON." diff --git a/docs/RELEASE-0.12.0.md b/docs/RELEASE-0.12.0.md new file mode 100644 index 0000000..3a09ce1 --- /dev/null +++ b/docs/RELEASE-0.12.0.md @@ -0,0 +1,78 @@ +# BricksSnap 0.12.0: Import & Modernize, and 90 layouts + +Many Bricks users already have sections: from old projects, from clients, from free libraries. They often use fixed colors, px sizes, repeated inline styles and no mobile rules. 0.12.0 brings them onto the same design system as the Studio, and more than doubles the Studio's own layouts. + +## 1. Import & Modernize + +A new **Modernize** tab takes any Bricks JSON and rebuilds it on BricksSnap's tokens: + +- **Colors:** fixed colors become design tokens by role (backgrounds, headings, text, borders, buttons, icons, shadows). The source's brand colors are detected and replaced by your kit's. +- **Sizes:** font sizes, spacing and corners land on the kit's scale, fluid with `clamp()` instead of fixed px. +- **Classes:** repeated inline styles become one clean `bs--` global class per role. +- **Mobile:** missing rules are added, and the report lists each one: + - grids collapse on tablets and phones; + - button rows stack at full width; + - sections get rhythm and gutters; + - fixed widths become maxima. +- **Brand kit:** the result follows color, fonts, corners, spacing and dark mode like any Studio section. + +You compare before and after at three widths, read a report of every change, and take the result to Bricks by download, clipboard or Staging. + +It runs locally in the browser, and nothing is fetched: you bring the JSON. Use it on sections you made, received from a client or licensed. It is not a way to repackage other people's templates. See [Modernize](MODERNIZE.md). + +**MCP.** The new `bricks_modernize_template` tool does the same for Claude, ChatGPT and other clients. The server now has eleven tools. + +## 2. 90 layouts instead of 40 + +50 new layouts cover every section type. They reuse the kit's classes, so every layout works with every brand kit, industry and language: + +| Section | New layouts | +|---|---| +| Header | centred logo, floating bar, dark | +| Hero | bento tiles, centred with numbers, statement with wide image, image left with social proof, with enquiry form | +| Services | numbered, photo cards, tabs | +| Benefits | cards with icons, image in the middle, dark with rules | +| Steps | vertical with line, centred numbers | +| Numbers | cards, image with numbers | +| Pricing | with switch, plans as rows, price tiles | +| Reviews | quote wall, one featured quote, large photo | +| Team | photo cards, list | +| Portfolio | bento, project index | +| Timeline | horizontal | +| About | with numbers, photo collage, statement with wide image | +| FAQ | accordion, cards | +| Blog | one featured post, list | +| Logos | tiles, marquee | +| Gallery | masonry, bento | +| Call to action | background image, minimal with rules, card with photo | +| Contact | contact cards, centred form | +| Footer | big name, with call to action | +| Login, 404, coming soon | split screens with image | + +**Native Bricks tabs and accordion.** The pricing switch and the service tabs use Bricks' nested tabs; the FAQ accordion uses Bricks' nested accordion with FAQ schema. Bricks' own script switches them, and you edit each tab and answer in the builder. + +**Pricing switch.** The industries' sample prices are one-off, hourly or per-visit prices, so the switch shows **Packages / Single prices**. A computed "yearly" price would be wrong. For monthly and yearly billing, rename the two tabs in Bricks and enter your yearly prices in the second pane. + +The remote library in Bricks now serves 206 templates: 13 designs as pages and all 90 layouts as sections, in German and English. + +## Later + +Cooperation instead of copying: +- an "Open in BricksSnap" link for template libraries that want it; +- a community gallery with an explicit open license. + +These are on the [roadmap](ROADMAP.md) and not part of this release. + +## Verified + +- **Automated:** 255 tests. + - Every layout validates in every style. + - The one-class-per-CSS-property rule holds for all 90 layouts. + - No class name is defined twice. + - Tabs and accordion have Bricks' structure. + - The modernize engine is tested on its own pricing and hero fixtures. +- **Visual:** all 50 new layouts at desktop and phone width in the Clean kit, and in a dark Warm kit. +- **Against Bricks 2.4.2 on the test site (read-only):** + - Bricks' frontend script and styles use the same tab, pane, accordion and `brx-open` classes as the layouts. + - `render-elements` outputs the `_hidden` classes the nested elements rely on. +- **App:** the Studio renders all 90 thumbnails in about 0.1 s, and a kit change redraws them in about 0.15 s. diff --git a/docs/REMOTE-LIBRARY.md b/docs/REMOTE-LIBRARY.md index 1c3dcb8..9fc071c 100644 --- a/docs/REMOTE-LIBRARY.md +++ b/docs/REMOTE-LIBRARY.md @@ -2,10 +2,10 @@ A BricksSnap deployment can act as a **Remote Library** source in Bricks. Bricks users browse the design library in the builder and insert pages and sections like templates from any other Bricks site. No JSON download is needed. -Since 0.9.0 the library serves the Studio's designs instead of the older classic catalog, in German and English (106 templates): +Since 0.9.0 the library serves the Studio's designs instead of the older classic catalog, in German and English (206 templates since 0.12.0): - **Pages.** Each of the 13 designs (for example "Nord", "Trattoria", "Lachfalte") as a complete page. -- **Sections.** All 40 layouts as single sections, in the "Fundament" design. +- **Sections.** All 90 layouts as single sections, in the "Fundament" design. Styling travels as `bs-` global classes. Class IDs are the same in every design, so sections inserted later take on the look of the first design the site received. To change the look everywhere, install the design system from the Studio (see [Studio](STUDIO.md)). diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 5cdfb85..5970367 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -68,6 +68,18 @@ Delivered in 0.8.0 (see [release notes](RELEASE-0.8.0.md)): - **App.** Light workbench redesign; Claude through MCP with current models. - **Not included.** Loading the kit's web fonts in Bricks, theme styles, and Studio layouts in the remote library. +## v0.12 — Import & Modernize and more layouts + +Delivered in 0.12.0 (see [release notes](RELEASE-0.12.0.md)): +- **Modernize.** Any Bricks JSON rebuilt on the design system, in the app and as the MCP tool `bricks_modernize_template` ([Modernize](MODERNIZE.md)). +- **Layouts.** 90 instead of 40, with Bricks' nested tabs and accordion where a section switches or folds. +- **Not included.** Importing from template libraries directly. BricksSnap does not fetch or redistribute other people's templates. + +## Later: cooperation instead of copying + +- **"Open in BricksSnap".** Template libraries that want it could link their sections to the Modernize tab, so users bring a section onto their own design system with one click. This needs the library's consent and a small, documented hand-over (for example a URL with the JSON or a postMessage from a library page). +- **Community gallery.** Sections shared by their authors under an explicit open license (for example CC0 or MIT), with author credit, moderation and a license on every entry. Only then may BricksSnap offer others' sections. + ## 2.0 milestone Use the 2.0 name when a connected site can be read, a change reviewed, applied, verified and recovered through a tested workflow. Intermediate releases should deliver useful complete workflows without implying that later phases are already available. diff --git a/docs/SETUP.md b/docs/SETUP.md index 33abab0..4967163 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -42,7 +42,7 @@ Anthropic does not permit third-party apps to offer a Claude.ai sign-in or to ro - **claude.ai and the Claude apps:** Customize → Connectors → + → **Add custom connector** with `https://your-deployment/api/mcp` ([Anthropic help](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp)). Claude connects from Anthropic's cloud, so the deployment must be public HTTPS with `BRICKSSNAP_MCP_ENABLED=true`. - **Inside BricksSnap:** choose Anthropic in Settings with an API key from the Claude Console; the model defaults to `claude-sonnet-5-5` (also `claude-opus-5-5`, `claude-haiku-4-5-20251001`). -The opt-in stateless endpoint provides ten tools: `bricks_get_schema`, `bricks_list_templates`, `bricks_get_template`, `bricks_validate_template`, `bricks_generate_section`, `bricks_assemble_page`, `bricks_kit_options`, `bricks_kit_page`, `bricks_merge_templates` and `bricks_compare_templates`. It cannot access API keys, WordPress or private files, or publish pages. It currently has no authentication because it only provides public computations; apply hosting rate limits. Leave disabled when unused. For local stdio clients and the staging workflow, see [Staging and MCP](STAGING-MCP.md). +The opt-in stateless endpoint provides eleven tools: `bricks_get_schema`, `bricks_list_templates`, `bricks_get_template`, `bricks_validate_template`, `bricks_generate_section`, `bricks_assemble_page`, `bricks_kit_options`, `bricks_kit_page`, `bricks_modernize_template`, `bricks_merge_templates` and `bricks_compare_templates`. It cannot access API keys, WordPress or private files, or publish pages. It currently has no authentication because it only provides public computations; apply hosting rate limits. Leave disabled when unused. For local stdio clients and the staging workflow, see [Staging and MCP](STAGING-MCP.md). ## Export and compatibility diff --git a/docs/STAGING-MCP.md b/docs/STAGING-MCP.md index 62cde8c..ac742a2 100644 --- a/docs/STAGING-MCP.md +++ b/docs/STAGING-MCP.md @@ -63,6 +63,7 @@ HTTP uses the same tools at `/api/mcp`, opt-in as described in [Setup](SETUP.md) | `bricks_assemble_page` | `prompt`, ordered `sections` array (1–12), optional preset/palette IDs; page and warnings. | | `bricks_kit_options` | None; style directions, font pairs, industries and every section type with its layouts. | | `bricks_kit_page` | `sections` (type, optional `variant`, 1–16), optional `kit` and `profile`, `title`; Studio sections or page with global classes, design system and quality checks. See [Studio](STUDIO.md). | +| `bricks_modernize_template` | JSON string `json` (up to 2 MB), optional `kit`, `block` (class prefix) and `title`; the section on BricksSnap's design system with the design system, a report of every change and quality checks. See [Modernize](MODERNIZE.md). | | `bricks_merge_templates` | JSON strings `baseline` and `addition`, `position` (`append`, `prepend`, `after`), `afterId` for `after`; staged template, diff, ID remapping and warnings. | | `bricks_compare_templates` | JSON strings `baseline` and `proposal`; element deltas, counts and metadata keys that differ. | diff --git a/docs/STUDIO.md b/docs/STUDIO.md index 296c187..1a6d9d2 100644 --- a/docs/STUDIO.md +++ b/docs/STUDIO.md @@ -35,7 +35,9 @@ The texts are templates: read and adjust them before publishing. Nothing leaves ## 3. Sections -The **Sections** view shows all 40 layouts in 22 section types, grouped by type and rendered live at 1280 px. The section types are header, hero, services, benefits, steps, numbers, pricing, reviews, team, portfolio, timeline, about, FAQ, blog, logos, gallery, call to action, contact, footer, login, 404 and coming soon. +The **Sections** view shows all 90 layouts in 22 section types, grouped by type and rendered live at 1280 px. The section types are header, hero, services, benefits, steps, numbers, pricing, reviews, team, portfolio, timeline, about, FAQ, blog, logos, gallery, call to action, contact, footer, login, 404 and coming soon. Since 0.12 each type has at least two layouts, among them bento grids, a pricing switch, service tabs, a FAQ accordion, a quote wall, a logo marquee and masonry galleries. + +- **Tabs and accordion.** The pricing switch and the service tabs use Bricks' nested tabs. The FAQ accordion uses Bricks' nested accordion with FAQ schema. Bricks' own script switches them; the preview shows the first tab open and the answers closed. Edit each tab and answer in the builder. For monthly and yearly prices, rename the switch's tabs (**Packages / Single prices**) and enter your prices in the panes. - **Copy.** Copies a single section. Paste it in the Bricks editor with Ctrl+V. - **Add to page.** Adds the section to your page. A header goes first, a footer last, and anything else goes before the footer. @@ -52,6 +54,10 @@ The **Sections** view shows all 40 layouts in 22 section types, grouped by type - **Copy for Bricks (Ctrl+V).** Pastes the page into the editor. - **Open in Staging.** Loads the page as a new section or version, to review it against a page of a connected site, save it there, or install the design system. +## Modernize your own sections + +The **Modernize** tab brings Bricks JSON you already have onto the same design system: tokens instead of fixed colors, the kit's scale instead of px, `bs-` classes instead of repeated inline styles, and mobile rules. The brand kit then restyles it like a Studio layout. See [Modernize](MODERNIZE.md). + ## How the output is built **tokens → Bricks palette and variables → BEM global classes → elements** @@ -94,9 +100,10 @@ Since 0.10 an install is not a one-way street. ## From Claude, ChatGPT and other MCP clients -The MCP server offers two Studio tools: +The MCP server offers three Studio tools: - **`bricks_kit_options`** lists style directions, font pairs, industries and every section type with its layouts. +- **`bricks_modernize_template`** rebuilds Bricks JSON on the design system (see [Modernize](MODERNIZE.md)). - **`bricks_kit_page`** builds sections or a page. It takes `sections` (type and optional `variant`), an optional `kit` (style, primary, accent, fonts, radius, spacing, mode) and an optional `profile` (industry, language, name, city, phone, email, address, tagline, services). It returns the Bricks import object, the design system and the quality checks. For example: "Use BricksSnap to build a homepage for a vehicle registration service in Bremen in the Warm style with a green brand color, in German, and give me the Bricks JSON." diff --git a/package-lock.json b/package-lock.json index d5b696a..1fc5550 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "brickssnap", - "version": "0.11.1", + "version": "0.12.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "brickssnap", - "version": "0.11.1", + "version": "0.12.0", "license": "PolyForm-Shield-1.0.0", "dependencies": { "@modelcontextprotocol/sdk": "^1.30.1", diff --git a/package.json b/package.json index f93cc49..1394eba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "brickssnap", - "version": "0.11.1", + "version": "0.12.0", "scripts": { "dev": "next dev --webpack", "dev:local": "node scripts/dev-local.mjs", diff --git a/src/app/page.tsx b/src/app/page.tsx index 4cc19e0..46e555c 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -14,6 +14,7 @@ import ConnectionGuide from "@/components/ConnectionGuide"; import StagingWorkspace from "@/components/StagingWorkspace"; import KitStudio, { type KitSelection, type Saved } from "@/components/kit/KitStudio"; import KitLibrary, { type StudioPreset } from "@/components/kit/KitLibrary"; +import KitModernize from "@/components/kit/KitModernize"; import { DESIGNS } from "@/lib/kit/library"; import { VARIANTS } from "@/lib/kit/sections"; import packageJson from "../../package.json"; @@ -21,10 +22,11 @@ import packageJson from "../../package.json"; // Default import: webpack no longer supports named exports from JSON modules. const { version } = packageJson; -type Tab = "studio" | "generator" | "library" | "staging"; +type Tab = "studio" | "generator" | "library" | "modernize" | "staging"; const TABS: Array<{ id: Tab; label: string }> = [ { id: "studio", label: "Studio" }, { id: "library", label: "Library" }, + { id: "modernize", label: "Modernize" }, { id: "generator", label: "Generator" }, { id: "staging", label: "Staging" }, ]; @@ -288,6 +290,17 @@ export default function Home() { )} + {activeTab === "modernize" && ( +
+
+

Import & modernize

+

Bring any section. Make it yours.

+

Paste Bricks JSON from an old project, a client site or a component library. BricksSnap maps its colors, font sizes, spacing and radii to your design system, turns inline styles into clean bs- classes and adds the mobile rules it is missing. Then the brand kit restyles it like any Studio section.

+
+ +
+ )} + {activeTab === "library" && (
diff --git a/src/components/kit/KitControls.tsx b/src/components/kit/KitControls.tsx index 11588dd..af29c91 100644 --- a/src/components/kit/KitControls.tsx +++ b/src/components/kit/KitControls.tsx @@ -36,7 +36,7 @@ function ColorField({ id, label, value, onChange }: { id: string; label: string;
; } -export default function KitControls({ kit, onKit, profile, onProfile }: { kit: BrandKit; onKit: (kit: BrandKit) => void; profile: BusinessProfile; onProfile: (profile: BusinessProfile) => void }) { +export default function KitControls({ kit, onKit, profile, onProfile, showBusiness = true }: { kit: BrandKit; onKit: (kit: BrandKit) => void; profile: BusinessProfile; onProfile: (profile: BusinessProfile) => void; showBusiness?: boolean }) { const [services, setServices] = useState(profile.services?.join("\n") ?? ""); const checks = contrastChecks(resolveKit(kit)).filter(check => !check.ok); const field = (key: "name" | "city" | "phone" | "email" | "address", label: string, placeholder: string, type = "text") => @@ -86,7 +86,7 @@ export default function KitControls({ kit, onKit, profile, onProfile }: { kit: B onKit({ ...kit, mode })}/> -
+ {showBusiness &&

Business

@@ -108,6 +108,6 @@ export default function KitControls({ kit, onKit, profile, onProfile }: { kit: B onChange={e => { setServices(e.target.value); const list = e.target.value.split("\n").map(s => s.trim()).filter(Boolean).slice(0, 6); onProfile({ ...profile, services: list.length ? list : undefined }); }}/>

Texts are written for the industry and filled with your details. Nothing leaves your browser.

-
+
}
; } diff --git a/src/components/kit/KitModernize.tsx b/src/components/kit/KitModernize.tsx new file mode 100644 index 0000000..874ec92 --- /dev/null +++ b/src/components/kit/KitModernize.tsx @@ -0,0 +1,177 @@ +"use client"; + +import { useDeferredValue, useMemo, useRef, useState } from "react"; +import { buildBricksImportJson } from "@/lib/bricks-export"; +import { copyToClipboard, downloadText } from "@/lib/clipboard"; +import { KIT_FONT_VARS } from "@/lib/kit/app-fonts"; +import { renderPreview } from "@/lib/kit/preview"; +import { DEFAULT_KIT, normalizeKit, resolveKit, type BrandKit } from "@/lib/kit/tokens"; +import { modernizeTemplate, parseColor } from "@/lib/modernize"; +import { MODERNIZE_EXAMPLE } from "@/lib/modernize-example"; +import KitControls from "./KitControls"; +import KitPreviewFrame from "./KitPreviewFrame"; +import type { KitSelection } from "./KitStudio"; + +const VIEWPORTS = { desktop: 1280, tablet: 820, phone: 390 } as const; +type Viewport = keyof typeof VIEWPORTS; +const secondary = "inline-flex h-9 items-center justify-center gap-2 rounded-lg border border-border bg-card px-3 text-sm font-medium text-foreground hover:border-border-hover hover:bg-subtle disabled:opacity-40"; +const primary = "inline-flex h-9 items-center justify-center gap-2 rounded-lg bg-primary px-4 text-sm font-medium text-white hover:bg-primary-hover disabled:opacity-40"; +const segment = (active: boolean) => `h-8 rounded-md px-3 text-xs ${active ? "bg-card font-medium text-foreground shadow-[0_1px_2px_rgba(28,25,23,.08)]" : "text-muted hover:text-foreground"}`; + +/** Starts from the Studio's last kit in this browser. */ +function studioKit(): BrandKit { + try { const saved = JSON.parse(localStorage.getItem("brickssnap_kit_studio") ?? "null"); if (saved?.kit) return normalizeKit(saved.kit); } catch { /* Not essential. */ } + return DEFAULT_KIT; +} + +function Swatch({ color }: { color: string }) { + return ; +} + +/** Import any Bricks JSON and rebuild it on the brand kit's tokens and bs- classes. */ +export default function KitModernize({ onOpenInStaging }: { onOpenInStaging: (selection: KitSelection) => void }) { + const [kit, setKit] = useState(studioKit); + const [text, setText] = useState(""); + const [parsed, setParsed] = useState(null); + const [parseError, setParseError] = useState(""); + const [block, setBlock] = useState(""); + const [view, setView] = useState<"after" | "before" | "compare">("after"); + const [viewport, setViewport] = useState("desktop"); + const [status, setStatus] = useState(""); + const file = useRef(null); + + const shownKit = useDeferredValue(kit); + const shownBlock = useDeferredValue(block); + const outcome = useMemo(() => { + if (parsed === null) return null; + try { return { result: modernizeTemplate(parsed, { kit: shownKit, block: shownBlock || undefined }) }; } + catch (error) { return { error: error instanceof Error ? error.message : "This JSON could not be read." }; } + }, [parsed, shownKit, shownBlock]); + const result = outcome && "result" in outcome ? outcome.result : null; + const previews = useMemo(() => { + if (!result) return null; + const variables = result.designSystem.css.replace(/^:root \{\n/, "").replace(/\n\}$/, ""); + return { before: renderPreview(result.source), after: renderPreview(result.template, { variables, fonts: KIT_FONT_VARS }) }; + }, [result]); + const colors = resolveKit(shownKit).colors as Record; + + const flash = (message: string) => { setStatus(message); window.setTimeout(() => setStatus(s => (s === message ? "" : s)), 2500); }; + const read = (value: string) => { + setText(value); + if (!value.trim()) { setParsed(null); setParseError(""); return; } + try { setParsed(JSON.parse(value)); setParseError(""); } + catch { setParsed(null); setParseError("This is not valid JSON. Copy a section in Bricks (Ctrl+C) or export a template, and paste the whole text."); } + }; + const loadFile = async (f?: File) => { + if (!f) return; + if (f.size > 2_000_000) { setParseError("Choose a JSON file smaller than 2 MB."); return; } + read(await f.text()); + }; + const title = result ? `Modernized ${result.block}` : "Modernized"; + const type = result && result.template.content.filter(el => el.parent === 0).length > 1 ? "content" : "section"; + const r = result?.report; + + const frame = (which: "before" | "after", width: number) => previews &&
+
+
; + + return
+ + +
+
+
+
+

1. Paste Bricks JSON

+

In Bricks, select a section in the structure panel and press Ctrl+C, or export a template. Components from a library work too, as long as you may use them. Everything runs in your browser; nothing is uploaded.

+
+
+ + +
+
+ { void loadFile(e.target.files?.[0]); e.target.value = ""; }}/> + +