Skip to content

Commit 8aab968

Browse files
leekelleheriOvergaard
authored andcommitted
fix(uui-color-picker): sets preview color of empty value to transparent
1 parent aa15fb6 commit 8aab968

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/uui-color-picker/lib/uui-color-picker.element.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
428428
}
429429

430430
private _renderColorPicker() {
431+
const previewColor = this.value
432+
? `hsla(${this.hue}deg, ${this.saturation}%, ${this.lightness}%, ${this.alpha / 100})`
433+
: 'transparent';
431434
return html`
432435
<div
433436
class=${classMap({
@@ -478,11 +481,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
478481
class="color-picker__preview color-picker__transparent-bg"
479482
title="Copy"
480483
aria-label="Copy"
481-
style=${styleMap({
482-
'--preview-color': `hsla(${this.hue}deg, ${this.saturation}%, ${
483-
this.lightness
484-
}%, ${this.alpha / 100})`,
485-
})}
484+
style=${styleMap({ '--preview-color': previewColor })}
486485
@click=${this.handleCopy}></button>
487486
</div>
488487
<div class="color-picker__user-input" aria-live="polite">
@@ -547,6 +546,9 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
547546
}
548547

549548
private _renderPreviewButton() {
549+
const previewColor = this.value
550+
? `hsla(${this.hue}deg, ${this.saturation}%, ${this.lightness}%, ${this.alpha / 100})`
551+
: 'transparent';
550552
return html`<button
551553
type="button"
552554
part="trigger"
@@ -559,11 +561,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
559561
'color-dropdown__trigger--large': this.size === 'large',
560562
'color-picker__transparent-bg': true,
561563
})}
562-
style=${styleMap({
563-
'--preview-color': `hsla(${this.hue}deg, ${this.saturation}%, ${
564-
this.lightness
565-
}%, ${this.alpha / 100})`,
566-
})}
564+
style=${styleMap({ '--preview-color': previewColor })}
567565
?disabled=${this.disabled}
568566
aria-haspopup="true"
569567
aria-expanded="false"

0 commit comments

Comments
 (0)