Different toast alignments for frontend
I have an admin panel, and I am using the Toast notifications in a regular livewire component (https://filamentphp.com/docs/3.x/notifications/installation).
The issue I am having is I cannot find a way of changing the position of the toast notifications only on the frontend.
The code I am using to change it.
I have tried the following:
1. Adding it inside
View::composer('layouts.app', function() {})
2. Creating a middleware and applying it to the frontend routes.
3. Using request()->is('admin/*')
It only happens when trying to send a toast in livewire, does work if I send it then redirect (like a regular flash msg).
It's like these attempts cannot tell if the livewire update request is frontend/admin panel so does not work, and Filament is generating the position during this request.Solution:Jump to solution
Ok have figured it out with:
```
.fi-no {
@apply !items-center !flex-col-reverse !justify-end;
}...
17 Replies
You mean, Filament notifications?
yep
I'm using them outside of a panel too though
maybe a custom middleware?
Tried that. Sadly it does not apply them when I send a notification. Still pops up from the top-right.
Just tried your code verbatim too.
it should work. Maybe you could create a miminal repo on github to reproduce this issue
https://github.com/harvey-4thd/filament-notification-position here's a repo with the issue reproduced. Fullpage livewire component, with that custom middleware. You can click the button to test the notification.
GitHub
GitHub - harvey-4thd/filament-notification-position
Contribute to harvey-4thd/filament-notification-position development by creating an account on GitHub.
Hi, sorry for the delay. Maybe we can try another way to achieve it:
add to
resources/css/app.css
run npm run dev
Appreciate your time on this. I have decided to go with checking the
request()->header('referer')
and seeing if it has my /admin
in there. If it does then we can assume we're on the frontend. That was it'll also retain the correct transition-in.
In my service provider:
Seems to work for my case.I believe applying the CSS is more appropriate and it avoids additional processing on the backend..
Yes, but it does not have the correct transition - it's still coming in from the right
same code here
But it still slides in from the right? The animation I mean
Is this what you are seeing?
Solution
Ok have figured it out with:
which makes it slide in from the top (and is in the middle) like default
that works. I think it is better than process it on backend..
Yeah cheers. I just didn't want to give up those animations😂