-
-
Notifications
You must be signed in to change notification settings - Fork 299
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
🌈 Track progress of notistack v3 #421
Comments
Define custom componentconst ReportCompleteNotification = React.forwardRef<HTMLDivElement, { allowDownload: boolean }>((props, ref) => {
return (
<div ref={ref}>
<span>{props.message}</span>
{props.allowDownload && (
<Button>Click to download</Button>
)}
</div>
)
})
<SnackbarProvider
Components={{
error: MyCustomErrorNotification,
reportComplete: ReportCompleteNotification,
}}
>
</SnackbarProvider> // ...
enqueueSnackbar('Your report is ready to download', {
variant: 'reportComplete',
persist: true,
// pass any additional props to your component.
// notistack works well with typescript, so it'll help you pass any additional props
// that ReportCompleteNotification expects to receive
allowDownload: true,
}) |
Hello! @iamhosseindhv How is the progress on releasing the V3 going? |
I noticed improved typescript support is checked. Is there already a way to show the custom prop types within enqueueSnackbar() based on the variant? As far as I used it now, typescript doesn't complain but is not aware either. |
Yes @emielvanseveren, I finally found some time to document this. See more details. But in a nutshell, in v3 (npm i notistack@alpha) you can do: declare module 'notistack' {
interface VariantOverrides {
// removes the `warning` variant
warning: false;
// adds `myCustomVariant` variant
myCustomVariant: true;
// adds `reportComplete` variant and specifies the
// "extra" props it takes in options of `enqueueSnackbar`
reportComplete: {
allowDownload: boolean
}
}
} |
I will be publishing v3 as stable soon. The delay in doing so was caused by lack of enough documentation. In the past couple of weeks, I've made a new doc website (https://notistack.com/) which has sufficient docs for both <v2.x (latest) and v3 (alpha). In the meantime, it'd be great to have some early adapters and get feedback :) |
Thanks for all the hard work with this library, @iamhosseindhv. We've started using Notistack in our product (opted for v3 so we could use 'enqueueSnackbar' outside of a component) for chat notifications and it's working great so far! Looking forward to the stable release, let me know if there's anything we can help with to that end |
This will be huge @iamhosseindhv , thanks for this and let me know if I can help |
I had an issue with the Custom Components feature. It seems that there is a minimum width being enforced that makes it so pointer events no longer pass through as expected when your custom notifications are defined to be small. Here's a code sandbox reproducing the issue: When you click the "Show Snackbar" button, you won't be able to click it again because clicks are being blocked by an invisible div. |
@Everston I think that it corresponds to |
Please 🙏 allow to change the default colors of the exsiting variants 🙏 |
Hello @iamhosseindhv I stumbled upon an issue though: I cannot pass a React Node as the message to enqueueSnackbar, it displays an empty snackbar instead. This was possible in notistack v2 and I think it was really useful for occasional use (no need to create a custom variant with all the styling). To summarize the issue above, the following code produces an empty snackbar (a SnackbarProvider has been added to the app of course):
|
@iamhosseindhv, you wrote in last summer that you will be publishing v3 as stable soon. How do you see it now? Do you still maintain this project? Do you plan to maintain it long term? |
No bugs to reports so far but will keep an eye for any 🙂 |
Ran into the same problem as mentioned in: #485 |
How to customize the SnackbarContainer style in v3? I want to change the position of it. Now, I use the global style. <GlobalStyles
styles={{
'.notistack-SnackbarContainer': {
left: 96,
bottom: 60,
},
}}
/> |
After a long time I'm happy to announce v3 is published as stable which doesn't require |
Notistack v3 primarily focuses on flexibility, scalibity and customisation. There has been numerous issues and pull requests on the repository asking support for customising snackbars more easily, and removing the dependency on Material-UI.
So far, customisation was only possible by overriding the existing styles, but this is not always enough. There is only so much you can do by overriding styles. Since we can't cover everyone's requirements natively on notistack, in v3, we give you the tools to build your own snackbars. This is achieved through
Components
prop.You can track the progress on alpha branch.
Download the latest alpha using
npm i notistack@alpha
Go-live Checklist:
enqueueSnackbar
to your custom component@material-ui/core
Slide
,Grow
,Zoom
andCollapse
transition componentsnpm i notistack@alpha
) and report bugs if anyThe text was updated successfully, but these errors were encountered: