Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ It also accepts options.
```javascript
toaster.notify("Hello world", {
position: "bottom-left", // top-left, top, top-right, bottom-left, bottom, bottom-right
duration: null // This notification will not automatically close
duration: null, // This notification will not automatically close
className: "is--danger" // Custom className to be passed to the toast if you're using the string version
});
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "toasted-notes",
"version": "3.2.0",
"version": "3.3.0",
"description": "Flexible, easy to implement toast notifications for react",
"main": "commonjs/index.js",
"module": "lib/index.js",
Expand Down
5 changes: 3 additions & 2 deletions src/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ interface Props {
id: string;
title: React.ReactNode | string;
onClose: () => void;
className?: string;
}

const Alert = ({ id, title, onClose }: Props) => {
const Alert = ({ id, title, onClose, className = '' }: Props) => {
return (
<div id={id} className="Toaster__alert">
<div id={id} className={`Toaster__alert ${className}`}>
{typeof title === "string" ? (
<div className="Toaster__alert_text">{title}</div>
) : (
Expand Down
6 changes: 4 additions & 2 deletions src/Alert/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface MessageOptions {
onRequestClose: () => void;
showing: boolean;
position: PositionsType;
className?: string;
}

interface Props extends MessageOptions {
Expand All @@ -58,7 +59,8 @@ export const Message = ({
position,
onRequestRemove,
requestClose = false,
duration = 30000
duration = 30000,
className = '',
}: Props) => {
const container = React.useRef<HTMLDivElement | null>(null);
const [timeout, setTimeout] = React.useState(duration);
Expand Down Expand Up @@ -119,7 +121,7 @@ export const Message = ({

function renderMessage() {
if (typeof message === "string" || React.isValidElement(message)) {
return <Alert id={id} title={message} onClose={close} />;
return <Alert id={id} title={message} onClose={close} className={className} />;
}

if (typeof message === "function") {
Expand Down
4 changes: 3 additions & 1 deletion src/Alert/ToastManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface MessageOptionalOptions {
type?: MessageType;
duration?: number | null;
position?: PositionsType;
className?: string;
}

interface ToastArgs extends MessageOptions {
Expand Down Expand Up @@ -101,7 +102,8 @@ export default class ToastManager extends React.Component<Props, State> {
duration:
typeof options.duration === "undefined" ? 5000 : options.duration,
onRequestRemove: () => this.removeToast(String(id), position),
type: options.type
type: options.type,
className: options.className,
};
};

Expand Down