Colour-picker swatch for container-template fields with a #RRGGBB value - #2712
Conversation
… value A container-template Variable whose value is a #RRGGBB hex (an accent or theme colour) now shows a native colour swatch next to its text box on the Add/Edit Container form, kept in sync both ways. The text box is unchanged, so typing, pasting and an empty value keep working, and the swatch never alters the value unless clicked. Detection is by value pattern only (no new template attribute), so existing templates with a hex default upgrade automatically.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesDocker color swatch support
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
On the Add/Edit Container form, a template Variable whose value is a
#RRGGBBhex (a theme or accent colour, say) now shows a small native colour swatch next to its text box, kept in sync both ways: picking a colour fills the text box (and fireschangeso the form stays dirty-tracked), and typing or pasting a valid#rrggbbupdates the swatch.The text box itself is unchanged, so typing, pasting and leaving the field empty all keep working, and the swatch never alters the value unless the user clicks it.
Why
Several templates already expose a colour field (an accent, a theme tint) as a plain Variable with a hex default, so users have to hand-type a hex code with no visual feedback. A native swatch turns that into a one-click pick while staying fully backwards-compatible.
How
Detection is by value pattern only (
^#[0-9a-fA-F]{6}$) inmakeConfig()ininclude/CreateDocker.php, mirroring howMask="true"already switches a field to a password input a few lines above. There is no new template attribute and no schema change, so existing templates with a hex default upgrade automatically and every other field is untouched. Two delegatedinputhandlers keep the swatch and text box in sync, and a small CSS rule styles the swatch. Only the browser-native<input type="color">is used, so there is no new dependency.Files
emhttp/plugins/dynamix.docker.manager/include/CreateDocker.phpemhttp/plugins/dynamix.docker.manager/sheets/CreateDocker.cssSummary by CodeRabbit
New Features
Style