Class: Shadcn::Resizable::Handle::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Resizable::Handle::Component
- Defined in:
- app/components/shadcn/resizable/handle/component.rb
Overview
The bar between two panels: a role="separator" that can be dragged and
driven from the keyboard.
Its own orientation is the opposite of the group's — a row of panels
is divided by a vertical line — and role="separator" defaults to
horizontal, so the attribute is always written rather than left out.
Constant Summary collapse
- GRIP_CLASSES =
"z-10 flex h-4 w-3 items-center justify-center rounded-xs border bg-border"
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#orientation ⇒ Object
readonly
Returns the value of attribute orientation.
-
#with_handle ⇒ Object
readonly
Returns the value of attribute with_handle.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(with_handle: false, orientation: :horizontal, disabled: false, **attributes) ⇒ Component
constructor
with_handle:is upstream'swithHandle: the grip a pointer can see, which is off by default there too.
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(with_handle: false, orientation: :horizontal, disabled: false, **attributes) ⇒ Component
with_handle: is upstream's withHandle: the grip a pointer can see,
which is off by default there too.
35 36 37 38 39 40 |
# File 'app/components/shadcn/resizable/handle/component.rb', line 35 def initialize(with_handle: false, orientation: :horizontal, disabled: false, **attributes) @with_handle = with_handle @orientation = orientation&.to_sym == :vertical ? :vertical : :horizontal @disabled = disabled super(**attributes) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
31 32 33 |
# File 'app/components/shadcn/resizable/handle/component.rb', line 31 def disabled @disabled end |
#orientation ⇒ Object (readonly)
Returns the value of attribute orientation.
31 32 33 |
# File 'app/components/shadcn/resizable/handle/component.rb', line 31 def orientation @orientation end |
#with_handle ⇒ Object (readonly)
Returns the value of attribute with_handle.
31 32 33 |
# File 'app/components/shadcn/resizable/handle/component.rb', line 31 def with_handle @with_handle end |
Instance Method Details
#call ⇒ Object
56 57 58 |
# File 'app/components/shadcn/resizable/handle/component.rb', line 56 def call render_element(body: grip) end |
#element_attributes(**defaults) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/components/shadcn/resizable/handle/component.rb', line 42 def element_attributes(**defaults) super(**{ role: "separator", # The group's orientation decides the separator's, inverted. "aria-orientation" => orientation == :vertical ? "horizontal" : "vertical", "aria-disabled" => (disabled.presence && "true"), tabindex: (disabled ? "-1" : "0"), "data-separator" => "inactive", "data-shadcn--resizable-target" => "handle", "data-action" => "pointerdown->shadcn--resizable#press keydown->shadcn--resizable#keydown", style: merged_style("flex-basis:auto;flex-grow:0;flex-shrink:0") }.compact.merge(defaults)) end |