Module: UI::DrawerHandleBehavior
- Included in:
- DrawerHandle, DrawerHandleComponent
- Defined in:
- app/behaviors/ui/drawer_handle_behavior.rb
Overview
Shared behavior for Drawer Handle component Visual affordance for drag gesture (shown on bottom/top drawers only)
Instance Method Summary collapse
-
#drawer_handle_classes ⇒ Object
Merge base classes with custom classes using TailwindMerge.
-
#drawer_handle_container_base_classes ⇒ Object
Base CSS classes for handle container.
-
#drawer_handle_data_attributes ⇒ Object
Data attributes for handle (Stimulus target only).
-
#drawer_handle_html_attributes ⇒ Object
Build complete HTML attributes hash for handle.
Instance Method Details
#drawer_handle_classes ⇒ Object
Merge base classes with custom classes using TailwindMerge
18 19 20 |
# File 'app/behaviors/ui/drawer_handle_behavior.rb', line 18 def drawer_handle_classes TailwindMerge::Merger.new.merge([drawer_handle_container_base_classes, @classes].compact.join(" ")) end |
#drawer_handle_container_base_classes ⇒ Object
Base CSS classes for handle container
9 10 11 12 13 14 15 |
# File 'app/behaviors/ui/drawer_handle_behavior.rb', line 9 def drawer_handle_container_base_classes [ "bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full", # Only show for bottom direction (matching shadcn/ui implementation) "group-data-[vaul-drawer-direction=bottom]/drawer-content:block" ].join(" ") end |
#drawer_handle_data_attributes ⇒ Object
Data attributes for handle (Stimulus target only)
23 24 25 26 27 28 |
# File 'app/behaviors/ui/drawer_handle_behavior.rb', line 23 def drawer_handle_data_attributes user_data = @attributes&.fetch(:data, {}) || {} user_data.merge({ ui__drawer_target: "handle" }) end |
#drawer_handle_html_attributes ⇒ Object
Build complete HTML attributes hash for handle
31 32 33 34 35 36 37 38 39 |
# File 'app/behaviors/ui/drawer_handle_behavior.rb', line 31 def drawer_handle_html_attributes base_attrs = @attributes&.except(:data) || {} base_attrs.merge( class: drawer_handle_classes, "aria-hidden": "true", "data-vaul-handle": "", data: drawer_handle_data_attributes ) end |