Module: UI::ResizablePanelBehavior
- Included in:
- ResizablePanel, ResizablePanelComponent
- Defined in:
- app/behaviors/ui/resizable_panel_behavior.rb
Overview
UI::ResizablePanelBehavior
Instance Method Summary collapse
-
#merged_panel_data_attributes ⇒ Object
Merge user-provided data attributes with panel data.
-
#panel_base_classes ⇒ Object
Base CSS classes for the panel Uses min-w-0/min-h-0 and overflow-hidden to allow panels to shrink to 0.
-
#panel_data_attributes ⇒ Object
Generate data attributes for the panel.
-
#panel_html_attributes ⇒ Object
Build complete HTML attributes hash for panel.
Instance Method Details
#merged_panel_data_attributes ⇒ Object
Merge user-provided data attributes with panel data
33 34 35 36 |
# File 'app/behaviors/ui/resizable_panel_behavior.rb', line 33 def merged_panel_data_attributes user_data = @attributes&.fetch(:data, {}) || {} user_data.merge(panel_data_attributes) end |
#panel_base_classes ⇒ Object
Base CSS classes for the panel Uses min-w-0/min-h-0 and overflow-hidden to allow panels to shrink to 0
15 16 17 18 19 |
# File 'app/behaviors/ui/resizable_panel_behavior.rb', line 15 def panel_base_classes classes = ["relative overflow-hidden min-w-0 min-h-0"] classes << @classes if @classes.present? classes.join(" ") end |
#panel_data_attributes ⇒ Object
Generate data attributes for the panel
22 23 24 25 26 27 28 29 30 |
# File 'app/behaviors/ui/resizable_panel_behavior.rb', line 22 def panel_data_attributes attrs = { ui__resizable_target: "panel" } attrs[:default_size] = @default_size if @default_size attrs[:min_size] = @min_size if @min_size attrs[:max_size] = @max_size if @max_size attrs end |
#panel_html_attributes ⇒ Object
Build complete HTML attributes hash for panel
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/behaviors/ui/resizable_panel_behavior.rb', line 39 def panel_html_attributes base_attrs = @attributes&.except(:data) || {} # Use flex-grow for proportional sizing instead of flex-basis percentage # This works correctly with min-height containers in vertical layouts style_parts = [] if @default_size style_parts << "flex-grow: #{@default_size}" style_parts << "flex-shrink: #{@default_size}" style_parts << "flex-basis: 0" end attrs = base_attrs.merge( class: panel_base_classes, "data-slot": "resizable-panel", data: merged_panel_data_attributes ) attrs[:style] = style_parts.join("; ") if style_parts.any? attrs end |