1+ // Copyright (c) Gridiron Survivor.
2+ // Licensed under the MIT License.
3+
4+ import type { Meta , StoryObj } from '@storybook/react' ;
5+ import { Toast } from './Toast' ;
6+ import { ToastProvider } from '../ToastProvider/ToastProvider' ;
7+ import { ToastViewport } from '../ToastViewport/ToastViewport' ;
8+ import { ToastTitle } from '../ToastTitle/ToastTitle' ;
9+ import { ToastDescription } from '../ToastDescription/ToastDescription' ;
10+ import { ToastAction } from '../ToastAction/ToastAction' ;
11+ import { ToastClose } from '../ToastClose/ToastClose' ;
12+ import { ToastVariants } from './Toast.enum' ;
13+ import type { JSX } from 'react' ;
14+
15+ const meta = {
16+ title : 'Components/Toast' ,
17+ component : Toast ,
18+ decorators : [
19+ ( Story ) : JSX . Element => (
20+ < div className = "relative h-[200px] w-[500px] rounded-md p-4" >
21+ < ToastProvider >
22+ < Story />
23+ < ToastViewport className = "absolute inset-0 flex flex-col items-center justify-center w-full" />
24+ </ ToastProvider >
25+ </ div >
26+ ) ,
27+ ] ,
28+ parameters : {
29+ docs : {
30+ description : {
31+ component : `A customizable Toast Component.` ,
32+ } ,
33+ } ,
34+ } ,
35+ tags : [ 'autodocs' ] ,
36+ argTypes : {
37+ variant : {
38+ description : 'The style of the toast' ,
39+ control : { type : 'select' } ,
40+ options : [
41+ 'default' ,
42+ 'error' ,
43+ 'warning' ,
44+ 'success' ,
45+ ] ,
46+ } ,
47+ duration : {
48+ description : 'Auto-dismiss delay in milliseconds' ,
49+ control : 'number' ,
50+ defaultValue : 5000 ,
51+ } ,
52+ open : {
53+ description : 'Determines whether toast is visible' ,
54+ control : { type : 'boolean' } ,
55+ } ,
56+ forceMount : {
57+ description : 'Renders as child component if true' ,
58+ control : { type : 'boolean' } ,
59+ } ,
60+ className : {
61+ description : 'Classes for additional styling' ,
62+ type : 'string' ,
63+ } ,
64+ children : {
65+ control : 'text' ,
66+ description : 'Toast content' ,
67+ type : 'string' ,
68+ } ,
69+ } ,
70+ } satisfies Meta < typeof Toast > ;
71+
72+ export default meta ;
73+ type Story = StoryObj < typeof meta > ;
74+
75+ export const Default : Story = {
76+ args : {
77+ variant : ToastVariants . Default ,
78+ duration : 5000 ,
79+ defaultOpen : true ,
80+ children : (
81+ < >
82+ < div className = "flex-grow" >
83+ < ToastTitle > Default Toast</ ToastTitle >
84+ < ToastDescription > This is a notification.</ ToastDescription >
85+ </ div >
86+ < ToastClose />
87+ </ >
88+ ) ,
89+ } ,
90+ } ;
91+
92+ export const Error : Story = {
93+ args : {
94+ variant : ToastVariants . Error ,
95+ defaultOpen : true ,
96+ children : (
97+ < >
98+ < div className = "flex-grow" >
99+ < ToastTitle > Error Toast</ ToastTitle >
100+ < ToastDescription > Something went wrong.</ ToastDescription >
101+ < ToastClose />
102+ </ div >
103+ </ >
104+ ) ,
105+ } ,
106+ } ;
107+
108+ export const Warning : Story = {
109+ args : {
110+ variant : ToastVariants . Warning ,
111+ defaultOpen : true ,
112+ children : (
113+ < >
114+ < div className = "flex-grow" >
115+ < ToastTitle > Warning Toast</ ToastTitle >
116+ < ToastDescription > Something might need attention.</ ToastDescription >
117+ < ToastClose />
118+ </ div >
119+ </ >
120+ ) ,
121+ } ,
122+ } ;
123+
124+ export const Success : Story = {
125+ args : {
126+ variant : ToastVariants . Success ,
127+ defaultOpen : true ,
128+ children : (
129+ < >
130+ < div className = "flex-grow" >
131+ < ToastTitle > Success Toast</ ToastTitle >
132+ < ToastDescription > Your action was successful.</ ToastDescription >
133+ < ToastClose />
134+ </ div >
135+ </ >
136+ ) ,
137+ } ,
138+ } ;
139+
140+ export const WithActionAndClose : Story = {
141+ args : {
142+ variant : ToastVariants . Default ,
143+ defaultOpen : true ,
144+ children : (
145+ < >
146+ < div className = "flex-grow" >
147+ < ToastTitle > Action & Close </ ToastTitle >
148+ < ToastDescription > An action and close button.</ ToastDescription >
149+ </ div >
150+ < ToastAction altText = "action" > Action</ ToastAction >
151+ < ToastClose />
152+ </ >
153+ ) ,
154+ } ,
155+ } ;
0 commit comments