Sha256: bdfe09fb5f2fd900a7c5b2659d1fe194f20ebea7bfcb8044795eea82eddfd7bb

Contents?: true

Size: 825 Bytes

Versions: 4

Compression:

Stored size: 825 Bytes

Contents

module Components::AlertHelper
  def render_alert(title:, description: nil, variant: :default, icon: true, &block)
    alert_classes = case variant.to_sym
    when :default
      "[&>svg]:text-foreground bg-background text-foreground"
    when :error, :danger, :alert, :destructive
      "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"
    when :success
      "border-success/50 text-success dark:border-success [&>svg]:text-success"
    when :info
      "border-info/50 text-info dark:border-info [&>svg]:text-info"
    when :attention
      "border-attention/50 text-attention dark:border-attention [&>svg]:text-attention"
    end
    content = (capture(&block) if block) || description
    render "components/ui/alert", title:, content:, alert_classes:, variant:, icon:
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shadcn-ui-0.0.15 app/helpers/components/alert_helper.rb
shadcn-ui-0.0.14 app/helpers/components/alert_helper.rb
shadcn-ui-0.0.13 app/helpers/components/alert_helper.rb
shadcn-ui-0.0.12 app/helpers/components/alert_helper.rb