stephane-vanraes / renderless-svelte

A collection of renderless Svelte components
MIT License
277 stars 11 forks source link

Feature request for notifications - notification type #23

Closed mylastore closed 2 years ago

mylastore commented 2 years ago

How can I pass something like this: notifications.push(err.message, 'warning') to support notification type?

mylastore commented 2 years ago

Figure this out this is what I did: usage: notifications.push(err.message, 'warning') notifications store:

            update((arr) => [...arr, {message, messageType}]
        )

and on the implementation

        <Notification let:payload duration="10000">
            <p>Message Type: {payload.messageType}</p>
            <span>{payload.message}</span>
        </Notification>

Now I have message type example, success, warning, danger, success, info etc.

stephane-vanraes commented 2 years ago

The values passed into the notifications array can be anything, the docs page only has a string as an example, but (as you seem to have figured out) you can indeed do:

import { notifications } from 'renderless-svelte';
notifications.push({ type: 'warning', text: 'This is a warning' });

I will have a look at making the documentation more explicit on this :)