Fix import fidelity: rgba color tokens and import-from-anywhere#19
Merged
Conversation
The Properties panel resolved the selected node's DOM element by querying the admin document before the canvas iframes — but DOM-panel tree rows, Import-HTML preview rows, and overlay rings all carry data-node-id there, and the layers tree auto-expands ancestors AFTER selection. Ambient selector matching therefore flickered between correct (first click, real canvas element) and empty (re-click, tree row) on the same node. - New canonical lookup (canvasNodeLookup.ts) resolves nodes ONLY inside canvas breakpoint-frame documents (body[data-breakpoint-id]); the admin-document path and its ring-exclusion band-aids are deleted. - Consolidate three duplicate CSS attribute-escape helpers into one. - Ambient rules that match only through a universal subject (`*`, `body.x *`, `*::before`) no longer surface as pills — they are page-wide resets, not an identity of the selected element. They stay reachable via the dropdown and Selectors panel. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The importer's automatic CSS cascade isolation rewrote selectors the source never contained (body.instatic-import-scope-* prefixes, silent btn-2 suffix renames). That machinery is gone; control moves to the user. Each top-level linked stylesheet now imports in one of two modes, picked in the Review step (default 'convert'): - convert: parsed into editable style rules, merging CSS-natively into the one global cascade. When two page cascades define the same class differently, that is an explicit "Stylesheets disagree" conflict row (rename with suffix / keep first / overwrite) — applied scoped to the affected cascades, never silently. Repeated class fragments demote to ambient rules so the registry keeps one bindable rule per name. - file: the CSS imports verbatim as a SiteFile (type 'style') with a site.runtime.styles entry scoped to exactly the linking pages — page isolation via runtime scope instead of generated classes. @import graphs flatten in cascade order, Google-font imports still install as self-hosted fonts, url() assets still upload and rewrite. Node class tokens survive through the existing bare-class linking step. scopeClasses.ts is deleted; classCascades.ts (conflict detection + resolution + bindable normalization) and stylesheetPlan.ts (mode partition + flattening) replace it. The near-identical script/stylesheet SiteFile committers are deduplicated into importedSiteFiles.ts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Two losses found by comparing an imported template against its source: - The framework color engine only parsed hex and hsl/hsla. Imported tokens authored as rgba() (--rule, --ink-2, ...) silently emitted NO CSS variable, so every `var(--rule)` reference lost its declaration — user-visibly, all borders on the demo template vanished. parseColor now handles rgb()/rgba() (comma and space syntax, % alpha), and an unparseable BASE value (oklch(), color-mix(), named) emits verbatim instead of dropping — emission stays injection-safe because formatCssVariableBlock sanitises every value. Derived shade/tint/ transparent variants still skip what they can't model. - The Site Import modal is a global surface (Spotlight, any workspace), but static-site analysis resolves HTML through the module registry, which only the site editor's chunk populated. Importing from the Data workspace failed with "Module base.container is not registered". The modal now registers @modules/base itself, riding its own lazy chunk. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #15. Two import-fidelity losses found by comparing an imported template against its source HTML/CSS in a live browser session:
1. rgba() color tokens silently dropped → "all borders are gone"
The framework color engine (
parseColor) only understood hex and hsl/hsla. Imported:roottokens authored asrgba()—--rule: rgba(255,255,255,0.14),--ink-2/3/4— were stored correctly but emitted no CSS variable, so everyborder: 1px solid var(--rule)computed to no border, and translucent text colors fell back to plain white.parseColornow parsesrgb()/rgba()(comma + space syntax, numeric or%alpha) into channels — shades/tints/transparent steps derive normally.oklch(),color-mix(), named colors) now emits verbatim instead of silently dropping —var(--x)references never break. Injection-safe:formatCssVariableBlockalready sanitises every emitted value (covered by a new adversarial test). Derived variants still skip what they can't model.Verified live: re-loading the previously-imported club page restores all pricing-card borders and
--ink-2-tinted text with no reimport (tokens were stored faithfully; only emission was broken).2. Import only worked from the site editor
The Site Import modal is a global surface (Spotlight, any workspace), but static-site analysis resolves HTML through the module registry, which only the site editor's chunk populated — importing from
/admin/datafailed withModule "base.container" is not registered. The modal now registers@modules/baseitself; the import rides the modal's own lazy chunk, adding nothing to the shell bundle. Verified live from the Data workspace (zip reaches the Review step).Test plan
🤖 Generated with Claude Code