Class: UI::SliderComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::SliderComponent
- Includes:
- SliderBehavior
- Defined in:
- app/view_components/ui/slider_component.rb
Overview
Slider container component (ViewComponent) Root component for range slider with keyboard navigation
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(min: 0, max: 100, step: 1, value: nil, default_value: nil, disabled: false, orientation: "horizontal", inverted: false, name: "", center_point: nil, classes: "", attributes: {}) ⇒ SliderComponent
constructor
A new instance of SliderComponent.
Methods included from SliderBehavior
#merged_data_attributes, #slider_data_attributes, #slider_html_attributes
Constructor Details
#initialize(min: 0, max: 100, step: 1, value: nil, default_value: nil, disabled: false, orientation: "horizontal", inverted: false, name: "", center_point: nil, classes: "", attributes: {}) ⇒ SliderComponent
Returns a new instance of SliderComponent.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/view_components/ui/slider_component.rb', line 37 def initialize(min: 0, max: 100, step: 1, value: nil, default_value: nil, disabled: false, orientation: "horizontal", inverted: false, name: "", center_point: nil, classes: "", attributes: {}) @min = min @max = max @step = step @value = value @center_point = center_point # If center_point is defined and no default_value provided, start at center @default_value = default_value || (center_point ? [center_point] : [min]) @disabled = disabled @orientation = orientation @inverted = inverted @name = name @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'app/view_components/ui/slider_component.rb', line 53 def call attrs = attrs[:data] = attrs[:data].merge(@attributes.fetch(:data, {})) content_tag :div, **attrs.merge(@attributes.except(:data)) do content end end |