Class: UI::Alert

Inherits:
Phlex::HTML
  • Object
show all
Includes:
AlertBehavior
Defined in:
app/components/ui/alert.rb

Overview

Alert - Phlex implementation

A callout component for displaying important information to users. Uses AlertBehavior module for shared styling logic.

Examples:

Basic usage

render UI::Alert.new do
  svg class: "lucide lucide-circle-check" # Your icon here
  render UI::Title.new { "Success" }
  render UI::Description.new { "Your changes have been saved." }
end

Instance Method Summary collapse

Methods included from AlertBehavior

#alert_base_classes, #alert_classes, #alert_html_attributes, #alert_variant_classes, #render_alert

Constructor Details

#initialize(variant: :default, classes: "", **attributes) ⇒ Alert

Returns a new instance of Alert.

Parameters:

  • variant (Symbol) (defaults to: :default)

    Visual style variant (:default, :destructive)

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



20
21
22
23
24
# File 'app/components/ui/alert.rb', line 20

def initialize(variant: :default, classes: "", **attributes)
  @variant = variant
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_template(&block) ⇒ Object



26
27
28
29
30
# File 'app/components/ui/alert.rb', line 26

def view_template(&block)
  div(**alert_html_attributes) do
    yield if block_given?
  end
end