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

Toast style reactivity #47

Open
kakserpom opened this issue Nov 3, 2022 · 5 comments
Open

Toast style reactivity #47

kakserpom opened this issue Nov 3, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@kakserpom
Copy link

kakserpom commented Nov 3, 2022

Example:

<Toaster
    position="top-right"
    gutter={24}
    toastOptions={{
        style: darkMode() ? {
            background: '#363636',
            color: '#fff',
        } : {},
    }}
    containerStyle={{'margin-top': '50px'}}
/>

Changes of darkMode only get applied to new toasts, but not pre-existing ones. Is there a way to pass reactivity inside a toast?

@kakserpom kakserpom reopened this Nov 3, 2022
@Brendan-csel
Copy link

I'm not familiar with the code but it looks like there is a createToast function that destructures the default toaster options - so the individual toast would not be reactive to any changes in those default options.

My guess is the code needs to be refactored to merge the options while rendering the toast - instead of when adding toasts to a data structure like now.

@ardeora ardeora added the bug Something isn't working label Nov 5, 2022
@ardeora
Copy link
Owner

ardeora commented Nov 5, 2022

Thanks for pointing this out. Yeah I need to take a deeper look at what would be the best approach to achieve reactivity on the options level

@Brendan-csel
Copy link

You could do...

export const createToast = (message: Message, type: ToastType = 'blank', options: ToastOptions): Accessor<Toast> => 
   createMemo(() => ({.....})

But toast then becomes an accessor so would need to become toast() anywhere that used it.

@kakserpom
Copy link
Author

Any news?

@ardeora
Copy link
Owner

ardeora commented Nov 23, 2022

Apologies for the late reply. I was on vacation last couple of weeks. I will take a look at this, this week. Also, PRs are always welcome 😊

@ardeora ardeora mentioned this issue Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants