Skip to content

Commit d16c7ee

Browse files
committed
Disable color swatches
1 parent 94c1045 commit d16c7ee

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,9 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
652652
swatch =>
653653
html`<uui-color-swatch
654654
label="${swatch}"
655-
.value=${swatch}></uui-color-swatch>`
655+
.value=${swatch}
656+
?disabled=${this.disabled}>
657+
</uui-color-swatch>`
656658
)}
657659
</uui-color-swatches>`;
658660
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ export class UUIColorSwatchesElement extends LabelMixin('label', LitElement) {
3535
@property()
3636
value = '';
3737

38+
/**
39+
* Disables the color swatches.
40+
* @type {boolean}
41+
* @attr
42+
* @default false
43+
**/
44+
@property({ type: Boolean, reflect: true }) disabled = false;
45+
3846
@queryAssignedElements({ selector: 'uui-color-swatch' })
3947
swatches!: Array<UUIColorSwatchElement>;
4048

@@ -84,6 +92,10 @@ export class UUIColorSwatchesElement extends LabelMixin('label', LitElement) {
8492
swatch.setAttribute('aria-checked', 'false');
8593
swatch.setAttribute('role', 'radio');
8694

95+
if (this.disabled) {
96+
swatch.setAttribute('disabled', '')
97+
}
98+
8799
if (this.value !== '' && swatch.color?.isEqual(this.value)) {
88100
swatch.selected = true;
89101
swatch.setAttribute('aria-checked', 'true');

0 commit comments

Comments
 (0)