Module: UI::ResponsiveDialogBehavior
- Included in:
- ResponsiveDialog, ResponsiveDialogComponent
- Defined in:
- app/behaviors/ui/responsive_dialog_behavior.rb
Overview
UI::ResponsiveDialogBehavior
Instance Method Summary collapse
-
#merged_responsive_dialog_data_attributes ⇒ Object
Merge user-provided data attributes.
-
#responsive_dialog_base_classes ⇒ Object
Base CSS classes.
-
#responsive_dialog_classes ⇒ Object
Generate final classes using TailwindMerge.
-
#responsive_dialog_data_attributes ⇒ Object
Generate data attributes for Stimulus controller.
-
#responsive_dialog_html_attributes ⇒ Object
Build complete HTML attributes hash.
Instance Method Details
#merged_responsive_dialog_data_attributes ⇒ Object
Merge user-provided data attributes
28 29 30 31 |
# File 'app/behaviors/ui/responsive_dialog_behavior.rb', line 28 def merged_responsive_dialog_data_attributes user_data = @attributes&.fetch(:data, {}) || {} user_data.merge(responsive_dialog_data_attributes) end |
#responsive_dialog_base_classes ⇒ Object
Base CSS classes
43 44 45 |
# File 'app/behaviors/ui/responsive_dialog_behavior.rb', line 43 def responsive_dialog_base_classes "" end |
#responsive_dialog_classes ⇒ Object
Generate final classes using TailwindMerge
48 49 50 |
# File 'app/behaviors/ui/responsive_dialog_behavior.rb', line 48 def responsive_dialog_classes TailwindMerge::Merger.new.merge([responsive_dialog_base_classes, @classes].compact.join(" ")) end |
#responsive_dialog_data_attributes ⇒ Object
Generate data attributes for Stimulus controller
19 20 21 22 23 24 25 |
# File 'app/behaviors/ui/responsive_dialog_behavior.rb', line 19 def responsive_dialog_data_attributes { controller: "ui--responsive-dialog", ui__responsive_dialog_open_value: @open, ui__responsive_dialog_breakpoint_value: @breakpoint || 768 } end |
#responsive_dialog_html_attributes ⇒ Object
Build complete HTML attributes hash
34 35 36 37 38 39 40 |
# File 'app/behaviors/ui/responsive_dialog_behavior.rb', line 34 def responsive_dialog_html_attributes base_attrs = @attributes&.except(:data) || {} base_attrs.merge( class: responsive_dialog_classes, data: merged_responsive_dialog_data_attributes ) end |