From 7861e78d1c03b5a7107f95234332d712386e9705 Mon Sep 17 00:00:00 2001 From: Dariusz Dawidowski Date: Fri, 13 Sep 2024 15:20:35 +0200 Subject: [PATCH] Color picker: show current calue. --- controls/popovers/color-picker.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/controls/popovers/color-picker.js b/controls/popovers/color-picker.js index 174bd0d..d12b6a4 100644 --- a/controls/popovers/color-picker.js +++ b/controls/popovers/color-picker.js @@ -16,12 +16,12 @@ class MetavizPopoverColorPicker { constructor(args) { - const { options = [], value = 0, onChange = null } = args; + const { options = ['var(--paper-2)'], value = 0, onChange = null } = args; // Icon this.element = document.createElement('span'); this.element.classList.add('toolbar-action', 'circle'); - this.element.style.background = 'var(--paper-2)'; + this.element.style.background = options[value]; // Cloud const cloud = document.createElement('div'); @@ -42,7 +42,9 @@ class MetavizPopoverColorPicker { color.style.background = option; color.dataset.value = nr; if (onChange) color.addEventListener('click', () => { - onChange(parseInt(color.dataset.value)); + const val = parseInt(color.dataset.value); + this.element.style.background = options[val]; + onChange(val); }); cloud.append(color); nr ++;