Class: Shadcn::ScrollArea::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::ScrollArea::Component
- Defined in:
- app/components/shadcn/scroll_area/component.rb
Overview
Port of registry/new-york-v4/ui/scroll-area.tsx, whose behaviour is Radix's
ScrollArea — 1,189 lines against shadcn's 58, and vendored at
vendor/radix/ui/scroll-area.tsx.
Like shadcn's own, this composes the whole thing rather than exposing the
parts: the viewport, one scrollbar per requested axis, and the corner where
two of them meet. orientation: is this port's way of asking for the
second bar, which shadcn does by passing a second <ScrollBar> as a child
— a shape that relies on React's Slottable to hoist it out of the viewport
and has no counterpart here.
Two of Radix's four type strategies are reproduced: hover, its default,
and always. See features/scroll-area.md.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
-
#scroll_hide_delay ⇒ Object
readonly
Returns the value of attribute scroll_hide_delay.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(orientation: :vertical, type: :hover, scroll_hide_delay: 600, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(orientation: :vertical, type: :hover, scroll_hide_delay: 600, **attributes) ⇒ Component
Returns a new instance of Component.
27 28 29 30 31 32 |
# File 'app/components/shadcn/scroll_area/component.rb', line 27 def initialize(orientation: :vertical, type: :hover, scroll_hide_delay: 600, **attributes) @orientation = orientation&.to_sym || :vertical @type = type&.to_sym || :hover @scroll_hide_delay = scroll_hide_delay super(**attributes) end |
Instance Attribute Details
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
25 26 27 |
# File 'app/components/shadcn/scroll_area/component.rb', line 25 def orientation @orientation end |
#scroll_hide_delay ⇒ Object (readonly)
Returns the value of attribute scroll_hide_delay.
25 26 27 |
# File 'app/components/shadcn/scroll_area/component.rb', line 25 def scroll_hide_delay @scroll_hide_delay end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
25 26 27 |
# File 'app/components/shadcn/scroll_area/component.rb', line 25 def type @type end |
Instance Method Details
#call ⇒ Object
44 45 46 |
# File 'app/components/shadcn/scroll_area/component.rb', line 44 def call render_element(body: safe_join([ , *, corner ].compact)) end |
#element_attributes(**defaults) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/components/shadcn/scroll_area/component.rb', line 34 def element_attributes(**defaults) super(**{ "data-controller" => "shadcn--scroll-area", "data-shadcn--scroll-area-type-value" => type, "data-shadcn--scroll-area-hide-delay-value" => scroll_hide_delay, "data-action" => "pointerenter->shadcn--scroll-area#pointerEnter " \ "pointerleave->shadcn--scroll-area#pointerLeave" }.merge(defaults)) end |