From f2316d1a5d005c77a46733bcb5bbfa76052505bc Mon Sep 17 00:00:00 2001 From: Tammo ter Hark Date: Thu, 26 Nov 2026 14:15:09 +0100 Subject: [PATCH] fix(options): readable swatch chips + re-enable color swatch on 'Other' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two fixes for the navbarfontcolor working example: (1) the hex value inside the swatch chips was unreadable and obscured the color — chips are now plain color swatches with the hex in a small label BELOW each swatch (.color-chip-label), and the chips row uses gap: 10px so the swatches stand out. (2) The visible color swatch input (navbarfontcolorcustom_picker) never re-enabled when choosing 'Other…' from the dropdown: it lacked data-parent/selector_radio_childfield, so updateChild/updateAllChildren never touched it and it stayed disabled (server-side rendered disabled) — the text field was enabled but the swatch the user actually clicks stayed grayed out. The swatch now gets the child classes when parented, so it follows the mode like the text field (also fixes the same latent bug for the per-element textcolorcustom pickers). OPTIONS_JS_TOKEN -> 20261126.3. jsdom test extended: swatch enabled in mode 'other'/disabled otherwise, hex below swatch, chip gap 10px asserted against css/plain.css; suite 6/6, export 0. Variants intentionally not rebuilt. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- css/plain.css | 29 +++++++++++++++++++++-------- options/options.js | 11 ++++++++--- options/options.twig | 5 +++-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/css/plain.css b/css/plain.css index 2aaa40b..1f0400b 100644 --- a/css/plain.css +++ b/css/plain.css @@ -234,28 +234,41 @@ div.qvideo .question-valid-container { } /* Full column width: the chips row sits in its own block under the dropdown - (sel.after(chips) in options.js) and stretches to the column's full width. */ + (sel.after(chips) in options.js) and stretches to the column's full width. + 10px between the swatches so they stand out; the hex value sits BELOW each + swatch in .color-chip-label (inside the swatch it was unreadable). */ .color-mode-chips { display: flex; width: 100%; - gap: 0.35rem; + gap: 10px; margin-top: 0.4rem; } -.color-chip { +.color-chip-item { flex: 1 1 0; + min-width: 0; + display: flex; + flex-direction: column; + gap: 2px; +} + +.color-chip { + width: 100%; height: 1.6rem; - padding: 0 0.2rem; + padding: 0; border: 1px solid rgba(0, 0, 0, 0.35); border-radius: 0.25rem; cursor: pointer; background: transparent; - color: #fff; - text-shadow: 0 0 2px rgba(0, 0, 0, 0.8); +} + +.color-chip-label { font-size: 0.65rem; - line-height: 1; - overflow: hidden; + color: #6c757d; + text-align: center; white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } .color-chip.active { diff --git a/options/options.js b/options/options.js index 872c164..7e9ad0f 100644 --- a/options/options.js +++ b/options/options.js @@ -783,9 +783,14 @@ var ThemeOptions = function () { sel.after(chips); sel.data('color-chips', chips); $.each(presets, function (mode, key) { - var chip = $(''); + // per preset: a swatch button with the hex value BELOW it + // (the hex inside the swatch was unreadable and obscured the color) + var item = $(''); + var chip = $(''); + var lbl = $(''); chip.on('click', function () { sel.val(mode).trigger('change'); }); - chips.append(chip); + item.append(chip).append(lbl); + chips.append(item); }); } chips.find('.color-chip').each(function () { @@ -793,10 +798,10 @@ var ThemeOptions = function () { var mode = String(chip.data('mode')); var c = currentColor(presets[mode]); chip.css('background', c || 'transparent'); - chip.text(c || ''); chip.attr('title', mode + (c ? ' [' + c + ']' : '')); chip.attr('aria-label', chip.attr('title')); chip.toggleClass('active', String(sel.val()) === mode); + chip.siblings('.color-chip-label').first().text(c || ''); }); }; var refreshEffective = function () { diff --git a/options/options.twig b/options/options.twig index fc889d8..44ce569 100644 --- a/options/options.twig +++ b/options/options.twig @@ -43,7 +43,7 @@ heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control). Re-register it with a version token: bump OPTIONS_JS_TOKEN below whenever options/options.js changes, so every browser fetches the new file once. #} -{% set OPTIONS_JS_TOKEN = '20261126.2' %} +{% set OPTIONS_JS_TOKEN = '20261126.3' %} {{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }} @@ -524,7 +524,8 @@ + {% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %} + class="selector__colorpicker-inherit-value{% if attr.parent != '' %} selector_radio_childfield{% endif %}"/>