Skip to content

Commit 30440e7

Browse files
committed
Make flashes disappear, style for multiple flashes
1 parent ab4ce6f commit 30440e7

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

app/assets/stylesheets/application.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ input[type=number]::-webkit-outer-spin-button {
8484
animation: heartbeat 2s infinite;
8585
}
8686

87+
@keyframes fade-out {
88+
from { opacity: 1; }
89+
to { opacity: 0; }
90+
}
91+
92+
.animate-fadeout {
93+
animation: fade-out 2s;
94+
animation-delay: 5s;
95+
animation-fill-mode: forwards;
96+
}
97+
8798
button.dropdown-button:has( + div > ul:empty) {
8899
display: none;
89100
}

app/javascript/controllers/flash_controller.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { Controller } from "@hotwired/stimulus"
22

33
// Connects to data-controller="flash"
44
export default class extends Controller {
5-
connect() {
6-
}
7-
8-
hide() {
5+
destroy() {
96
this.element.remove()
107
}
118
}

app/views/layouts/application.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ html
2222

2323
/ data-controller="#{'debug-turbo' if Rails.env.development?}"
2424
body
25-
= render("shared/flash")
25+
= render "shared/flash"
2626

2727
/ TODO: this is here because Devise is using this layout, not public
2828
- if request.path.include?("/lookbook/")

app/views/shared/_flash.html.slim

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
- flash.each do |type, message|
1+
.absolute.right-10.pt-4
2+
- flash.each do |type, message|
23
- if type.to_sym == :notice
3-
- color_classes = "bg-blue-100 border-blue-500"
4+
- color_classes = "bg-blue-200"
5+
- icon_symbol = :bell
46
- elsif type.to_sym.in?([ :error, :alert ])
5-
- color_classes = "bg-red-100 border-red-500"
7+
- color_classes = "bg-red-500 text-xl"
8+
- icon_symbol = :warning_circle
69
- else
7-
- color_classes = "bg-white"
10+
- color_classes = "bg-white"
11+
- icon_symbol = :bell
812

9-
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"
10-
div class="flex"
11-
div class="py-1"
12-
= icon(:bell)
13-
div
14-
p = message
13+
div class="rounded-md mb-2 px-4 py-3 shadow-md #{color_classes} animate-fadeout" role="alert" data-controller="flash" data-action="click->flash#destroy animationend->flash#destroy"
14+
.flex.align-middle
15+
div = icon(icon_symbol)
16+
div = message

0 commit comments

Comments
 (0)