Skip to content

Commit ab4ce6f

Browse files
committed
Make flash messages destroyable
1 parent 893cfd9 commit ab4ce6f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

app/javascript/controllers/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { application } from "controllers/application"
33
import ClickableController from "controllers/clickable_controller"
44
application.register("clickable", ClickableController)
55

6+
import FlashController from "controllers/flash_controller"
7+
application.register("flash", FlashController)
8+
69
import DebugTurboController from "controllers/debug_turbo_controller"
710
application.register("debug-turbo", DebugTurboController)
811

app/views/shared/_flash.html.slim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
- flash.each do |type, message|
22
- if type.to_sym == :notice
33
- color_classes = "bg-blue-100 border-blue-500"
4-
- elsif type.to_sym == :error
4+
- elsif type.to_sym.in?([ :error, :alert ])
55
- color_classes = "bg-red-100 border-red-500"
6+
- else
7+
- color_classes = "bg-white"
68

79
div class="absolute border-t-4 rounded-b px-4 py-3 shadow-md #{color_classes} right-10" role="alert" data-controller="flash" data-action="click->flash#hide"
810
div class="flex"
911
div class="py-1"
1012
= icon(:bell)
11-
/ svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-500 mr-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"
12-
path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"
1313
div
14-
p class="font-bold" = t(type)
1514
p = message

0 commit comments

Comments
 (0)