11---
22import Icon from " @ui/Icon.astro" ;
33
4+ // Destructure known props, rest goes into `restProps`
45const {
56 url,
67 id,
@@ -14,38 +15,39 @@ const {
1415 iconSvg = false ,
1516 iconRight = true ,
1617 iconSize = " " ,
17- title= " " ,
18+ title = " " ,
19+ ... restProps // all data-*, aria-* and custom attributes
1820} = Astro .props ;
1921
2022const resolvedIsExternal = isExternal ?? url ?.startsWith (" http" );
2123
2224const baseClasses = " font-bold text-lg px-4 py-4 rounded-lg inline-flex items-center justify-center leading-4 transition-colors duration-200 not-prose border hover:text-black" ;
2325const primaryClasses = " bg-button text-text-inverted hover:bg-button-hover border-transparent" ;
2426const secondaryClasses = " bg-primary text-white hover:bg-primary-hover border-transparent" ;
25- const clearClasses = " bg-transparent text-primary hover:bg-transparent hover:text-primary-active border-transparent"
27+ const clearClasses = " bg-transparent text-primary hover:bg-transparent hover:text-primary-active border-transparent" ;
2628const outlineClasses = " border-gray-500 text-gray-700 hover:bg-gray-100 hover:bg-button-hover" ;
2729const disabledClasses = " opacity-50 pointer-events-none" ;
2830const iconClasses = " mx-2 " ;
29- const idName = id ;
30- const slotContent = await Astro .slots .render (' default' )
31-
3231
32+ const idName = id ;
33+ const slotContent = await Astro .slots .render (' default' );
3334---
3435
3536{ url ? (
3637 <a
3738 id = { idName }
3839 href = { disabled ? undefined : url }
3940 title = { title }
40- aria-label = { title ? title : slotContent }
41+ aria-label = { title ? title : slotContent }
4142 class = { ` ${baseClasses }
4243 ${clear ? clearClasses : outline ? outlineClasses : secondary ? secondaryClasses : primaryClasses }
4344 ${disabled ? disabledClasses : " " }
4445 ${className } ` }
4546 aria-disabled = { disabled }
4647 { ... (resolvedIsExternal ? { target: " _blank" , rel: " noopener noreferrer" } : {})}
48+ { ... restProps }
4749 >
48- { ! iconRight && icon && <Icon name = { icon } svg = { iconSvg } size = { iconSize } class = { iconClasses } />}
50+ { ! iconRight && icon && <Icon name = { icon } svg = { iconSvg } size = { iconSize } class = { iconClasses } />}
4951 <slot />
5052 { iconRight && icon && <Icon name = { icon } svg = { iconSvg } size = { iconSize } class = { iconClasses } />}
5153 { resolvedIsExternal && <Icon name = " external-link" svg = { iconSvg } size = { iconSize } class = { iconClasses } />}
@@ -54,15 +56,16 @@ const slotContent = await Astro.slots.render('default')
5456 <button
5557 id = { idName }
5658 title = { title }
57- aria-label = { title ? title : slotContent }
59+ aria-label = { title ? title : slotContent }
5860 class = { ` ${baseClasses }
5961 ${clear ? clearClasses : outline ? outlineClasses : secondary ? secondaryClasses : primaryClasses }
6062 ${disabled ? disabledClasses : " " }
6163 ${className } ` }
6264 disabled = { disabled }
6365 aria-disabled = { disabled }
66+ { ... restProps }
6467 >
65- { ! iconRight && icon && <Icon name = { icon } svg = { iconSvg } size = { iconSize } class = { iconClasses } />}
68+ { ! iconRight && icon && <Icon name = { icon } svg = { iconSvg } size = { iconSize } class = { iconClasses } />}
6669 <slot />
6770 { iconRight && icon && <Icon name = { icon } svg = { iconSvg } size = { iconSize } class = { iconClasses } />}
6871 </button >
0 commit comments