@@ -84,12 +84,22 @@ export class UUIColorSliderElement extends LabelMixin('label', LitElement) {
84
84
@property ( ) value = 0 ;
85
85
86
86
/**
87
- * Disables the color slider.
87
+ * Sets the color slider to readonly mode.
88
+ * @type {boolean }
89
+ * @attr
90
+ * @default false
91
+ */
92
+ @property ( { type : Boolean , reflect : true } )
93
+ readonly = false ;
94
+
95
+ /**
96
+ * Sets the color slider to disabled.
88
97
* @type {boolean }
89
98
* @attr
90
99
* @default false
91
100
**/
92
- @property ( { type : Boolean , reflect : true } ) disabled = false ;
101
+ @property ( { type : Boolean , reflect : true } )
102
+ disabled = false ;
93
103
94
104
private container ! : HTMLElement ;
95
105
private handle ! : HTMLElement ;
@@ -115,7 +125,8 @@ export class UUIColorSliderElement extends LabelMixin('label', LitElement) {
115
125
}
116
126
117
127
handleDrag ( event : PointerEvent ) {
118
- if ( this . disabled || ! this . container || ! this . handle ) return ;
128
+ if ( this . disabled || this . readonly || ! this . container || ! this . handle )
129
+ return ;
119
130
120
131
const { width, height } = this . container . getBoundingClientRect ( ) ;
121
132
@@ -140,7 +151,7 @@ export class UUIColorSliderElement extends LabelMixin('label', LitElement) {
140
151
}
141
152
142
153
handleClick ( event : MouseEvent ) {
143
- if ( this . disabled ) return ;
154
+ if ( this . disabled || this . readonly ) return ;
144
155
145
156
this . value = this . getValueFromMousePosition ( event ) ;
146
157
this . syncValues ( ) ;
@@ -258,7 +269,8 @@ export class UUIColorSliderElement extends LabelMixin('label', LitElement) {
258
269
<span
259
270
id= "color-slider__handle"
260
271
style = "--current-value: ${ this . cssPropCurrentValue } %;"
261
- tabindex = ${ ifDefined ( this . disabled ? undefined : '0' ) } > </ span>
272
+ tabindex = ${ ifDefined ( this . disabled ? undefined : '0' ) } >
273
+ </ span>
262
274
</ div>
263
275
${ Math . round ( this . value ) } ` ;
264
276
}
@@ -340,6 +352,14 @@ export class UUIColorSliderElement extends LabelMixin('label', LitElement) {
340
352
opacity : 0.55 ;
341
353
}
342
354
355
+ : host ([readonly ]) {
356
+ cursor : default;
357
+ }
358
+
359
+ : host ([readonly ]) # color-slider {
360
+ pointer-events : none;
361
+ }
362
+
343
363
# color-slider__handle {
344
364
position : absolute;
345
365
top : calc (50% - var (--uui-slider-handle-size ) / 2 );
0 commit comments