Skip to content

Commit e7dc71b

Browse files
committed
1 parent 0bf0bd4 commit e7dc71b

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div id="flash_toasts" class="fixed inset-x-0 bottom-3 flex items-center justify-center flex-col gap-3 pointer-events-none" role="alert">
2+
<% toasts.each do |key, message| %>
3+
<%= render component("ui/toast").new(text: message, scheme: key.to_sym == :error ? :error : :default) %>
4+
<% end %>
5+
</div>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
class SolidusAdmin::Layout::Flashes::Toasts::Component < SolidusAdmin::BaseComponent
4+
attr_reader :toasts
5+
6+
def initialize(toasts:)
7+
@toasts = toasts
8+
end
9+
end

admin/app/controllers/solidus_admin/base_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class BaseController < ApplicationController
1919

2020
helper 'solidus_admin/components'
2121
helper 'solidus_admin/layout'
22+
helper 'solidus_admin/flash'
2223

2324
private
2425

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module SolidusAdmin
4+
module FlashHelper
5+
def toasts
6+
flash.to_hash.with_indifferent_access.except(:alert)
7+
end
8+
end
9+
end

admin/app/views/layouts/solidus_admin/application.html.erb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
</main>
3232
</div>
3333

34-
<div class="fixed inset-x-0 bottom-3 flex items-center justify-center flex-col gap-3 pointer-events-none" role="alert">
35-
<% flash.each do |key, message| %>
36-
<%= render component("ui/toast").new(text: message, scheme: key.to_sym == :error ? :error : :default) %>
37-
<% end %>
38-
</div>
34+
<%= render component("layout/flashes/toasts").new(toasts:) %>
3935
</body>
4036
</html>

0 commit comments

Comments
 (0)