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
17 changes: 15 additions & 2 deletions packages/uui-color-picker/lib/uui-color-picker.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
@property({ type: Boolean, reflect: true }) inline = false;

/**
* Disables the color picker.
* Sets the color picker to disabled.
* @attr
* @type {boolean}
* @default false
Expand All @@ -153,6 +153,14 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
**/
@property({ type: Boolean }) opacity = false;

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

/**
* By default, the value will be set in lowercase. Set this to true to set it in uppercase instead.
* @attr
Expand Down Expand Up @@ -433,6 +441,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
.value="${this.value}"
.hue="${Math.round(this.hue)}"
?disabled=${this.disabled}
?readonly=${this.readonly}
@change=${this.handleGridChange}>
</uui-color-area>
<div class="color-picker__controls">
Expand All @@ -442,6 +451,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
class="hue-slider"
.value=${Math.round(this.hue)}
?disabled=${this.disabled}
?readonly=${this.readonly}
@change=${this.handleHueChange}>
</uui-color-slider>
${this.opacity
Expand All @@ -457,6 +467,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
this.lightness,
)}
?disabled=${this.disabled}
?readonly=${this.readonly}
@change=${this.handleAlphaChange}>
</uui-color-slider>
`
Expand Down Expand Up @@ -486,6 +497,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
spellcheck="false"
.value=${live(this.inputValue)}
?disabled=${this.disabled}
?readonly=${this.readonly}
@keydown=${this.handleInputKeyDown}
@change=${this.handleInputChange}>
</uui-input>
Expand All @@ -503,7 +515,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
${hasEyeDropper
? html`<uui-button
label="Select a color"
?disabled=${this.disabled}
?disabled=${this.disabled || this.readonly}
@click=${this.handleEyeDropper}
compact>
<uui-icon-registry-essential>
Expand All @@ -525,6 +537,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) {
class="color-picker__swatches"
label="Swatches"
?disabled=${this.disabled}
?readonly=${this.readonly}
@change=${this.handleColorSwatchChange}>
${this.swatches.map(
swatch =>
Expand Down
12 changes: 9 additions & 3 deletions packages/uui-color-picker/lib/uui-color-picker.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ export const Disabled: Story = {
},
};

export const Formats: Story = {
args: {
format: 'hex',
inline: true,
},
};

export const Inline: Story = {
args: {
inline: true,
Expand All @@ -70,9 +77,8 @@ export const Opacity: Story = {
},
};

export const Formats: Story = {
export const Readonly: Story = {
args: {
format: 'hex',
inline: true,
readonly: true,
},
};
Loading