Class: Shadcn::Slider::Thumb::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Slider::Thumb::Component
- Defined in:
- app/components/shadcn/slider/thumb/component.rb
Overview
The handle, and the only focusable thing in the component: role="slider"
with its own aria-valuenow, so a two-thumb range is two controls rather
than one with two numbers.
Positioning lives on a wrapper the root renders, not here — Radix does
the same, and it is what lets the thumb keep transition-[color,box-shadow]
without the position transitioning too.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #element_attributes(**defaults) ⇒ Object
-
#initialize(orientation: :horizontal, value: 0, min: 0, max: 100, disabled: false, index: 0, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(orientation: :horizontal, value: 0, min: 0, max: 100, disabled: false, index: 0, **attributes) ⇒ Component
Returns a new instance of Component.
28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/shadcn/slider/thumb/component.rb', line 28 def initialize(orientation: :horizontal, value: 0, min: 0, max: 100, disabled: false, index: 0, **attributes) @orientation = orientation @value = value @min = min @max = max @disabled = disabled @index = index super(**attributes) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
26 27 28 |
# File 'app/components/shadcn/slider/thumb/component.rb', line 26 def disabled @disabled end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
26 27 28 |
# File 'app/components/shadcn/slider/thumb/component.rb', line 26 def index @index end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
26 27 28 |
# File 'app/components/shadcn/slider/thumb/component.rb', line 26 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
26 27 28 |
# File 'app/components/shadcn/slider/thumb/component.rb', line 26 def min @min end |
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
26 27 28 |
# File 'app/components/shadcn/slider/thumb/component.rb', line 26 def orientation @orientation end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
26 27 28 |
# File 'app/components/shadcn/slider/thumb/component.rb', line 26 def value @value end |
Instance Method Details
#element_attributes(**defaults) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/components/shadcn/slider/thumb/component.rb', line 39 def element_attributes(**defaults) super(**{ role: "slider", tabindex: disabled ? -1 : 0, "aria-valuemin" => min, "aria-valuemax" => max, "aria-valuenow" => value, "aria-orientation" => orientation, "aria-disabled" => (disabled.presence && "true"), "data-orientation" => orientation, "data-index" => index, "data-shadcn--slider-target" => "thumb", "data-action" => "keydown->shadcn--slider#keydown " \ "pointerdown->shadcn--slider#thumbDown" }.compact.merge(defaults)) end |