Class: UI::SliderTrackComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
SliderTrackBehavior
Defined in:
app/view_components/ui/slider_track_component.rb

Overview

Slider Track component (ViewComponent) Background rail that contains the range

Examples:

Basic usage

<%= render UI::SliderTrackComponent.new do %>
  <%= render UI::SliderRangeComponent.new %>
<% end %>

Instance Method Summary collapse

Methods included from SliderTrackBehavior

#slider_track_html_attributes

Constructor Details

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

Returns a new instance of SliderTrackComponent.

Parameters:

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

    additional CSS classes

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

    additional HTML attributes



15
16
17
18
# File 'app/view_components/ui/slider_track_component.rb', line 15

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

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
# File 'app/view_components/ui/slider_track_component.rb', line 20

def call
  attrs = slider_track_html_attributes
  attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {}))

   :div, **attrs.merge(@attributes.except(:data)) do
    content
  end
end