Class: Maquina::Application::Alert
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- Maquina::Application::Alert
- Includes:
- Maquina::ApplicationView
- Defined in:
- app/views/maquina/application/alert.rb
Instance Method Summary collapse
-
#initialize(flash) ⇒ Alert
constructor
A new instance of Alert.
- #view_template ⇒ Object
Methods included from Maquina::ApplicationView
#attribute_human_name, #button_to, #image_tag, #link_to, #model_human_name, #svg_icon
Constructor Details
#initialize(flash) ⇒ Alert
Returns a new instance of Alert.
8 9 10 11 12 13 14 |
# File 'app/views/maquina/application/alert.rb', line 8 def initialize(flash) notice = flash.notice || flash.now[:notice] alert = flash.alert || flash.now[:alert] @flash = notice || alert @success = notice.present? end |
Instance Method Details
#view_template ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/views/maquina/application/alert.rb', line 16 def view_template return if @flash.blank? div(aria_live: "assertive", class: "pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:items-start sm:p-6 z-30", data: {controller: "alert"}) do div(class: "flex w-full flex-col items-center space-y-4 sm:items-end hidden", data: transition_attributes) do div(class: "pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg bg-white shadow-lg ring-1 ring-black ring-opacity-5") do div(class: "p-4") do div(class: "flex items-start") do div(class: "flex-shrink-0") do svg_icon(:outline, css_class: classes("h-6 w-6", alert_success?: "text-green-400", alert_failure?: "text-red-400").dig(:class), icon: alert_icon) end div(class: "ml-3 w-0 flex-1 pt-0.5") do p(class: "text-sm font-medium text-skin-base") { alert_title } p(class: "mt-1 text-sm text-skin-dimmed") { alert_description } end div(class: "ml-4 flex flex-shrink-0") do (type: "button", class: "inline-flex rounded-md bg-white text-gray-dimmed hover:text-skin-muted focus:outline-none focus:ring-2 focus:ring-skin-accented focus:ring-offset-2", data: {action: "alert#close"}) do span(class: "sr-only") { "Close" } svg_icon(:fill, view_box: "0 0 20 20", css_class: "h-5 w-5", icon: close_icon) end end end end end end end end |