feat(options): menu item color as preset dropdown with persistent custom color (working example)

navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.

NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-26 13:51:55 +01:00
commit f2ebf24270

View file

@ -268,6 +268,17 @@ foreach ($logoPositions as $pos) {
}
}
// --- Row 115 migration: navbarfontcolor became a mode dropdown (default|color1|
// color2|color3|other) with a navbarfontcolorcustom colorpicker child. A legacy HEX
// value in the json means "custom color": map it to mode "other" and move the hex
// into navbarfontcolorcustom, so the variant default stays valid for the dropdown.
if (isset($definition['options']['navbarfontcolor'])
&& is_string($definition['options']['navbarfontcolor'])
&& preg_match('/^#[0-9a-fA-F]{3,8}$/', $definition['options']['navbarfontcolor'])) {
$definition['options']['navbarfontcolorcustom'] = $definition['options']['navbarfontcolor'];
$definition['options']['navbarfontcolor'] = 'other';
}
$optionsNode = $xpath->query('//options')->item(0);
if ($optionsNode === null) {
fwrite(STDERR, "No <options> section found in mother config\n");