Skip to content

[Studio UI] Document editables: switch and colour picker options, design tokens for editmode CSS - #4202

Open
idaiv wants to merge 4 commits into
2026.xfrom
document-editables-switch-and-color
Open

idaiv wants to merge 4 commits into
2026.xfrom
document-editables-switch-and-color

Conversation

@idaiv

@idaiv idaiv commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Changes in this pull request

Part of https://github.com/pimcore/product-management/issues/1458 (portal configuration in Studio)

Two new options for document editables, and Studio's design tokens for a template's own editmode CSS. Nothing changes for templates that don't use them.

pimcore_checkbox as a switch

  • {display: 'switch'} draws Studio's Switch (small, label on the right) instead of a checkbox.
  • The stored value is the same boolean. Inheritance works as before: the switch is disabled while the value is inherited.
  • The label is a <label> for the control, in both displays: it gives the switch or checkbox its accessible name, and a click on it toggles the control. Before, the checkbox label was an unconnected sibling.

pimcore_input as a colour picker

  • {color: true} draws Studio's ColorPicker (hex, no alpha, clearable) with the colour's hex code next to the swatch.
  • The editable still stores the hex text; clearing stores an empty string.
  • When the field is empty, its placeholder is shown as the swatch and as greyed hex text, so an editor sees which colour applies by default.
  • Inherited values get the usual overlay with "overwrite".

Studio design tokens in the document editor iframe

  • The iframe now publishes a set of Studio's theme tokens on :root as CSS variables, so a template's editmode stylesheet can follow the theme instead of copying values.
  • Covered: type, text colours, primary, borders, controls, the spacing scale, motion, and Studio's field widths (small, medium, large).
  • Names follow the antd token, kebab-cased with a --studio- prefix: marginSM → --studio-margin-sm, colorTextDescription → --studio-color-text-description.
  • The list is deliberate (design-token-variables.ts) and can be extended when a template needs another token.

Additional info

  • First user: the portal configuration page, pimcore/portal-engine#1102.
  • Tests: checkbox-editable.test.tsx, color-input-editable.test.tsx, design-token-variables.test.ts (14 tests).

🤖 Generated with Claude Code

idaiv and others added 2 commits October 14, 2026 09:29
…ur picker

Two opt-in display options for document editables, set from the template config:
- pimcore_checkbox(..., {display: 'switch'}) draws Studio's Switch (small, label on its right)
  instead of a checkbox.
- pimcore_input(..., {color: true}) draws Studio's ColorPicker trigger: a swatch with the
  upper-case hex code, clearable. The stored value is unchanged: the hex text, or an empty string
  once cleared. An empty field shows its placeholder, the colour that applies while it is empty,
  in the swatch and as its hex code in the placeholder colour.

Without the options both editables render exactly as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… the iframe

A template's editmode stylesheet cannot read the theme, so it had to copy values and drift from
it. The editor iframe now publishes a deliberate set of tokens on :root as --studio-* variables:
type, text, primary, borders, controls, the spacing scale, motion and Studio's field widths.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 09:36
@idaiv idaiv added this to the 2026.4.0 milestone Oct 14, 2026
@idaiv idaiv self-assigned this Oct 14, 2026
@idaiv
idaiv requested a review from vin0401 October 14, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The newly rendered switch lacks an accessible name despite displaying a visual label.

1 open finding
What changed in this PR

Adds opt-in switch and colour-picker document editables, plus iframe CSS design tokens.

Changes:

  • Adds switch rendering for checkbox editables.
  • Adds colour-picker rendering for input editables.
  • Exposes selected Studio theme tokens as CSS variables.

Review assessment:

  • Implementation is additive, backward-compatible, and placed in the owning components.
  • Relevant call sites are covered by configuration-gated rendering.
  • Focused regression tests are included; no dedicated documentation was added.
  • Accessibility issue: the switch’s visible label is not its accessible name (checkbox-editable.tsx:72-76).
File Description
dynamic-type-document-editable-input.tsx Selects colour-picker rendering.
dynamic-type-document-editable-checkbox.tsx Adds the switch display option.
color-input-editable.tsx Implements colour editing and inheritance.
color-input-editable.test.tsx Tests colour display and component selection.
color-input-editable.styles.ts Styles placeholder text.
checkbox-editable.tsx Implements switch rendering.
checkbox-editable.test.tsx Tests switch behavior.
global.styles.ts Publishes tokens in the iframe.
design-token-variables.ts Maps theme tokens to CSS variables.
design-token-variables.test.ts Tests token mapping and serialization.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

… and toggles it

The label was a sibling of the control, so a screen reader announced an unnamed switch and a
click on the label did nothing. It is now a <label> for the control, in both displays.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The colour picker’s value-selection and clearing persistence contract needs regression coverage.

0 open findings

1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Low severity Add persistence tests for color selection and clearing

assets/​js/​src/​core/​modules/​element/​dynamic-types/​definitions/​document/​editable/​components/​color-input-editable/​color-input-editable.tsx:45

The persistence branch for this new editable is not exercised: the added tests only check rendered text and component selection, so a regression where selecting or clearing a colour emits the wrong stored string would still pass. Please invoke the picker’s onChange path and assert that a selected colour emits its hex text and a cleared colour emits ''; this is the smallest seam for the new storage contract.

🧠 Review effort: Balanced

A picked colour is stored as its hex text, a cleared one as an empty string. The test drives the
picker's onChange the way a pick and a clear do.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@idaiv

idaiv commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Copilot's second review listed a "previously missed" finding: no test covered what the colour picker stores. Fixed in 9c032f6. The test drives the picker's onChange the way a pick and a clear do, and asserts that a pick stores the hex text and a clear stores an empty string.

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants