@@ -6,21 +6,35 @@ import type { CallToAction } from '~/types';
6
6
const {
7
7
variant = ' secondary' ,
8
8
target,
9
- text = Astro .slots .render (" default" ),
9
+ text = Astro .slots .render (' default' ),
10
10
icon = ' ' ,
11
11
class : className = ' ' ,
12
+ type,
12
13
... rest
13
14
} = Astro .props as CallToAction ;
14
15
15
16
const variants = {
16
- primary: ' btn-primary' ,
17
+ primary: ' btn-primary' ,
17
18
secondary: ' btn-secondary' ,
18
19
tertiary: ' btn btn-tertiary' ,
19
20
link: ' cursor-pointer hover:text-primary' ,
20
21
};
21
22
---
22
23
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