@@ -6,21 +6,35 @@ import type { CallToAction } from '~/types';
66const {
77 variant = ' secondary' ,
88 target,
9- text = Astro .slots .render (" default" ),
9+ text = Astro .slots .render (' default' ),
1010 icon = ' ' ,
1111 class : className = ' ' ,
12+ type,
1213 ... rest
1314} = Astro .props as CallToAction ;
1415
1516const variants = {
16- primary: ' btn-primary' ,
17+ primary: ' btn-primary' ,
1718 secondary: ' btn-secondary' ,
1819 tertiary: ' btn btn-tertiary' ,
1920 link: ' cursor-pointer hover:text-primary' ,
2021};
2122---
2223
23- <a class ={ twMerge (variants [variant ] || ' ' , className )} {... target ? { target: target , rel: ' noopener noreferrer' } : {}} {... rest }>
24- <Fragment set:html ={ text } />
25- { icon && <Icon name = { icon } class = " w-5 h-5 ml-1 -mr-1.5 rtl:mr-1 rtl:-ml-1.5 inline-block" />}
26- </a >
24+ {
25+ type === ' button' || type === ' submit' || type === ' reset' ? (
26+ <button type = { type } class = { twMerge (variants [variant ] || ' ' , className )} { ... rest } >
27+ <Fragment set :html = { text } />
28+ { icon && <Icon name = { icon } class = " w-5 h-5 ml-1 -mr-1.5 rtl:mr-1 rtl:-ml-1.5 inline-block" />}
29+ </button >
30+ ) : (
31+ <a
32+ class = { twMerge (variants [variant ] || ' ' , className )}
33+ { ... (target ? { target: target , rel: ' noopener noreferrer' } : {})}
34+ { ... rest }
35+ >
36+ <Fragment set :html = { text } />
37+ { icon && <Icon name = { icon } class = " w-5 h-5 ml-1 -mr-1.5 rtl:mr-1 rtl:-ml-1.5 inline-block" />}
38+ </a >
39+ )
40+ }
0 commit comments