Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-awesome-toasts
Advanced tools
Changelog
0.0.9
Readme
Easily customizable React notification system that manages its queue for you.
https://bananabobby.github.io/react-awesome-toasts/
Install the package:
yarn add react-awesome-toasts
// or
npm install react-awesome-toasts
Wrap your app with ToastProvider
:
import { ToastProvider } from 'react-awesome-toasts';
const App = () => {
return (
<ToastProvider>
App content
</ToastProvider>
)
}
Add toast methods to your component with one of the following methods:
With High Order Component:
import { withToast } from 'react-awesome-toasts';
const ToastButton = ({ toast }) => {
const toastProps = {
text: 'Message sent',
actionText: 'Undo',
ariaLabel: 'Message sent, click to undo',
onActionClick: toast.hide,
};
return <Button onClick={() => toast.show(toastProps)}>Show toast</Button>;
}
export default withToast(ToastButton);
With ToastConsumer:
import { ToastConsumer } from 'react-awesome-toasts';
const toastProps = {
text: 'Message sent',
actionText: 'Undo',
ariaLabel: 'Message sent, click to undo',
};
<ToastConsumer>
{
({ show, hide }) => (
<Button onClick={() => show({ ...toastProps, onActionClick: hide )}>
Show toast
</Button>
)
}
</ToastConsumer>
hide()
- hides currently active toast.
show(props)
- shows a toast and passes all props to the presentational component
By default ToastProvider
uses Toast
component provided by the library.
Toast
component is responsible for the accessibility and responsiveness of notifications.
Keep in mind, that if your replace it with your custom component - you will have to handle both of these features in your component if you need them in your app.
Default Toast
component has follow properties:
Property | Description |
---|---|
text string , required | Message to display in notification |
actionText string | Text of the action button |
onActionClick func | Action button click handler |
ariaLabel string | Default: text property value. Should be used for better accessibility. |
variant "error" | Variant of message |
Default presentational Toast
component provides accessibility features:
ariaLabel
value. Since action button gets focused automatically - it's nice to have an aria-label that mentions it, e.g. `Item deleted, click to undo.ToastProvider
accepts properties for customizing the behaviour of the notifications.
Property | Description |
---|---|
timeout number | Default: 4500 . The time until a toast is dismissed, in milliseconds. |
component | Presentational component for displaying notifications. |
position top-right, bottom-right, top-left, bottom-left, top-center, bottom-center | Default: bottom-left . Position of the toasts on the screen. |
FAQs
Higly customisable React toast notifications with automanaged queue
The npm package react-awesome-toasts receives a total of 399 weekly downloads. As such, react-awesome-toasts popularity was classified as not popular.
We found that react-awesome-toasts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.