Skip to content

Enhance slider functionality with dynamic ranges, colors, and updates#310

Merged
snootched merged 11 commits intomainfrom
dev
Mar 29, 2026
Merged

Enhance slider functionality with dynamic ranges, colors, and updates#310
snootched merged 11 commits intomainfrom
dev

Conversation

@snootched
Copy link
Copy Markdown
Owner

No description provided.

- Add _resolveRangeBounds(): resolves template min/max for band ranges
- Add _resolveRangeColor(): routes object configs through resolveStateColor(),
  strings through _resolveColorValue(); coerces result to string for SVG attrs
- Add _extractRangeEntityDependencies(): scans range templates for external
  entity refs (token + JS bracket syntax), stores in _rangeTemplateEntities
- Override _shouldUpdateOnHassChange(): also watches _rangeTemplateEntities
  so external entity changes trigger re-renders without a page refresh
- Move _resolveMarkerValues() outside primary-entity guard in _handleHassUpdate
  so cards with no entity but dynamic range templates also respond
- Update all four rendering paths (getPillColor, markerPillMap, _generateGaugeBandRanges,
  _generateShapedRangeBands, gauge inline path) to use resolved bounds + _resolveRangeColor
- Update pills memoization hash to include _resolvedRangeBounds
- Schema: ranges[].min/max accept string templates; ranges[].color accepts
  stateColorSchema (object form for state-aware syntax)
- Base: _shouldUpdateOnHassChange JSDoc @Private@Protected to allow override
…rrectness

- Fix getPillColor(): when _invertFill is true, mirror the pillValue calculation
  (displayMax - valuePercent*displayRange) so band ranges color the pills that
  visually correspond to their value positions, consistent with the swapped
  gradient and reversed fill direction in _updatePillOpacities
- Fix pills memoization hash: append entity state + classified button state so
  state-aware range colors (e.g. { active: red, inactive: gray }) bust the cache
  on entity state change without requiring a page refresh
…ent (Group 3)

- background.min/max now clamp extent in _generateProgressBar() zone renderer
- background.radius {start,end} object form available in editor (per-end fields)
- fill bar radius field replaced with radius.start/end per-end fields in editor
- editor: Progress Bar section groups Fill and Background Track as collapsible sub-sections
- horizontal input overlay constrained to control-range footprint in display space
- vertical drag overlay constrained to control-range band; value handlers simplified
… template support

- Gauge memoization hash: add classifiedState, resolvedMarkerValues, resolvedRangeBounds
  so state-driven range colors and template-bound range extents correctly bust the cache

- Per-band pill opacity (#12): add getRangeOpacity() alongside getPillColor() in
  _generatePillsSVG(); embed resolved opacity as data-unfilled-opacity on each pill
  rect; _updatePillOpacities() reads per-pill opacity so band-specific opacity values
  are honoured during live updates

- Attribute template support (#9): new _resolveControlAttribute() method handles
  {entity.attributes.xxx}, {entity.state}, and [[[JS]]] templates; used in
  _getEntityValue() so the slider can read from a dynamically-resolved attribute name

- Open GitHub issue #309 for Group 7 #10 drag interaction visual state (deferred)
- Bump version to 2026.03.29.1
- Upgrade jsdom from 27.1.0 to 29.0.1
- Upgrade custom-card-helpers from 1.9.0 to 2.0.0
@snootched snootched merged commit 469c73f into main Mar 29, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant