Files
site-builder/craft
shadowdao 613a44c4d4 feat(builder): items 10+12+13 — scope canvas guides, Show Guides toggle, Layers panel hover/icons, topbar unification
Item 10: dashed canvas "guide" outlines were applied via blanket tag
selectors (div/section/header/...), so a finished section showed 3-4
nested dashed boxes. RenderNode.tsx (the <Editor onRender> override) now
tags each Craft.js droppable container's real DOM node with a
`data-craft-node` attribute (node.data.isCanvas, excluding ROOT), and
editor.css's guide rules target that attribute instead — a component's own
internal wrapper markup is no longer mistaken for a drop target. Added a
"Show guides" topbar toggle (default ON, persisted to localStorage),
state lifted in EditorShell.tsx (mirrors how `device` is already lifted),
flips `.guides-off` on Canvas.tsx's `.canvas-device-frame`.

Item 12: Layers panel rows get per-type FA icons (keyed off the same
craft.displayName used for the row label, seeded from BlocksPanel's
choices), indent-guide lines connecting nested rows, and row hover
highlights the matching canvas element (`data-layer-hovered`, written
directly to the node's DOM via `query.node(id).get().dom` — NOT via
`actions.setNodeEvent`, which is stripped from useEditor()'s public
`actions` at runtime, not just in its TS type, and threw when called).

Along the way, Craft.js's own connect() was found to already wire mouse
hover to the same `hovered` node event internally (previously invisible
because the matching CSS was dead) — RenderNode now also mirrors that
onto `data-craft-hovered` for a real-mouse-hover canvas highlight, and
both hover attributes plus the guide attribute are suppressed under
`.guides-off` so the toggle stays airtight.

Item 13: unified the topbar to one button radius (`.topbar-btn` 20px pill
-> var(--radius-md)), demoted Code/Preview to icon-only with
`data-tooltip`. Fixed a latent bug the new tooltips exposed: `[data-tooltip]`
tooltips render above their trigger, but the topbar has no room above it
(`body { overflow: hidden }`) — added a `.topbar` override to render
those below instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 20:55:52 -07:00
..

WHP Site Builder v2

A visual drag-and-drop website builder for WHP, rebuilt from the ground up with Craft.js, React 18, and TypeScript. Replaces the legacy GrapesJS-based editor.

Quick Start

npm install
npm run dev

Opens at http://localhost:5173. The editor runs in standalone mode without WHP integration.

Build and Deploy

# Build production bundle
npm run build

# Deploy to WHP
cp dist/index.html /docker/whp/web/site-builder/editor.html
cp -r dist/js/ /docker/whp/web/site-builder/js/
cp -r dist/css/ /docker/whp/web/site-builder/css/

The PHP wrapper (index.php) injects WHP_CONFIG (user session, CSRF token, site ID) into the HTML before serving.

Architecture

  • Craft.js - React-based visual editor framework (no iframe, direct DOM rendering)
  • Inline styles - All user content uses React CSSProperties, no class-based CSS
  • Component pattern - Each component is a self-contained file with: render logic, settings panel, Craft.js config, and HTML export method
  • 3-panel layout - Left (blocks/pages/layers/assets), Center (canvas with device preview), Right (styles/settings/head)
  • Dark theme - CSS custom properties, Inter font, blue accent

Components (22)

Category Components
Layout Container, Section, ColumnLayout (1-6 cols), BackgroundSection, HeaderZone, FooterZone
Basic Heading (H1-H6), TextBlock, ButtonLink, Navbar, Footer, Divider, Spacer
Media ImageBlock (upload/browse/drag-drop), VideoBlock (YouTube/Vimeo/direct/background)
Sections HeroSimple, FeaturesGrid, CTASection
Forms FormContainer, InputField, TextareaField, FormButton

Features

  • Visual Editor - Drag-and-drop building, real-time preview, responsive device preview (Desktop/Tablet/Mobile)
  • Site Design Tokens - 17 site-wide properties (colors, fonts, radii, nav style) with Basic/Advanced tabs
  • Multi-Page - Unlimited pages with shared Header and Footer across all pages
  • 16 Templates - Pre-built designs across 4 categories (Business, Creative, Personal, Community)
  • Asset Management - Upload, browse, drag-drop, thumbnails, server-side storage via WHP API
  • HTML Export - Full document export with Google Fonts and inline styles
  • Auto-Save - Saves every 30 seconds when connected to WHP
  • Context Menu - Right-click for duplicate, copy, paste, move, delete
  • Keyboard Shortcuts - Undo, redo, delete
  • Layers Panel - Component hierarchy tree view
  • Undo/Redo - Full history support

Key Files

File Purpose
src/main.tsx Entry point, reads WHP_CONFIG
src/App.tsx Editor + providers (EditorConfig, SiteDesign, Pages)
src/components/resolver.ts Component registry (20 components) for serialization
src/editor/EditorShell.tsx 3-panel layout + context menu + keyboard shortcuts
src/editor/Canvas.tsx Craft.js Frame with device switching
src/state/PageContext.tsx Multi-page state + header/footer
src/state/SiteDesignContext.tsx 17 site-wide design tokens
src/templates/definitions.ts 16 template definitions
src/constants/presets.ts Color, font, spacing presets
src/utils/html-export.ts Node-tree to HTML renderer

See CLAUDE.md for full documentation. See FEATURES.md for a complete feature list.