11import { ChangeEvent , useState } from 'react' ;
22
3- import { Checkbox , Snackbar , Tooltip } from '@equinor/eds-core-react' ;
3+ import { Checkbox , Icon , Snackbar , Tooltip } from '@equinor/eds-core-react' ;
44import { chevron_down , save } from '@equinor/eds-icons' ;
55import { Meta , StoryObj } from '@storybook/react-vite' ;
66
77import { spacings } from 'src/atoms/style' ;
88import { Button } from 'src/molecules/Button/Button' ;
99import { Stack } from 'src/storybook' ;
10- import { VariantShowcase } from 'src/storybook/VariantShowcase' ;
1110
1211import { expect , fn , userEvent } from 'storybook/test' ;
1312
@@ -53,39 +52,54 @@ const meta: Meta<typeof Button> = {
5352 type : 'select' ,
5453 } ,
5554 } ,
55+ leadingContent : {
56+ table : { type : { summary : 'ReactNode' } } ,
57+ } ,
58+ trailingContent : {
59+ table : { type : { summary : 'ReactNode' } } ,
60+ } ,
5661 } ,
5762} ;
5863
5964export default meta ;
6065type Story = StoryObj < typeof Button > ;
6166export const Introduction : Story = {
62- render : ( args ) => < Button { ...args } label = " You can control me" / >,
67+ render : ( args ) => < Button { ...args } > You can control me</ Button > ,
6368} ;
6469
6570export const Basic : Story = {
66- render : ( args ) => (
67- < VariantShowcase
68- GenericComponent = { Button }
69- otherProps = { { ...args , label : 'Button' } }
70- columns = { [
71- { label : 'Filled' , value : { variant : 'filled' } } ,
72- { label : 'Outlined' , value : { variant : 'outlined' } } ,
73- { label : 'Ghost' , value : { variant : 'ghost' } } ,
74- ] }
75- rows = { [
76- { label : 'Primary' , value : { color : 'primary' } } ,
77- { label : 'Danger' , value : { color : 'danger' } } ,
78- ] }
79- />
71+ render : ( ) => (
72+ < div
73+ style = { { display : 'flex' , flexDirection : 'column' , gap : spacings . medium } }
74+ >
75+ < div style = { { display : 'flex' , gap : spacings . medium } } >
76+ < Button > Filled</ Button >
77+ < Button variant = "outlined" > Outlined</ Button >
78+ < Button variant = "ghost" > Ghost</ Button >
79+ </ div >
80+ < div style = { { display : 'flex' , gap : spacings . medium } } >
81+ < Button color = "danger" > Filled</ Button >
82+ < Button color = "danger" variant = "outlined" >
83+ Outlined
84+ </ Button >
85+ < Button color = "danger" variant = "ghost" >
86+ Ghost
87+ </ Button >
88+ </ div >
89+ </ div >
8090 ) ,
8191} ;
8292
8393export const Disabled : Story = {
8494 render : ( ) => (
8595 < div style = { { display : 'flex' , gap : spacings . medium } } >
86- < Button label = "Filled" disabled />
87- < Button label = "Outlined" disabled variant = "outlined" />
88- < Button label = "Ghost" disabled variant = "ghost" />
96+ < Button disabled > Filled</ Button >
97+ < Button disabled variant = "outlined" >
98+ Outlined
99+ </ Button >
100+ < Button disabled variant = "ghost" >
101+ Ghost
102+ </ Button >
89103 </ div >
90104 ) ,
91105} ;
@@ -104,12 +118,13 @@ const AccessibilityComponent = () => {
104118 />
105119 < Tooltip title = { canSubmit ? '' : 'Terms & Conditions must be checked' } >
106120 < Button
107- label = "Submit"
108121 aria-disabled = { ! canSubmit }
109122 onClick = { ( ) => {
110123 if ( canSubmit ) setOpen ( true ) ;
111124 } }
112- />
125+ >
126+ Submit
127+ </ Button >
113128 </ Tooltip >
114129 < Snackbar
115130 open = { open }
@@ -130,13 +145,14 @@ export const Icons: Story = {
130145 render : ( ) => (
131146 < >
132147 < div style = { { display : 'flex' , gap : spacings . medium } } >
133- < Button label = "Leading icon" leadingIcon = { save } />
134- < Button label = "Trailing icon" trailingIcon = { save } />
148+ < Button leadingContent = { < Icon data = { save } /> } > Leading icon </ Button >
149+ < Button trailingContent = { < Icon data = { save } /> } > Trailing icon </ Button >
135150 < Button
136- label = "Both icons"
137- leadingIcon = { save }
138- trailingIcon = { chevron_down }
139- />
151+ leadingContent = { < Icon data = { save } /> }
152+ trailingContent = { < Icon data = { chevron_down } /> }
153+ >
154+ Both icons
155+ </ Button >
140156 </ div >
141157 </ >
142158 ) ,
@@ -152,21 +168,31 @@ export const Loading: Story = {
152168 } }
153169 >
154170 < div style = { { display : 'flex' , gap : spacings . medium } } >
155- < Button label = "Filled" loading />
156- < Button label = "Outlined" loading variant = "outlined" />
157- < Button label = "Ghost" loading variant = "ghost" />
171+ < Button loading > Filled</ Button >
172+ < Button loading variant = "outlined" >
173+ Outlined
174+ </ Button >
175+ < Button loading variant = "ghost" >
176+ Ghost
177+ </ Button >
158178 </ div >
159179 < div style = { { display : 'flex' , gap : spacings . medium } } >
160- < Button label = "Filled" loading color = "danger" />
161- < Button label = "Outlined" loading color = "danger" variant = "outlined" />
162- < Button label = "Ghost" loading color = "danger" variant = "ghost" />
180+ < Button loading color = "danger" >
181+ Filled
182+ </ Button >
183+ < Button loading color = "danger" variant = "outlined" >
184+ Outlined
185+ </ Button >
186+ < Button loading color = "danger" variant = "ghost" >
187+ Ghost
188+ </ Button >
163189 </ div >
164190 </ div >
165191 ) ,
166192} ;
167193
168194export const FullWidth : Story = {
169- render : ( ) => (
195+ render : ( args ) => (
170196 < div
171197 style = { {
172198 margin : '32px' ,
@@ -175,26 +201,34 @@ export const FullWidth: Story = {
175201 width : '100%' ,
176202 } }
177203 >
178- < Button label = "fullWidth" fullWidth leadingIcon = { save } />
179- < Button label = "fullWidth" fullWidth trailingIcon = { save } />
180- < Button label = "No fullWidth" leadingIcon = { save } />
204+ < Button { ...args } fullWidth leadingContent = { < Icon data = { save } /> } >
205+ fullWidth
206+ </ Button >
207+ < Button { ...args } fullWidth trailingContent = { < Icon data = { save } /> } >
208+ fullWidth
209+ </ Button >
210+ < Button { ...args } leadingContent = { < Icon data = { save } /> } >
211+ No fullWidth
212+ </ Button >
181213 </ div >
182214 ) ,
183215 name : 'Full width' ,
184216} ;
185217
186218export const LinkButton : Story = {
187219 render : ( ) => {
188- return < Button to = " /faq" label = " I am a link" / >;
220+ return < Button linkOptions = { { to : ' /faq' } } > I am a link</ Button > ;
189221 } ,
190222 name : 'Button as a link' ,
191223} ;
192224
193225export const TestLoadingState : Story = {
194226 tags : [ 'test-only' ] ,
227+ render : ( args ) => {
228+ return < Button { ...args } > Loading Button</ Button > ;
229+ } ,
195230 args : {
196231 loading : true ,
197- label : 'Loading Button' ,
198232 onClick : fn ( ) ,
199233 } ,
200234 play : async ( { canvas, args } ) => {
@@ -208,7 +242,7 @@ export const TestLoadingState: Story = {
208242
209243export const TestRendersAsLink : Story = {
210244 tags : [ 'test-only' ] ,
211- render : ( ) => < Button to = " /somewhere" label = " Save" / >,
245+ render : ( ) => < Button linkOptions = { { to : ' /somewhere' } } > Save</ Button > ,
212246 play : async ( { canvas } ) => {
213247 const link = canvas . getByRole ( 'link' , { name : 'Save' } ) ;
214248
0 commit comments