Module: UI::SliderTrackBehavior

Included in:
SliderTrack, SliderTrackComponent
Defined in:
app/behaviors/ui/slider_track_behavior.rb

Overview

Shared behavior for Slider Track component The track is the background rail that contains the range

Instance Method Summary collapse

Instance Method Details

#slider_track_html_attributesObject

Build complete HTML attributes hash for slider track



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/behaviors/ui/slider_track_behavior.rb', line 7

def slider_track_html_attributes
  base_attrs = @attributes&.except(:data) || {}
  user_data = @attributes&.fetch(:data, {}) || {}

  # Merge click action with user data
  track_data = {
    "ui--slider-target": "track",
    action: "click->ui--slider#clickTrack"
  }.merge(user_data)

  base_attrs.merge(
    class: "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5 #{@classes}".strip,
    "data-slot": "slider-track",
    data: track_data
  )
end