Module: UI::AlertDialogBehavior
- Included in:
- AlertDialog
- Defined in:
- app/behaviors/ui/alert_dialog_behavior.rb
Overview
UI::AlertDialogBehavior
Instance Method Summary collapse
-
#alert_dialog_base_classes ⇒ Object
Base CSS classes for alert dialog container.
-
#alert_dialog_classes ⇒ Object
Merge base classes with custom classes using TailwindMerge.
-
#alert_dialog_data_attributes ⇒ Object
Data attributes for Stimulus controller.
-
#alert_dialog_html_attributes ⇒ Object
Build complete HTML attributes hash for alert dialog container.
-
#merged_alert_dialog_data_attributes ⇒ Object
Merge user-provided data attributes.
Instance Method Details
#alert_dialog_base_classes ⇒ Object
Base CSS classes for alert dialog container
34 35 36 |
# File 'app/behaviors/ui/alert_dialog_behavior.rb', line 34 def alert_dialog_base_classes "" end |
#alert_dialog_classes ⇒ Object
Merge base classes with custom classes using TailwindMerge
39 40 41 |
# File 'app/behaviors/ui/alert_dialog_behavior.rb', line 39 def alert_dialog_classes TailwindMerge::Merger.new.merge([alert_dialog_base_classes, @classes].compact.join(" ")) end |
#alert_dialog_data_attributes ⇒ Object
Data attributes for Stimulus controller
44 45 46 47 48 49 50 |
# File 'app/behaviors/ui/alert_dialog_behavior.rb', line 44 def alert_dialog_data_attributes { controller: "ui--alert-dialog", ui__alert_dialog_open_value: @open, ui__alert_dialog_close_on_escape_value: @close_on_escape } end |
#alert_dialog_html_attributes ⇒ Object
Build complete HTML attributes hash for alert dialog container
59 60 61 62 63 64 65 |
# File 'app/behaviors/ui/alert_dialog_behavior.rb', line 59 def alert_dialog_html_attributes base_attrs = @attributes&.except(:data) || {} base_attrs.merge( class: alert_dialog_classes, data: merged_alert_dialog_data_attributes ) end |
#merged_alert_dialog_data_attributes ⇒ Object
Merge user-provided data attributes
53 54 55 56 |
# File 'app/behaviors/ui/alert_dialog_behavior.rb', line 53 def merged_alert_dialog_data_attributes user_data = @attributes&.fetch(:data, {}) || {} user_data.merge(alert_dialog_data_attributes) end |