Class: RUI::Flash

Inherits:
Base
  • Object
show all
Defined in:
lib/rui/flash.rb

Defined Under Namespace

Classes: Wrapper

Instance Method Summary collapse

Constructor Details

#initialize(variant = "alert") ⇒ Flash

Returns a new instance of Flash.



4
5
6
# File 'lib/rui/flash.rb', line 4

def initialize(variant = "alert")
  @variant = variant
end

Instance Method Details

#view_templateObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rui/flash.rb', line 8

def view_template
  div(role: "alert", data: { controller: "flash" }, class: "lg:max-w-lg border p-3 lg:px-5 lg:py-3 rounded-lg opacity-0 transition-opacity duration-100 ease-in-out " + classes) do
    div(class: "flex flex-row items-center justify-between gap-3") do
      div(class: "w-6") { render RUI::Icon.new(icon) }
      p(class: "w-full") { yield }
      button(class: "w-6 hover:cursor-pointer", data: { action: "flash#close" }) do
        render RUI::Icon.new("x")
      end
    end
  end
end