feat: implement flash messages system with auto-dismiss notifications
- Add flash message helper and styles for consistent notifications - Replace Devise error messages with flash-based notifications - Add dashboard page with event statistics - Configure SMTP settings for development and production - Update authentication controllers to use flash messages - Add JavaScript controller for auto-dismiss functionality
This commit is contained in:
27
app/javascript/controllers/flash_message_controller.js
Normal file
27
app/javascript/controllers/flash_message_controller.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["message"]
|
||||
|
||||
connect() {
|
||||
console.log("FlashMessageController mounted", this.element);
|
||||
|
||||
// Auto-dismiss after 5 seconds
|
||||
this.timeout = setTimeout(() => {
|
||||
this.close()
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout)
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
this.element.classList.add('opacity-0', 'transition-opacity', 'duration-300')
|
||||
setTimeout(() => {
|
||||
this.element.remove()
|
||||
}, 300)
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,12 @@
|
||||
import { application } from "./application"
|
||||
|
||||
import LogoutController from "./logout_controller"
|
||||
import ShadcnTestController from "./shadcn_test_controller"
|
||||
import FlashMessage from "./flash_message_controller"
|
||||
import CounterController from "./counter_controller"
|
||||
import ShadcnTestController from "./shadcn_test_controller"
|
||||
|
||||
application.register("logout", LogoutController)
|
||||
application.register("shadcn-test", ShadcnTestController)
|
||||
application.register("counter", CounterController)
|
||||
application.register("logout", LogoutController) // Allow logout using js
|
||||
application.register("flash-message", FlashMessage) // Dismiss notification after 5 secondes
|
||||
application.register("counter", CounterController) // Simple counter for homepage
|
||||
|
||||
application.register("shadcn-test", ShadcnTestController) // Test controller for Shadcn
|
||||
|
||||
Reference in New Issue
Block a user