Class: UI::Slider
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- UI::Slider
- Includes:
- SliderBehavior
- Defined in:
- app/components/ui/slider.rb
Overview
Slider - Phlex implementation
A range slider component for selecting values within a range. Uses SliderBehavior module for shared logic.
Instance Method Summary collapse
-
#initialize(min: 0, max: 100, step: 1, value: nil, default_value: nil, center_point: nil, disabled: false, orientation: "horizontal", inverted: false, name: "", classes: "", attributes: {}) ⇒ Slider
constructor
A new instance of Slider.
- #view_template(&block) ⇒ Object
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, center_point: nil, disabled: false, orientation: "horizontal", inverted: false, name: "", classes: "", attributes: {}) ⇒ Slider
Returns a new instance of Slider.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/components/ui/slider.rb', line 39 def initialize( min: 0, max: 100, step: 1, value: nil, default_value: nil, center_point: nil, disabled: false, orientation: "horizontal", inverted: false, name: "", classes: "", attributes: {} ) @min = min @max = max @step = step @value = value @center_point = center_point @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
#view_template(&block) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/components/ui/slider.rb', line 67 def view_template(&block) all_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 |