1
+ import * as icons from "@phosphor-icons/react/dist/ssr" ;
2
+ import type { Meta , StoryObj } from "@storybook/react" ;
3
+
4
+ import { InfoBox as InfoBoxComponent , VARIANTS } from "./index.jsx" ;
5
+ import { iconControl } from "../icon-control.jsx" ;
6
+ import styles from "./index.stories.module.scss" ;
7
+
8
+ const meta = {
9
+ component : InfoBoxComponent ,
10
+ argTypes : {
11
+ variant : {
12
+ control : "select" ,
13
+ options : VARIANTS ,
14
+ description : "The visual style variant" ,
15
+ table : {
16
+ category : "Appearance" ,
17
+ } ,
18
+ } ,
19
+ header : {
20
+ control : "text" ,
21
+ description : "Custom header text (overrides default)" ,
22
+ table : {
23
+ category : "Content" ,
24
+ } ,
25
+ } ,
26
+ icon : {
27
+ ...iconControl ,
28
+ description : "Custom icon (overrides default)" ,
29
+ table : {
30
+ category : "Content" ,
31
+ } ,
32
+ } ,
33
+ children : {
34
+ control : "text" ,
35
+ description : "Content to display in the info box" ,
36
+ table : {
37
+ category : "Content" ,
38
+ } ,
39
+ } ,
40
+ } ,
41
+ tags : [ "autodocs" ] ,
42
+ } satisfies Meta < typeof InfoBoxComponent > ;
43
+ export default meta ;
44
+
45
+ type Story = StoryObj < typeof InfoBoxComponent > ;
46
+
47
+ export const Default : Story = {
48
+ args : {
49
+ children : "This is an informational message to help users understand something important." ,
50
+ } ,
51
+ } ;
52
+
53
+ export const AllVariants : Story = {
54
+ render : ( ) => (
55
+ < div className = { styles . variantsList } >
56
+ < InfoBoxComponent variant = "neutral" >
57
+ This is a neutral message without any particular emphasis.
58
+ </ InfoBoxComponent >
59
+ < InfoBoxComponent variant = "info" >
60
+ This is an informational message providing helpful context.
61
+ </ InfoBoxComponent >
62
+ < InfoBoxComponent variant = "warning" >
63
+ This is a warning message alerting users to potential issues.
64
+ </ InfoBoxComponent >
65
+ < InfoBoxComponent variant = "error" >
66
+ This is an error message indicating something went wrong.
67
+ </ InfoBoxComponent >
68
+ < InfoBoxComponent variant = "data" >
69
+ This message relates to data or technical information.
70
+ </ InfoBoxComponent >
71
+ < InfoBoxComponent variant = "success" >
72
+ This is a success message celebrating an achievement!
73
+ </ InfoBoxComponent >
74
+ </ div >
75
+ ) ,
76
+ } ;
77
+
78
+ export const CustomHeader : Story = {
79
+ args : {
80
+ variant : "info" ,
81
+ header : "Did you know?" ,
82
+ children : "You can customize the header text to better suit your content." ,
83
+ } ,
84
+ } ;
85
+
86
+ export const CustomIcon : Story = {
87
+ args : {
88
+ variant : "info" ,
89
+ icon : < icons . Lightbulb /> ,
90
+ header : "Pro Tip" ,
91
+ children : "You can also use custom icons to enhance the message." ,
92
+ } ,
93
+ } ;
94
+
95
+ export const LongContent : Story = {
96
+ args : {
97
+ variant : "warning" ,
98
+ children : (
99
+ < >
100
+ < p > This info box contains multiple paragraphs of content.</ p >
101
+ < p >
102
+ It can handle longer messages that need more detailed explanations,
103
+ including lists, links, and other formatted content.
104
+ </ p >
105
+ < ul >
106
+ < li > First important point</ li >
107
+ < li > Second important point</ li >
108
+ < li > Third important point</ li >
109
+ </ ul >
110
+ </ >
111
+ ) ,
112
+ } ,
113
+ } ;
114
+
115
+ export const ErrorWithInstructions : Story = {
116
+ args : {
117
+ variant : "error" ,
118
+ header : "Connection Failed" ,
119
+ children : (
120
+ < >
121
+ Unable to connect to the server. Please check your internet connection
122
+ and try again. If the problem persists, contact{ " " }
123
+ < a href = "#support" > support</ a > .
124
+ </ >
125
+ ) ,
126
+ } ,
127
+ } ;
128
+
129
+ export const SuccessNotification : Story = {
130
+ args : {
131
+ variant : "success" ,
132
+ header : "Payment Successful!" ,
133
+ children : "Your transaction has been processed successfully. You should receive a confirmation email shortly." ,
134
+ } ,
135
+ } ;
136
+
137
+ export const DataExample : Story = {
138
+ args : {
139
+ variant : "data" ,
140
+ header : "API Response" ,
141
+ children : (
142
+ < pre >
143
+ { JSON . stringify ( { status : "ok" , timestamp : 1234567890 } , null , 2 ) }
144
+ </ pre >
145
+ ) ,
146
+ } ,
147
+ } ;
0 commit comments