Skip to content

Commit e35daff

Browse files
authored
feat(uui-color-swatches): Add readonly to color swatches component (#932)
1 parent a7ca074 commit e35daff

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,22 @@ export class UUIColorSwatchesElement extends LabelMixin('label', LitElement) {
2626
value = '';
2727

2828
/**
29-
* Disables the color swatches.
29+
* Sets the swatches to disabled.
3030
* @type {boolean}
3131
* @attr
3232
* @default false
3333
**/
3434
@property({ type: Boolean, reflect: true }) disabled = false;
3535

36+
/**
37+
* Sets the swatches to readonly mode.
38+
* @type {boolean}
39+
* @attr
40+
* @default false
41+
*/
42+
@property({ type: Boolean, reflect: true })
43+
readonly: boolean = false;
44+
3645
@queryAssignedElements({ selector: 'uui-color-swatch' })
3746
private readonly _swatches!: Array<UUIColorSwatchElement>;
3847

@@ -86,6 +95,10 @@ export class UUIColorSwatchesElement extends LabelMixin('label', LitElement) {
8695
swatch.setAttribute('selectable', 'selectable');
8796
}
8897

98+
if (this.readonly) {
99+
swatch.setAttribute('readonly', '');
100+
}
101+
89102
if (this.value !== '' && swatch.value === this.value) {
90103
swatch.selected = true;
91104
swatch.setAttribute('aria-checked', 'true');

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

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ export const Disabled: Story = {
6060
},
6161
};
6262

63+
export const Readonly: Story = {
64+
args: {
65+
readonly: true,
66+
},
67+
};
68+
6369
export const ShowLabel: Story = {
6470
args: {
6571
showLabel: true,

0 commit comments

Comments
 (0)