Skip to content

Commit

Permalink
Make handle opacity based on alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarnef committed Sep 28, 2023
1 parent dd34062 commit 6468c60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
14 changes: 3 additions & 11 deletions packages/uui-color-area/lib/uui-color-area.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,31 +146,23 @@ export class UUIColorAreaElement extends LitElement {
this._value = newVal;
this.requestUpdate('value', oldVal);

console.log("newVal", newVal);

try {
// TODO: Can we move the parsing of a color string to shared utility function?
const parsed = colord(newVal);

if (parsed.isValid()) {
const { h, s, l } = parsed.toHsl();
const { h, s, l, a } = parsed.toHsl();

console.log("h, s, l", h, s, l);
console.log("h, s, l, a", h, s, l, a);

// Test
if (s === 0) {
console.log("parsed", parsed.toHsl());
}

if (h !== 0) {
this.hue = h;
}

console.log("hue", this.hue);

//this.saturation = s;
this.lightness = l;
this.brightness = this.getBrightness(l);
this.alpha = a * 100;
}
} catch (e) {
console.log("value err", e);
Expand Down
5 changes: 2 additions & 3 deletions packages/uui-color-picker/lib/uui-color-picker.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
this._swatches?.resetSelection();
const element = event.target as UUIColorSliderElement;

console.log("handleHueChange", element.value);

const newColor: HslaColor = {
h: element.value,
s: this.saturation,
Expand Down Expand Up @@ -684,7 +682,8 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
swatch =>
html`<uui-color-swatch
label="${swatch}"
.value=${swatch}></uui-color-swatch>`
.value=${swatch}>
</uui-color-swatch>`
)}
</uui-color-swatches>`;
}
Expand Down

0 comments on commit 6468c60

Please sign in to comment.