Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit 657100e

Browse files
richarthiOvergaard
andauthored
Adds read-only mode to Color Picker Property Editor (#2451)
* Adds read-only mode to Color Picker Property Editor Implemented the read-only mode of the Color Picker Property Editor UI to close umbraco/Umbraco-CMS#17045. * feat: forward the `readonly` attribute to the swatch* elements * chore: rearrange properties in the element --------- Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
1 parent 60514c4 commit 657100e

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/packages/core/components/input-color/input-color.element.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export class UmbInputColorElement extends UUIFormControlMixin(UmbLitElement, '')
1515
return undefined;
1616
}
1717

18+
/**
19+
* Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
20+
* @attr
21+
* @default false
22+
*/
23+
@property({ type: Boolean, reflect: true })
24+
readonly = false;
25+
1826
@property({ type: Boolean })
1927
showLabels = false;
2028

@@ -28,7 +36,11 @@ export class UmbInputColorElement extends UUIFormControlMixin(UmbLitElement, '')
2836

2937
override render() {
3038
return html`
31-
<uui-color-swatches label="Color picker" value=${this.value ?? ''} @change=${this.#onChange}>
39+
<uui-color-swatches
40+
?readonly=${this.readonly}
41+
label="Color picker"
42+
value=${this.value ?? ''}
43+
@change=${this.#onChange}>
3244
${this.#renderColors()}
3345
</uui-color-swatches>
3446
`;
@@ -39,7 +51,11 @@ export class UmbInputColorElement extends UUIFormControlMixin(UmbLitElement, '')
3951
return map(
4052
this.swatches,
4153
(swatch) => html`
42-
<uui-color-swatch label=${swatch.label} value=${swatch.value} .showLabel=${this.showLabels}></uui-color-swatch>
54+
<uui-color-swatch
55+
?readonly=${this.readonly}
56+
label=${swatch.label}
57+
value=${swatch.value}
58+
.showLabel=${this.showLabels}></uui-color-swatch>
4359
`,
4460
);
4561
}

src/packages/property-editors/color-picker/manifests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const manifests: Array<UmbExtensionManifest> = [
1111
propertyEditorSchemaAlias: 'Umbraco.ColorPicker',
1212
icon: 'icon-colorpicker',
1313
group: 'pickers',
14+
supportsReadOnly: true,
1415
},
1516
},
1617
schemaManifest,

src/packages/property-editors/color-picker/property-editor-ui-color-picker.element.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ export class UmbPropertyEditorUIColorPickerElement extends UmbLitElement impleme
2525
}
2626
#value?: UmbSwatchDetails | undefined;
2727

28+
/**
29+
* Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
30+
* @type {boolean}
31+
* @attr
32+
* @default false
33+
*/
34+
@property({ type: Boolean, reflect: true })
35+
readonly = false;
36+
2837
@state()
2938
private _showLabels = this.#defaultShowLabels;
3039

@@ -59,7 +68,8 @@ export class UmbPropertyEditorUIColorPickerElement extends UmbLitElement impleme
5968
value=${this.value?.value ?? ''}
6069
.swatches=${this._swatches}
6170
?showLabels=${this._showLabels}
62-
@change=${this.#onChange}></umb-input-color>`;
71+
@change=${this.#onChange}
72+
?readonly=${this.readonly}></umb-input-color>`;
6373
}
6474
}
6575

0 commit comments

Comments
 (0)