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

Instance Method Details

#alert_description_base_classesObject

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_classesObject

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_attributesObject

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 || {})
  (:div, **all_attributes, &content_block)
end