Module: UI::AlertDialogContentBehavior
- Included in:
- AlertDialogContent
- Defined in:
- app/behaviors/ui/alert_dialog_content_behavior.rb
Overview
Shared behavior for AlertDialog Content component Handles content area styling, ARIA attributes, and animations
Instance Method Summary collapse
-
#alert_dialog_content_base_classes ⇒ Object
Base CSS classes for alert dialog content Use opacity-0/scale-95 and pointer-events-none when closed for smooth animations.
-
#alert_dialog_content_classes ⇒ Object
Merge base classes with custom classes using TailwindMerge.
-
#alert_dialog_content_data_attributes ⇒ Object
Data attributes for Stimulus target.
-
#alert_dialog_content_html_attributes ⇒ Object
Build complete HTML attributes hash for alert dialog content.
-
#merged_alert_dialog_content_data_attributes ⇒ Object
Merge user-provided data attributes.
Instance Method Details
#alert_dialog_content_base_classes ⇒ Object
Base CSS classes for alert dialog content Use opacity-0/scale-95 and pointer-events-none when closed for smooth animations
10 11 12 |
# File 'app/behaviors/ui/alert_dialog_content_behavior.rb', line 10 def alert_dialog_content_base_classes "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:opacity-0 data-[state=open]:opacity-100 data-[state=open]:pointer-events-auto data-[state=closed]:pointer-events-none fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg" end |
#alert_dialog_content_classes ⇒ Object
Merge base classes with custom classes using TailwindMerge
15 16 17 |
# File 'app/behaviors/ui/alert_dialog_content_behavior.rb', line 15 def alert_dialog_content_classes TailwindMerge::Merger.new.merge([alert_dialog_content_base_classes, @classes].compact.join(" ")) end |
#alert_dialog_content_data_attributes ⇒ Object
Data attributes for Stimulus target
20 21 22 23 24 |
# File 'app/behaviors/ui/alert_dialog_content_behavior.rb', line 20 def alert_dialog_content_data_attributes { ui__alert_dialog_target: "content" } end |
#alert_dialog_content_html_attributes ⇒ Object
Build complete HTML attributes hash for alert dialog content
33 34 35 36 37 38 39 40 41 |
# File 'app/behaviors/ui/alert_dialog_content_behavior.rb', line 33 def alert_dialog_content_html_attributes base_attrs = @attributes&.except(:data) || {} base_attrs.merge( class: alert_dialog_content_classes, role: "alertdialog", "aria-modal": "true", data: merged_alert_dialog_content_data_attributes ) end |
#merged_alert_dialog_content_data_attributes ⇒ Object
Merge user-provided data attributes
27 28 29 30 |
# File 'app/behaviors/ui/alert_dialog_content_behavior.rb', line 27 def merged_alert_dialog_content_data_attributes user_data = @attributes&.fetch(:data, {}) || {} user_data.merge(alert_dialog_content_data_attributes) end |