Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/uui-color-swatches/lib/uui-color-swatches.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ export class UUIColorSwatchesElement extends LabelMixin('label', LitElement) {
value = '';

/**
* Disables the color swatches.
* Sets the swatches to disabled.
* @type {boolean}
* @attr
* @default false
**/
@property({ type: Boolean, reflect: true }) disabled = false;

/**
* Sets the swatches to readonly mode.
* @type {boolean}
* @attr
* @default false
*/
@property({ type: Boolean, reflect: true })
readonly: boolean = false;

@queryAssignedElements({ selector: 'uui-color-swatch' })
private readonly _swatches!: Array<UUIColorSwatchElement>;

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

if (this.readonly) {
swatch.setAttribute('readonly', '');
}

if (this.value !== '' && swatch.value === this.value) {
swatch.selected = true;
swatch.setAttribute('aria-checked', 'true');
Expand Down
6 changes: 6 additions & 0 deletions packages/uui-color-swatches/lib/uui-color-swatches.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export const Disabled: Story = {
},
};

export const Readonly: Story = {
args: {
readonly: true,
},
};

export const ShowLabel: Story = {
args: {
showLabel: true,
Expand Down
Loading