Module: UI::AlertDescriptionBehavior
- Included in:
- AlertDescription, AlertDescriptionComponent
- Defined in:
- app/behaviors/ui/alert_description_behavior.rb
Overview
Shared behavior for Alert Description component Handles description text styling
Instance Method Summary collapse
-
#alert_description_base_classes ⇒ Object
Base CSS classes for alert description.
-
#alert_description_classes ⇒ Object
Merge base classes with custom classes.
-
#alert_description_html_attributes ⇒ Object
Build complete HTML attributes hash for alert description.
-
#render_alert_description(&content_block) ⇒ Object
Renders the alert description HTML (for ERB partials).
Instance Method Details
#alert_description_base_classes ⇒ Object
Base CSS classes for alert description
9 10 11 |
# File 'app/behaviors/ui/alert_description_behavior.rb', line 9 def alert_description_base_classes "text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed" end |
#alert_description_classes ⇒ Object
Merge base classes with custom classes
14 15 16 |
# File 'app/behaviors/ui/alert_description_behavior.rb', line 14 def alert_description_classes TailwindMerge::Merger.new.merge([alert_description_base_classes, @classes].compact.join(" ")) end |
#alert_description_html_attributes ⇒ Object
Build complete HTML attributes hash for alert description
19 20 21 22 23 24 25 |
# File 'app/behaviors/ui/alert_description_behavior.rb', line 19 def alert_description_html_attributes base_attrs = @attributes || {} base_attrs.merge( class: alert_description_classes, "data-slot": "alert-description" ) end |
#render_alert_description(&content_block) ⇒ Object
Renders the alert description HTML (for ERB partials)
28 29 30 31 |
# File 'app/behaviors/ui/alert_description_behavior.rb', line 28 def render_alert_description(&content_block) all_attributes = alert_description_html_attributes.deep_merge(@attributes || {}) content_tag(:div, **all_attributes, &content_block) end |