Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svelte-sonner slots #1062

Open
Carlos-err406 opened this issue May 1, 2024 · 5 comments
Open

svelte-sonner slots #1062

Carlos-err406 opened this issue May 1, 2024 · 5 comments
Assignees
Labels
type: feature Introduction of new functionality to the application

Comments

@Carlos-err406
Copy link
Contributor

Describe the feature

the original svelte-sonner provides slots for modifying the default iconst of the toast
see this section of the svelte-sonner readme

my request is to add those slots to the installed component to make it more extendable, and so users dont have to modify the /ui/sonner.svelte component just to add them

@Carlos-err406 Carlos-err406 added the type: feature Introduction of new functionality to the application label May 1, 2024
@Carlos-err406
Copy link
Contributor Author

also i would be glad to work on this, and if needed update the docs

@huntabyte
Copy link
Owner

That would be great @Carlos-err406 !

@Carlos-err406
Copy link
Contributor Author

Carlos-err406 commented May 3, 2024

@huntabyte Do you think it's sane to copy and paste the Icon and Loader components from svelte-sonner, to use as default values of the slots, or is it better to get a quick PR on svelte-sonner to export the Icon component (and Loader) to the index? i dont know their stand on that though

or maybe is preferable to just use lucide-svelte icons and forget about the defaults of svelte-sonner?

@Carlos-err406
Copy link
Contributor Author

Carlos-err406 commented May 4, 2024

tried the lucide icons approach, i think it came out pretty nice

@oliverdowling
Copy link

oliverdowling commented Aug 26, 2024

EDIT: Apologies, Svelte 5 did not give a warning/error for my example and because it doesn't work, it used a cached version and I commented a bit prematurely, before I realised.

For posterity, this is what I tried adding to sonner.svelte:

{#if $$slots["loading-icon"]}<slot slot="loading-icon" name="loading-icon" />{/if}
{#if $$slots["success-icon"]}<slot slot="success-icon" name="success-icon" />{/if}
{#if $$slots["error-icon"]}<slot slot="error-icon" name="error-icon" />{/if}
{#if $$slots["warning-icon"]}<slot slot="warning-icon" name="warning-icon" />{/if}
{#if $$slots["info-icon"]}<slot slot="info-icon" name="info-icon" />{/if}

I started trying to write a wrapper but I still couldn't easily get it to work as desired, even with Svelte 5's snippets, so I think it's easiest to use the changes in the PR if anyone needs the functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

3 participants