Module: UI::ResizablePanelGroupBehavior
- Included in:
- ResizablePanelGroup, ResizablePanelGroupComponent
- Defined in:
- app/behaviors/ui/resizable_panel_group_behavior.rb
Overview
Shared behavior for ResizablePanelGroup container component Handles Stimulus controller setup and data attributes
Instance Method Summary collapse
-
#merged_panel_group_data_attributes ⇒ Object
Merge user-provided data attributes with panel group controller data.
-
#panel_group_base_classes ⇒ Object
Base CSS classes for the panel group container.
-
#panel_group_data_attributes ⇒ Object
Generate Stimulus controller data attributes.
-
#panel_group_html_attributes ⇒ Object
Build complete HTML attributes hash for panel group container.
Instance Method Details
#merged_panel_group_data_attributes ⇒ Object
Merge user-provided data attributes with panel group controller data
16 17 18 19 |
# File 'app/behaviors/ui/resizable_panel_group_behavior.rb', line 16 def merged_panel_group_data_attributes user_data = @attributes&.fetch(:data, {}) || {} user_data.merge(panel_group_data_attributes) end |
#panel_group_base_classes ⇒ Object
Base CSS classes for the panel group container
22 23 24 25 26 27 28 29 |
# File 'app/behaviors/ui/resizable_panel_group_behavior.rb', line 22 def panel_group_base_classes classes = [ "flex h-full w-full overflow-hidden", (@direction == "vertical") ? "flex-col" : "flex-row" ] classes << @classes if @classes.present? classes.join(" ") end |
#panel_group_data_attributes ⇒ Object
Generate Stimulus controller data attributes
7 8 9 10 11 12 13 |
# File 'app/behaviors/ui/resizable_panel_group_behavior.rb', line 7 def panel_group_data_attributes { controller: "ui--resizable", ui__resizable_direction_value: @direction || "horizontal", ui__resizable_keyboard_resize_by_value: @keyboard_resize_by || 10 } end |
#panel_group_html_attributes ⇒ Object
Build complete HTML attributes hash for panel group container
32 33 34 35 36 37 38 39 40 |
# File 'app/behaviors/ui/resizable_panel_group_behavior.rb', line 32 def panel_group_html_attributes base_attrs = @attributes&.except(:data) || {} base_attrs.merge( class: panel_group_base_classes, "data-panel-group-direction": @direction || "horizontal", "data-slot": "resizable-panel-group", data: merged_panel_group_data_attributes ) end |