Skip to content

Commit 6900442

Browse files
mariush2Copilot
andauthored
📝 Improve Toast/ToastProvider stories (#1183)
* 📝 Improve Toast/ToastProvider stories * Update src/providers/ToastProvider/ToastProvider.stories.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/providers/ToastProvider/ToastProvider.stories.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix syntax for onClick function in Toast stories --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 20374bf commit 6900442

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

src/molecules/Toast/Toast.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const meta: Meta<typeof Toast> = {
6565
undefined: undefined,
6666
withAction: {
6767
onClick: fn(),
68-
text: 'Undo',
68+
text: 'Read more',
6969
},
7070
},
7171
},

src/providers/ToastProvider/ToastProvider.stories.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,37 @@ function StoryComponent(args: ToastProps | string) {
1111
const { showToast, hideAllToasts } = useToasts();
1212
return (
1313
<div
14-
style={{ display: 'flex', gap: spacings.medium, position: 'relative' }}
14+
style={{
15+
display: 'flex',
16+
flexDirection: 'column',
17+
gap: spacings.large,
18+
alignItems: 'center',
19+
}}
1520
>
16-
<Button onClick={() => showToast(args)}>Show toast</Button>
17-
<Button onClick={hideAllToasts}>Hide all</Button>
21+
<div
22+
style={{ display: 'flex', gap: spacings.medium, position: 'relative' }}
23+
>
24+
<Button onClick={() => showToast(args)}>Show toast</Button>
25+
<Button onClick={hideAllToasts}>Hide all</Button>
26+
</div>
27+
{/* prettier-ignore */}
28+
<pre>
29+
<code style={{ width: '35rem' }}>
30+
{
31+
`// How to use the ToastProvider and useToasts hook
32+
showToast('This is a toast title');
33+
showToast({
34+
title: 'This is a toast title',
35+
description: 'This is a description',
36+
variant: 'success',
37+
duration: 10,
38+
action: {
39+
text: 'Read more',
40+
onClick: () => void
41+
};
42+
});`}
43+
</code>
44+
</pre>
1845
</div>
1946
);
2047
}

0 commit comments

Comments
 (0)