Open bamorim opened 4 months ago
Hi @bamorim
I tried using your fork and I encountered a bug.
Note that I am using :top_right for my :corner prop of the toast group.
It looks OK with 1 toast:
But with 2 toasts the translate-y is messed up:
(Yes, that is 2 toasts superimposed)
Here is then 3 toasts:
As you can see, they are all being translated as though they are the "earliest" toast.
I reckon the problem lies in this bit of JS in assets/js/live_toast/live_toast.ts
:
// Calculate the translateY value with gap
// now that they can be different heights, we need to actually caluclate the real heights and add them up.
let val = 0
for (let j = 0; j < toast.order; j++) {
val += ts[j].offsetHeight + gap
}
The screenshots are from a page I built just to test different toast behaviors. I had built my own similar toast system based on toastify-js
but I want to get back in with the herd, for safety, so I switched to this lib. I will keep using this lib, even though I am dismayed at the impossible-to-customize buttons. Your PR is a good effort. I appreciate you.
This is a WIP, but mainly I was trying to have a completely custom component for all flashes/toasts.
I realized that the DX was weird because I had to pass the component each time. Worse than that, the X icon was still being rendered even with a custom component.
So I'm trying to improve this by:
component
to be passed straight toLiveToast.toast_group
functionphx-*
attributes to be used for closing the toast down to the component, so one can place the close button/action wherever they want.This is still missing a lot of important details. I also was failing to run the tests because some Jason issue that I'll look into after.
But with this setup I was able to customize the toast completely with the following toast component: