Skip to content

Commit

Permalink
chore: update stories
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanluongoe committed Jan 9, 2024
1 parent c9f39fc commit 7375c2a
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion src/stories/Toast.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,30 @@ export const Error: StoryFn<typeof Toaster> = () => {
toast.error({
title: `Scheduled: Catch up ${count}`,
description: 'Friday, February 10, 2023 at 5:57 PM',
duration: 3 * 1000,
duration: 300 * 1000,
});
setCount((prev) => prev + 1);
}}
>
Show Toast
</button>
</div>
);
};

export const Loading: StoryFn<typeof Toaster> = () => {
const [count, setCount] = useState(0);

return (
<div>
<Toaster position="center" />
<button
type="button"
onClick={() => {
toast.loading({
title: `Scheduled: Catch up ${count}`,
description: 'Friday, February 10, 2023 at 5:57 PM',
duration: 300 * 1000,
});
setCount((prev) => prev + 1);
}}
Expand Down Expand Up @@ -274,3 +297,40 @@ export const CustomClassName: StoryFn<typeof Toaster> = () => {
</div>
);
};

export const PromiseSupport: StoryFn<typeof Toaster> = () => {
return (
<div>
<Toaster
toastOptions={{
className: 'abc',
duration: 5 * 1000,
}}
/>
<button
type="button"
onClick={() => {
const resolveAfter3Sec = new Promise((resolve) => {
setTimeout(() => {
resolve('resolved');
}, 2000);
});

toast.promise(resolveAfter3Sec, {
loading: {
title: 'loading',
},
success: {
title: 'success',
},
error: {
title: 'error',
},
});
}}
>
Show Toast
</button>
</div>
);
};

0 comments on commit 7375c2a

Please sign in to comment.