Module: UI::AlertTitleBehavior
- Included in:
- AlertTitle, AlertTitleComponent
- Defined in:
- app/behaviors/ui/alert_title_behavior.rb
Overview
Shared behavior for Alert Title component Handles title styling
Instance Method Summary collapse
-
#alert_title_base_classes ⇒ Object
Base CSS classes for alert title.
-
#alert_title_classes ⇒ Object
Merge base classes with custom classes.
-
#alert_title_html_attributes ⇒ Object
Build complete HTML attributes hash for alert title.
-
#render_alert_title(&content_block) ⇒ Object
Renders the alert title HTML (for ERB partials).
Instance Method Details
#alert_title_base_classes ⇒ Object
Base CSS classes for alert title
9 10 11 |
# File 'app/behaviors/ui/alert_title_behavior.rb', line 9 def alert_title_base_classes "col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight" end |
#alert_title_classes ⇒ Object
Merge base classes with custom classes
14 15 16 |
# File 'app/behaviors/ui/alert_title_behavior.rb', line 14 def alert_title_classes TailwindMerge::Merger.new.merge([alert_title_base_classes, @classes].compact.join(" ")) end |
#alert_title_html_attributes ⇒ Object
Build complete HTML attributes hash for alert title
19 20 21 22 23 24 25 |
# File 'app/behaviors/ui/alert_title_behavior.rb', line 19 def alert_title_html_attributes base_attrs = @attributes || {} base_attrs.merge( class: alert_title_classes, "data-slot": "alert-title" ) end |
#render_alert_title(&content_block) ⇒ Object
Renders the alert title HTML (for ERB partials)
28 29 30 31 |
# File 'app/behaviors/ui/alert_title_behavior.rb', line 28 def render_alert_title(&content_block) all_attributes = alert_title_html_attributes.deep_merge(@attributes || {}) content_tag(:div, **all_attributes, &content_block) end |