Files
webstudio/.github
Oleg Isonen 89ca46cd7f fix: Improve floating surface and menu selection contrast (#6670)
## Problem

Autocomplete suggestions were hard to distinguish in dark mode.
Dropdowns and dialogs did not have a clear depth order, and Select
opened against its trigger.

## Result

Floating surfaces become slightly darker in light mode and lighter in
dark mode. Select opens 4 px below its control. Highlighted rows, intent
colors, and disabled states remain distinguishable on the new surfaces.

The theme still uses nine live inputs. Shared color recipes and a
smaller CSS reader replace repeated calculations and authoring-policy
checks. Missing references, cycles, duplicate definitions, and selector
ownership are still checked during type generation. Components keep the
same generated semantic color types.

## Plan and todos

1. [x] Define floating surface levels from the existing theme colors for
both modes.
2. [x] Apply them to dialogs, menus, nested menus, popovers, commands,
canvas controls, arrows, and borders.
3. [x] Keep highlighted menu, command, and inset-list rows visible.
4. [x] Remove the Builder spacing popover's base-background override.
5. [x] Add Storybook examples for dropdown over dialog, canvas toolbar,
and badge.
6. [x] Add a 4 px gap to the shared Select used by Position and Display.
7. [x] Check primary, secondary, accent, error, and status contrast on
floating levels.
8. [x] Document the palette rule in the design-system color guide.
9. [x] Review the selected light and dark stories listed in earlier
validation. This was not an exhaustive UI-state audit.
10. [x] Run design-system tests, relevant typechecks, lint, formatting,
package boundaries, and diff checks.
11. [x] Fix the audit's text, destructive-control, style-source,
disabled-hover, and vivid-theme contrast failures.
12. [x] Review product documentation and fixture impact.
13. [ ] Monitor CI for the current commit and complete visual-difference
approval.
14. [x] Replace floating-only intent colors with shared semantic colors.
15. [x] Make InsetList selection follow its actual containing surface.
16. [x] Consolidate color recipes and contrast-pair definitions while
preserving rendered colors.
17. [x] Simplify CSS parsing and verify all nine theme controls in both
modes.
18. [x] Remove redundant declaration collection while retaining exact
validation behavior.
19. [x] Reproduce and fix the Grid generator contrast and CSS value
footer reports in real Storybook compositions, cover missing
open/hover/selected states in both modes, and record actual audit
coverage and remaining gaps.
20. [ ] Audit every Builder, Dashboard, and design-system interface in
light and dark mode: inventory components and reachable states, render
all stories, exercise
hover/focus/active/selected/disabled/open/error/loading/empty states,
add missing compositions, inspect screenshots and actual contrast, and
publish findings with evidence and unresolved coverage gaps.
21. [x] Soften floating-surface contrast in light and dark themes, align
the Grid generator's preview outline with its grid lines, and verify
focused stories, regression checks, and documentation impact.
22. [x] Make shared popover headers and bodies use one background color,
check Grid settings and other callers in both themes, add regression
coverage, and review documentation impact.
23. [x] Reduce the shared Grid generator and selector line contrast in
both themes, keep the preview outline matched, verify visibility and
Storybook states, and review documentation impact.

## Validation

Palette-refactor validation below applies to `07d11239f5`. The Storybook
coverage follow-up is `e38d25537d`.

- All 284 design-system tests passed, plus design-system typecheck,
focused lint, formatting, and diff checks.
- A Chromium comparison found identical rendered RGBA values for 1,312
samples across both modes and 16 theme configurations before and after
the recipe refactor.
- All 50 contrast contracts remain. The new theme-control checks cover
every generated public theme input in both modes.
- Deliberate temporary mutations confirmed the new checks fail when the
protected behavior breaks.
- Independent Astra reviews found no new defects. The final cleanup
matched exact outputs or errors for 167 valid and invalid parser inputs.
- Current parsed source output and generated token types are unchanged.
- Earlier Builder typechecks and package-boundary checks passed. This
refactor changes no public component API.
- No fixture inputs or generated fixture bundles are affected. The
design-system README was updated; the product Craft documentation still
matches the behavior.

The latest commit removes 342 net implementation lines, excluding tests
and documentation. The color parser is 152 lines, the stylesheet 253,
and the contrast helper 127. CSS still performs all runtime color
calculation; the parser supports type generation and Storybook.

All non-visual CI checks passed for this commit. The visual-regression
job was cancelled before producing its comparison report, so visual CI
is not complete. The visual approval label has not been applied.

## Visual coverage correction

The previous palette tests and selected screenshots did not establish
that every Builder interface and state had been inspected. The Grid
generator had no direct story, and the CSS fragment story did not open
the dialog or render its shortcut footer. Both reported defects were
reproduced in new open stories in light and dark mode. Both fixes are
verified locally and included in `e38d25537d`. Grid open, selected,
hover, preset-hover, and keyboard-focus states were captured; the CSS
dialog was captured normal and maximized in both modes. The grid's
weakest measured outline contrast is 3.176:1, up from about 1.1:1
against the panel. The footer no longer paints a base-surface strip
inside the floating dialog.

All 11 focused browser tests, Builder typecheck, six-file lint,
formatting, and diff checks passed. Temporary old-style mutations made
all four new light/dark regression cases fail; restoring the fixes made
them pass. Independent review found no remaining defects in these fixes.
Runtime code grows by five net lines; stories add 110 lines, including
shared-store setup and restoration for repeatable rendering. No fixture
bundles or product documentation are affected.

The follow-up adds 217 story cases, including actual dialogs, canvas
overlays, collection and resource loading/error states, confirmations,
and editor states. Stories use real components and local HTTP responses.
Builder and design-system typechecks, focused lint, formatting, and diff
checks pass. No published-project fixture inputs or generated bundles
are affected.

The broader contrast audit remains in progress. Its source inventory
covers 416 JSX interface files; the current Storybook scope is 427
stories in both themes. Render captures and interaction-state probes are
tracked separately. Confirmed remaining problems include error-page
heading contrast, collaborator labels, grid guides over different canvas
colors, position dots, keyboard hints, pressed secondary labels, editor
punctuation, and color-picker unit labels/surfaces. These findings are
not fixed by this commit. Task 20 remains open until the remaining
interactions and evidence review are complete.

CI for `bd1d6349bc` is running; task 13 remains open pending required
checks and visual review.

## Contrast follow-up

Floating surfaces are softer in both themes, especially light mode,
while keeping the intended light and dark surface directions. The Grid
preview outline matches its internal lines except during visible
keyboard focus. New browser regressions failed before the fix and pass
afterward in both modes. Storybook captures of the open Grid generator
and dialog with dropdown were reviewed in light and dark mode.
Design-system tests (284), focused Builder tests (2), both package
typechecks, focused lint, formatting, and diff checks pass. The Craft
docs and design-system color guide still describe this behavior; no
documentation or fixture input/output changes are needed. These changes
are included in `5558d2ab12`, and task 21 is complete.

## Popover surface follow-up

The Style panel passes its primary section background and sticky header
setting into portalled Grid settings. The shared floating panel now
marks its surface, and Builder sections inside it use the same floating
background as the panel title and body. The Grid settings Storybook
story reproduces the real Style panel context. New light and dark
browser regressions failed before the fix and pass afterward. Reviewed
Grid settings, a plain FloatingPanel, and a titled Popover in both
modes; direct Popover keeps its raised surface. Design-system tests
(284), focused Builder tests (4), both package typechecks, focused lint,
formatting, and diff checks pass. No product documentation or fixture
inputs/outputs change. These changes are included in `6839897bb2`, and
task 22 is complete.

## Grid line contrast follow-up

The shared Grid line mix is reduced from 75% to 60%
foreground-secondary. In Chromium, gray selector and preset-cell borders
now measure 2.323:1 in light mode and 2.550:1 in dark mode against their
cell fills, down from 3.134:1 and 3.415:1. The preview line measures
2.803:1 and 2.964:1 against its surrounding body surface; its outer
outline uses the exact same color. Selected and hover focus-color cues
remain unchanged. These gray strokes are softer and remain visible, but
their cell-border ratios are below the Craft guide's 3:1 target for
meaningful non-text graphics. The focused browser regressions failed
before the edit and pass afterward in both themes. Grid generator and
selector Storybook states were reviewed in light and dark mode. Builder
typecheck, focused lint, formatting, and diff checks pass. Product
documentation and fixture inputs/outputs are unaffected. This change is
included in `bd1d6349bc`, and task 23 is complete.
2026-11-10 23:10:16 +01:00
..
2024-05-28 14:15:55 +03:00