Open paulovieira opened 1 year ago
Hey, if I'm understanding correctly, you're passing the --toastContainer*
CSS vars through options.theme
? TBH the toastContainer*
vars weren't intended to be used like that. The docs should have been clearer about this.
I think there's opportunity for improvement re CSS var setup, but it feel it should be a v1
rework; I do think these changes will be breaking.
I agree with @paulovieira. Passing --toastContainer*
in toast instance also no works:
toast.push('Yo!', {
theme: {
'--toastContainerTop': '3.5rem',
}
})
Adding the paul's styles as globals runs like a charm
EDIT: But no stacked...
Hey, if I'm understanding correctly, you're passing the
--toastContainer*
CSS vars throughoptions.theme
? TBH thetoastContainer*
vars weren't intended to be used like that. The docs should have been clearer about this.
Yes, I was setting them in options.theme
. Now I understand that they should be used in the <style>
block, like this:
<style>
:root {
--toastContainerXyz: abc;
}
</style>
Thanks for the clarification. Yes, the documentation was a bit misleading since some css variables can be used in the <SvelteToast />
component, but others don't.
Thanks again.
Going to label this issue as an enhancement - the CSS vars should be refactored in v1
.
First, congratulations for this great utility! It's the kind of thing we all have to do manually sooner or later, but here you have something robust and that works for everyone.
About the issue: I was playing with the several css variables and noticed that
--toastContainer*
css variables don't have any effect. After inspecting the source code the problem seems to be here: https://github.com/zerodevx/svelte-toast/blob/master/src/lib/SvelteToast.svelte#L25-L52You are using the
style
prop in the<li>
element, so the--toastContainer*
variables will be set here. However the_toastContainer
class (which uses those variables) is used in the parent element (the<ul>
). So the variables are not available for_toastContainer
.A simple solution would be unfold the css in that component into 2 selectors: