diff --git a/etc/lime-elements.api.md b/etc/lime-elements.api.md index 24412c5839..d8e2dc4373 100644 --- a/etc/lime-elements.api.md +++ b/etc/lime-elements.api.md @@ -663,8 +663,10 @@ export namespace Components { "disabled": boolean; "factor": number; "helperText": string; + "invalid": boolean; "label": string; "readonly": boolean; + "required": boolean; "step": number; "unit": string; "value": number; @@ -1784,9 +1786,11 @@ export namespace JSX { "disabled"?: boolean; "factor"?: number; "helperText"?: string; + "invalid"?: boolean; "label"?: string; "onChange"?: (event: LimelSliderCustomEvent) => void; "readonly"?: boolean; + "required"?: boolean; "step"?: number; "unit"?: string; "value"?: number; diff --git a/src/components/slider/slider.scss b/src/components/slider/slider.scss index 2bac06bacc..b708924187 100644 --- a/src/components/slider/slider.scss +++ b/src/components/slider/slider.scss @@ -5,14 +5,30 @@ @use '../../style/internal/lime-theme'; @use '@material/slider/styles'; -@use '@material/floating-label/mdc-floating-label'; :host(limel-slider) { isolation: isolate; position: relative; + display: flex; + flex-direction: column; +} + +:host(limel-slider:not([invalid]):not([invalid='true'])), +// We don't want the gray notched outlines around the slider by default +:host(limel-slider[disabled]:not([disabled='false'])) { + .limel-notched-outline { + --limel-notched-outline-border-color: transparent; + --limel-notched-outline-background-color: transparent; + } + // and we don't want the `disabled` but `invalid` slider to show any + // red lines. Since users cannot do anything to fix a disabled but invalid slider +} +div[slot='content'] { display: flex; flex-direction: column; + width: 100%; + padding: 0 0.25rem; } .mdc-slider { @@ -20,7 +36,6 @@ margin: 0 0.75rem; } -.mdc-floating-label, .mdc-slider .mdc-slider__value-indicator-text { // As long as this component is depended on MDC, // we need to force it to be font-agnostic. @@ -31,16 +46,6 @@ font-family: inherit; } -.slider__label { - padding-left: functions.pxToRem(20); - top: 0.75rem; // To place its label on the same height as other `floating-label`s in a form - - color: shared_input-select-picker.$label-color; - :host(limel-slider.disabled:not(.readonly)) & { - color: shared_input-select-picker.$label-color-disabled; - } -} - .slider__content-range-container { display: flex; order: 2; diff --git a/src/components/slider/slider.tsx b/src/components/slider/slider.tsx index 776dccd57b..baca61269a 100644 --- a/src/components/slider/slider.tsx +++ b/src/components/slider/slider.tsx @@ -67,6 +67,18 @@ export class Slider { @Prop({ reflect: true }) public helperText: string; + /** + * Set to `true` to indicate that the slider is required. + */ + @Prop({ reflect: true }) + public required = false; + + /** + * Set to `true` to indicate that the current value of the slider is invalid. + */ + @Prop({ reflect: true }) + public invalid = false; + /** * Unit to display next to the value */ @@ -150,60 +162,21 @@ export class Slider { return ( - -
- - {this.multiplyByFactor(this.valuemin)} - {this.unit} - - - {this.multiplyByFactor(this.valuemax)} - {this.unit} - -
-
- -
-
-
-
-
-
-
- -
+
+ {this.renderRangeContainer()} + {this.renderSliderContainer(inputProps)}
-
+ {this.renderHelperLine()} ); @@ -240,6 +213,82 @@ export class Slider { this.reCreateSliderWithStep(); } + private renderRangeContainer = () => { + return ( +
+ + {this.multiplyByFactor(this.valuemin)} + {this.unit} + + + {this.multiplyByFactor(this.valuemax)} + {this.unit} + +
+ ); + }; + + private renderSliderContainer = (inputProps: any) => { + return ( +
+ {this.renderSliderInput(inputProps)} + {this.renderTrack()} + {this.renderThumb()} +
+ ); + }; + + private renderSliderInput = (inputProps: any) => { + return ( + + ); + }; + + private renderTrack = () => { + return ( +
+
+
+
+
+
+ ); + }; + + private renderThumb = () => { + return ( +
+ +
+
+ ); + }; + private renderHelperLine = () => { if (!this.helperText) { return; @@ -249,6 +298,7 @@ export class Slider { ); };