From f5624fbf4a44582f983207f07960d12945c83028 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 14 Jul 2025 16:05:02 -0400 Subject: [PATCH] Slider hint (#1174) * update example * show hint in correct position when present * update example * update example --- .../webawesome/docs/docs/components/slider.md | 25 ++++++++++++------ .../docs/docs/resources/changelog.md | 6 ++++- .../src/components/slider/slider.ts | 26 +++++++++++++------ 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/packages/webawesome/docs/docs/components/slider.md b/packages/webawesome/docs/docs/components/slider.md index 3db02b645..5b0bb6b28 100644 --- a/packages/webawesome/docs/docs/components/slider.md +++ b/packages/webawesome/docs/docs/components/slider.md @@ -7,8 +7,8 @@ category: Form Controls ```html {.example} + ``` ### Showing tooltips @@ -72,7 +72,15 @@ Use the `with-markers` attribute to display visual indicators at each step incre Use the `reference` slot to add contextual labels below the slider. References are automatically spaced using `space-between`, making them easy to align with the start, center, and end positions. ```html {.example} - + Slow Medium Fast @@ -249,8 +257,8 @@ By default, the filled indicator extends from the minimum value to the current p ```html {.example} - Lazy - Zoomies + Easy + Moderate + Difficult ``` diff --git a/packages/webawesome/docs/docs/resources/changelog.md b/packages/webawesome/docs/docs/resources/changelog.md index f24c96517..3f067140c 100644 --- a/packages/webawesome/docs/docs/resources/changelog.md +++ b/packages/webawesome/docs/docs/resources/changelog.md @@ -8,6 +8,10 @@ Web Awesome follows [Semantic Versioning](https://semver.org/). Breaking changes Components with the Experimental badge should not be used in production. They are made available as release candidates for development and testing purposes. As such, changes to experimental components will not be subject to semantic versioning. +## Next + +- Fixed a bug in `` that prevented the hint from showing up + ## 3.0.0-beta.2 ### New Features {data-no-outline} @@ -375,4 +379,4 @@ Many of these changes and improvements were the direct result of feedback from u -Did we miss something? [Let us know!](https://github.com/shoelace-style/webawesome-alpha/discussions) \ No newline at end of file +Did we miss something? [Let us know!](https://github.com/shoelace-style/webawesome-alpha/discussions) diff --git a/packages/webawesome/src/components/slider/slider.ts b/packages/webawesome/src/components/slider/slider.ts index 0341c862c..5bd393564 100644 --- a/packages/webawesome/src/components/slider/slider.ts +++ b/packages/webawesome/src/components/slider/slider.ts @@ -769,8 +769,10 @@ export default class WaSlider extends WebAwesomeFormAssociatedElement { } render() { - const hasLabel = this.hasSlotController.test('label'); - const hasHint = this.hasSlotController.test('hint'); + const hasLabelSlot = this.hasSlotController.test('label'); + const hasHintSlot = this.hasSlotController.test('hint'); + const hasLabel = this.label ? true : !!hasLabelSlot; + const hasHint = this.hint ? true : !!hasHintSlot; const hasReference = this.hasSlotController.test('reference'); const sliderClasses = classMap({ @@ -791,7 +793,7 @@ export default class WaSlider extends WebAwesomeFormAssociatedElement { } // Common UI fragments - const labelAndHint = html` + const label = html` + `; -
+ const hint = html` +
${this.hint}
`; @@ -856,7 +866,7 @@ export default class WaSlider extends WebAwesomeFormAssociatedElement { const maxThumbPosition = clamp(this.getPercentageFromValue(this.maxValue), 0, 100); return html` - ${labelAndHint} + ${label}
@@ -914,7 +924,7 @@ export default class WaSlider extends WebAwesomeFormAssociatedElement { >
- ${referencesTemplate} + ${referencesTemplate} ${hint}
${createTooltip('thumb-min', this.minValue)} ${createTooltip('thumb-max', this.maxValue)} @@ -929,7 +939,7 @@ export default class WaSlider extends WebAwesomeFormAssociatedElement { ); return html` - ${labelAndHint} + ${label}
- ${referencesTemplate} + ${referencesTemplate} ${hint}
${createTooltip('thumb', this.value)}