Skip to content

Commit

Permalink
Color picker: show current calue.
Browse files Browse the repository at this point in the history
  • Loading branch information
dariuszdawidowski committed Sep 13, 2024
1 parent 2fda38b commit 7861e78
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions controls/popovers/color-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 ++;
Expand Down

0 comments on commit 7861e78

Please sign in to comment.