@@ -77,7 +77,22 @@ const meta: Meta<typeof Button> = {
7777 . filter ( Boolean )
7878 . join ( ' ' ) ;
7979 const disabled = args . disabled || args . loading ? ' disabled' : '' ;
80- return `<button type="button" class="${ cls } "${ disabled } >${ args . children ?? 'Tekst' } </button>` ;
80+ const iconStart =
81+ args . iconStart && ! args . loading
82+ ? `\n <svg class="dsn-icon" aria-hidden="true"><!-- icon --></svg>`
83+ : '' ;
84+ const loader = args . loading
85+ ? `\n <svg class="dsn-icon dsn-button__loader" aria-hidden="true"><!-- loader --></svg>`
86+ : '' ;
87+ const iconEnd = args . iconEnd
88+ ? `\n <svg class="dsn-icon" aria-hidden="true"><!-- icon --></svg>`
89+ : '' ;
90+ const label =
91+ args . children !== undefined && args . children !== null
92+ ? `\n <span class="dsn-button__label">${ args . children } </span>`
93+ : '' ;
94+ const inner = `${ loader || iconStart } ${ label } ${ iconEnd } ` ;
95+ return `<button type="button" class="${ cls } "${ disabled } >${ inner } \n</button>` ;
8196 } ,
8297 } ,
8398 } ,
@@ -337,17 +352,33 @@ export const IconOnly: Story = {
337352 name : 'Icon only' ,
338353 render : ( ) => (
339354 < div style = { { display : 'flex' , gap : '0.5rem' , alignItems : 'center' } } >
340- < Button variant = "strong" iconOnly aria-label = "Toevoegen" >
341- < Icon name = "plus" />
355+ < Button
356+ variant = "strong"
357+ iconOnly
358+ iconStart = { < Icon name = "plus" aria-hidden /> }
359+ >
360+ Toevoegen
342361 </ Button >
343- < Button variant = "default" iconOnly aria-label = "Instellingen" >
344- < Icon name = "settings" />
362+ < Button
363+ variant = "default"
364+ iconOnly
365+ iconStart = { < Icon name = "settings" aria-hidden /> }
366+ >
367+ Instellingen
345368 </ Button >
346- < Button variant = "subtle" iconOnly aria-label = "Sluiten" >
347- < Icon name = "x" />
369+ < Button
370+ variant = "subtle"
371+ iconOnly
372+ iconStart = { < Icon name = "x" aria-hidden /> }
373+ >
374+ Sluiten
348375 </ Button >
349- < Button variant = "strong-negative" iconOnly aria-label = "Verwijderen" >
350- < Icon name = "trash" />
376+ < Button
377+ variant = "strong-negative"
378+ iconOnly
379+ iconStart = { < Icon name = "trash" aria-hidden /> }
380+ >
381+ Verwijderen
351382 </ Button >
352383 </ div >
353384 ) ,
0 commit comments