feat: dark-mode variant for background images - #701
Conversation
Add a "Dark Mode" option to the Background control's "+" menu, mirroring the dark variant already available on Image elements. The dark background (image/color/gradient) is stored as `dark:background*` styles. - BackgroundHandler: expose the dark variant alongside the hover/active/focus states; skip the interaction-state transition since dark mode is a theme switch - builder_page: render `dark:` styles as a `@media (prefers-color-scheme: dark)` query plus `[data-theme="dark"]` / `[data-prefers-color-scheme="dark"]` selectors, instead of an invalid `:dark` pseudo-class - BuilderBlock: preview the dark variant in the canvas dark-mode toggle - copy/paste: absolutize the dark background image URL, like darkSrc Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
|
||
| // "Dark Mode" sits alongside the hover/active/focus states in the "+" menu; its | ||
| // value is stored as `dark:background*` styles and rendered under prefers-color-scheme. | ||
| const bgVariants = [{ name: "dark", property: "dark:background", label: "Dark Mode" }]; |
There was a problem hiding this comment.
Mixed backgrounds corrupt dark variants
When selected blocks have different base backgrounds, adding Dark Mode copies blockController.getStyle()'s mixed-value sentinel into every block, causing invalid or incorrect dark background CSS instead of preserving each block's own value.
Context Used: AGENTS.md (source)
Knowledge Base Used: Properties Panel: Editing Block Styles and Props
Confidence Score: 3/5The multi-selection dark-variant corruption should be fixed before merging. Creating Dark Mode for blocks with differing backgrounds copies the aggregate mixed sentinel into every selected block instead of copying each block’s own styles. Files Needing Attention: frontend/src/components/BackgroundHandler.vue Reviews (1): Last reviewed commit: "feat: dark-mode variant for background i..." | Re-trigger Greptile |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #701 +/- ##
===========================================
+ Coverage 56.54% 57.57% +1.03%
===========================================
Files 34 35 +1
Lines 4119 4278 +159
===========================================
+ Hits 2329 2463 +134
- Misses 1790 1815 +25 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What
Adds a Dark Mode option to the Background control's
+menu, so a block can have a separate background (image / color / gradient) for dark mode — mirroring the dark variant already available on Image elements (darkSrc).How it works
dark:background*styles (e.g.dark:backgroundImage), reusing the existing variant/state machinery — so the "+" menu, the variant row, and the popover editor all work with no new UI.@media (prefers-color-scheme: dark)plus[data-theme="dark"]/[data-prefers-color-scheme="dark"]selectors, matching how Builder already scopes dark mode (auto + manual toggle), instead of an invalid:darkpseudo-class.darkSrcswap).Changes
BackgroundHandler.vue— expose thedarkvariant on the Background control; skip the hover-style transition for it (dark mode is a theme switch, not an interaction state).builder_page.py—append_state_stylerenders thedarkstate via a dark-mode media query + toggle selectors (dark_mode_stylehelper).BuilderBlock.vue— applydark:styles in the canvas whencanvasDarkModeis on.builderBlockCopyPaste.ts— absolutize thedark:backgroundImageURL on copy, likedarkSrc.Testing
+menu lists Dark Mode alongside On Hover / On Active / On Focus, and that once set it appears as a variant row with its own background editor.Screen.Recording.2026-07-30.at.11.44.04.mov