Add IconSelect grids for animation type and protocol selectors

Replace plain dropdowns with visual icon grids:
- Animation type (static/gradient CSS sources): icons for each effect
- WLED target protocol: DDP vs HTTP with descriptions
Add i18n keys for protocol options in all 3 locales.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 15:18:29 +03:00
parent 31a0f4b2ff
commit c431cb67b6
5 changed files with 73 additions and 25 deletions

View File

@@ -28,6 +28,8 @@ import {
ICON_WARNING, ICON_PALETTE, ICON_WRENCH, ICON_TEMPLATE,
} from '../core/icons.js';
import { EntitySelect } from '../core/entity-palette.js';
import { IconSelect } from '../core/icon-select.js';
import * as P from '../core/icon-paths.js';
import { wrapCard } from '../core/card-colors.js';
import { TagInput, renderTagChips } from '../core/tag-input.js';
import { CardSection } from '../core/card-sections.js';
@@ -246,6 +248,7 @@ function _updateBrightnessThresholdVisibility() {
let _deviceEntitySelect = null;
let _cssEntitySelect = null;
let _brightnessVsEntitySelect = null;
let _protocolIconSelect = null;
function _populateCssDropdown(selectedId = '') {
const select = document.getElementById('target-editor-css-source');
@@ -306,6 +309,19 @@ function _ensureTargetEntitySelects() {
});
}
const _pIcon = (d) => `<svg class="icon" viewBox="0 0 24 24">${d}</svg>`;
function _ensureProtocolIconSelect() {
const sel = document.getElementById('target-editor-protocol');
if (!sel) return;
const items = [
{ value: 'ddp', icon: _pIcon(P.radio), label: t('targets.protocol.ddp'), desc: t('targets.protocol.ddp.desc') },
{ value: 'http', icon: _pIcon(P.globe), label: t('targets.protocol.http'), desc: t('targets.protocol.http.desc') },
];
if (_protocolIconSelect) { _protocolIconSelect.updateItems(items); return; }
_protocolIconSelect = new IconSelect({ target: sel, items, columns: 2 });
}
export async function showTargetEditor(targetId = null, cloneData = null) {
try {
// Load devices, CSS sources, and value sources for dropdowns
@@ -402,6 +418,8 @@ export async function showTargetEditor(targetId = null, cloneData = null) {
// Entity palette selectors
_ensureTargetEntitySelects();
_ensureProtocolIconSelect();
if (_protocolIconSelect) _protocolIconSelect.setValue(document.getElementById('target-editor-protocol').value);
// Auto-name generation
_targetNameManuallyEdited = !!(targetId || cloneData);