Class: UI::Alert

Inherits:
Base
  • Object
show all
Defined in:
app/views/ui/alert.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#before_template

Instance Method Details

#view_templateObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/views/ui/alert.rb', line 17

def view_template
  div(class: classes, data: data_with_defaults, role: alert_role) do
    render Icon(name: icon, size:, class: "shrink-0 mt-1 #{icon_color_classes}") if icon?
    div(class: "w-full") do
      div(class: "flex items-center justify-between gap-2") do
        h5(class: heading_classes) { heading }

        if dismissable?
          button aria_label: "Dismiss", data: {action: "dismissable#dismiss"} do
            render UI::Icon.new(name: :x_mark, size:, class: "cursor-pointer #{icon_color_classes}")
          end
        end
      end

      p(class: description_classes) { description } if description?

      if block_given?
        div(class: description_classes) do
          yield
        end
      end
    end
  end
end