Class: UI::SliderTrack

Inherits:
Phlex::HTML
  • Object
show all
Includes:
SliderTrackBehavior
Defined in:
app/components/ui/slider_track.rb

Overview

SliderTrack - Phlex implementation

The track is the background rail that contains the range. Uses SliderTrackBehavior module for shared logic.

Examples:

Basic usage

render UI::SliderTrack.new do
  render UI::SliderRange.new
end

Instance Method Summary collapse

Methods included from SliderTrackBehavior

#slider_track_html_attributes

Constructor Details

#initialize(classes: "", attributes: {}) ⇒ SliderTrack

Returns a new instance of SliderTrack.

Parameters:

  • classes (String) (defaults to: "")

    Additional CSS classes

  • attributes (Hash) (defaults to: {})

    Additional HTML attributes



17
18
19
20
# File 'app/components/ui/slider_track.rb', line 17

def initialize(classes: "", attributes: {})
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/components/ui/slider_track.rb', line 22

def view_template(&block)
  all_attributes = slider_track_html_attributes

  # Merge data attributes
  all_attributes[:data] = all_attributes[:data].merge(@attributes.fetch(:data, {}))

  # Merge with user attributes (except data which we already handled)
  all_attributes = all_attributes.merge(@attributes.except(:data))

  div(**all_attributes) do
    yield if block_given?
  end
end