Skip to content

Conversation

@lattln
Copy link
Collaborator

@lattln lattln commented Jan 30, 2026

Summary

Improves the HTML Field iframe rendering so embedded HTML content properly follows the application’s light/dark theme. Previously, the iframe was isolated from parent styles and fell back to browser defaults.


Key Changes

  • Added theme-aware default styles for HTML content rendered inside iframes
  • Reads semantic color CSS variables (--mie-color-*) from the parent editor/renderer root
  • Injects those variables into the iframe :root so styles stay in sync
  • Automatically updates when theme changes (via MutationObserver)

Behavior

  • Common HTML elements (p, headings, lists, tables, code, etc.) render with readable, theme-consistent styles
  • Defaults apply only when user HTML has no explicit styles
  • User-provided styles always take precedence
  • Falls back to light mode if theme variables are not yet available

Implementation Notes

  • Uses getComputedStyle() to read actual resolved theme values
  • Centralized theme constants and helpers for DRY/KISS compliance
  • Removed unused state and dead code

Files Changed

  • HTML_Field.jsx

Testing

  • Verified HTML content updates live when toggling light/dark mode
  • Confirmed custom inline and <style>-based user HTML is not overridden

Here’s a clean PR-ready section you can drop straight into the PR description under Testing or How to Test.
It’s concise, explicit, and reviewer-friendly.


How to Test (Local Package Validation)

This change was validated using a local packed build of the package and installed into an external project to verify real-world behavior.

Steps:

  1. From the questionnaire-builder repo:

    # which builds the packages and pack it locally for you insdie of ./localpackages/...
    npm run pack:local
    
  2. Locate the generated tarball(s) in:

    localpackages/..
    
  3. In the consuming project (e.g. bluehive-ai or another external app), install the local package:

    npm install /absolute/path/to/questionnaire-builder/localpackages/package/<package-name>.tgz
  4. Start the consuming application and verify:

    • HTML Field renders with correct light/dark theming
    • Theme changes propagate live into iframe content
    • No regressions in other form fields
    • User-provided HTML styles still take precedence

Notes:

  • This bypasses npm registry publishing and tests the package exactly as it would ship.
  • Repeat install for editor/renderer/engine packages as needed.

+ added Theme Variables
+ Theme awareness with default Theme if no Theme is provided.
+ Refactor HTML_Field for general DRY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Basic Theme Awareness for HTML Field Content (Iframe Default Styling)

2 participants