Class: RailsDevtools::Components::FlashMessage

Inherits:
ApplicationComponent show all
Defined in:
app/views/rails_devtools/components/flash_message.rb

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#before_template

Constructor Details

#initialize(message:) ⇒ FlashMessage

Returns a new instance of FlashMessage.



4
5
6
# File 'app/views/rails_devtools/components/flash_message.rb', line 4

def initialize(message:)
  @message = message
end

Instance Method Details

#view_templateObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/views/rails_devtools/components/flash_message.rb', line 8

def view_template
  div(
    class: "transition transform duration-1000 hidden",
    data: {
      controller: "notification",
      notification_delay_value: "2000",
      transition_enter_from: "opacity-0 translate-x-6",
      transition_enter_to: "opacity-100 translate-x-0",
      transition_leave_from: "opacity-100 translate-x-0",
      transition_leave_to: "opacity-0 translate-x-6"
    }
  ) do
    div(class: "toast toast-top toast-end") do
      div(role: "alert", class: "alert alert-success") do
        span { @message }
      end
    end
  end
end