Skip to content

the --toastContainer* css variables don't seem to be working #76

Open
@paulovieira

Description

@paulovieira

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-L52

You 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:

<style>
._toastContainer {
  list-style-type: none;
  z-index: var(--toastContainerZIndex, 9999);
}

._toastContainer > li {
  top: var(--toastContainerTop, 1.5rem);
  right: var(--toastContainerRight, 2rem);
  bottom: var(--toastContainerBottom, auto);
  left: var(--toastContainerLeft, auto);
  position: fixed;
  margin: 0;
  padding: 0;
  z-index: var(--toastContainerZIndex, 9999);
}
</style>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions