fix(options): readable swatch chips + re-enable color swatch on 'Other'
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 <el>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 <vibe@mistral.ai>
This commit is contained in:
parent
dc27d63de5
commit
f2316d1a5d
3 changed files with 32 additions and 13 deletions
|
|
@ -234,28 +234,41 @@ div.qvideo .question-valid-container {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Full column width: the chips row sits in its own block under the dropdown
|
/* 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 {
|
.color-mode-chips {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
gap: 0.35rem;
|
gap: 10px;
|
||||||
margin-top: 0.4rem;
|
margin-top: 0.4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-chip {
|
.color-chip-item {
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-chip {
|
||||||
|
width: 100%;
|
||||||
height: 1.6rem;
|
height: 1.6rem;
|
||||||
padding: 0 0.2rem;
|
padding: 0;
|
||||||
border: 1px solid rgba(0, 0, 0, 0.35);
|
border: 1px solid rgba(0, 0, 0, 0.35);
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: #fff;
|
}
|
||||||
text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
|
|
||||||
|
.color-chip-label {
|
||||||
font-size: 0.65rem;
|
font-size: 0.65rem;
|
||||||
line-height: 1;
|
color: #6c757d;
|
||||||
overflow: hidden;
|
text-align: center;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-chip.active {
|
.color-chip.active {
|
||||||
|
|
|
||||||
|
|
@ -783,9 +783,14 @@ var ThemeOptions = function () {
|
||||||
sel.after(chips);
|
sel.after(chips);
|
||||||
sel.data('color-chips', chips);
|
sel.data('color-chips', chips);
|
||||||
$.each(presets, function (mode, key) {
|
$.each(presets, function (mode, key) {
|
||||||
var chip = $('<button type="button" class="color-chip" data-mode="' + mode + '" aria-label="' + mode + '"></button>');
|
// per preset: a swatch button with the hex value BELOW it
|
||||||
|
// (the hex inside the swatch was unreadable and obscured the color)
|
||||||
|
var item = $('<span class="color-chip-item"></span>');
|
||||||
|
var chip = $('<button type="button" class="color-chip" data-mode="' + mode + '"></button>');
|
||||||
|
var lbl = $('<span class="color-chip-label"></span>');
|
||||||
chip.on('click', function () { sel.val(mode).trigger('change'); });
|
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 () {
|
chips.find('.color-chip').each(function () {
|
||||||
|
|
@ -793,10 +798,10 @@ var ThemeOptions = function () {
|
||||||
var mode = String(chip.data('mode'));
|
var mode = String(chip.data('mode'));
|
||||||
var c = currentColor(presets[mode]);
|
var c = currentColor(presets[mode]);
|
||||||
chip.css('background', c || 'transparent');
|
chip.css('background', c || 'transparent');
|
||||||
chip.text(c || '');
|
|
||||||
chip.attr('title', mode + (c ? ' [' + c + ']' : ''));
|
chip.attr('title', mode + (c ? ' [' + c + ']' : ''));
|
||||||
chip.attr('aria-label', chip.attr('title'));
|
chip.attr('aria-label', chip.attr('title'));
|
||||||
chip.toggleClass('active', String(sel.val()) === mode);
|
chip.toggleClass('active', String(sel.val()) === mode);
|
||||||
|
chip.siblings('.color-chip-label').first().text(c || '');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var refreshEffective = function () {
|
var refreshEffective = function () {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control).
|
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
|
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. #}
|
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') }}
|
{{ unregisterScriptFile(optionsPath ~ '/options.js') }}
|
||||||
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
|
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
|
||||||
|
|
||||||
|
|
@ -524,7 +524,8 @@
|
||||||
<input type="color" name="{{ key }}_picker" data-value="{{ oParentOptions[key] }}"
|
<input type="color" name="{{ key }}_picker" data-value="{{ oParentOptions[key] }}"
|
||||||
{% if currentValue matches '/^#[0-9a-fA-F]{3,8}$/' %}value="{{ currentValue }}"{% endif %}
|
{% if currentValue matches '/^#[0-9a-fA-F]{3,8}$/' %}value="{{ currentValue }}"{% endif %}
|
||||||
{% if bChildDisabled %}disabled aria-disabled="true"{% endif %}
|
{% if bChildDisabled %}disabled aria-disabled="true"{% endif %}
|
||||||
class="selector__colorpicker-inherit-value"/>
|
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
|
||||||
|
class="selector__colorpicker-inherit-value{% if attr.parent != '' %} selector_radio_childfield{% endif %}"/>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" name="{{ key }}" data-inheritvalue="{{ oParentOptions[key] }}"
|
<input type="text" name="{{ key }}" data-inheritvalue="{{ oParentOptions[key] }}"
|
||||||
value="{% if currentValue != '' and currentValue != 'inherit' %}{{ currentValue }}{% endif %}"
|
value="{% if currentValue != '' and currentValue != 'inherit' %}{{ currentValue }}{% endif %}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue