Improve rendering of color options

This commit is contained in:
Jeremy Stretch 2024-02-09 14:31:53 -05:00
parent a7ea105247
commit 053e02d4d7
3 changed files with 6 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -17,13 +17,16 @@ export function initStaticSelects(): void {
// Initialize color selection fields
export function initColorSelects(): void {
function renderColor(item: TomOption, escape: typeof escape_html) {
return `<div><span class="dropdown-item-indicator color-label" style="background-color: #${escape(item.value)}"></span> ${escape(item.text)}</div>`
}
for (const select of getElements<HTMLSelectElement>('select.color-select')) {
new TomSelect(select, {
...config,
render: {
option: function (item: TomOption, escape: typeof escape_html) {
return `<div style="background-color: #${escape(item.value)}">${escape(item.text)}</div>`;
},
option: renderColor,
item: renderColor,
},
});
}