Clement c4f7d60016
Some checks failed
Build Docker Image Front / run (pull_request) Failing after 39s
Build Docker Image Back / run (pull_request) Successful in 23s
JsDocs / coverage (pull_request) Successful in 23s
Test and coverage / coverage (pull_request) Successful in 1m35s
make register and login to layout
2024-05-20 17:04:03 +02:00

43 lines
1.1 KiB
Plaintext

---
import { Icon } from 'astro-icon/components';
import { twMerge } from 'tailwind-merge';
import type { CallToAction as Props } from '~/types';
const {
variant = 'secondary',
target,
link,
text = Astro.slots.render('default'),
icon = '',
class: className = '',
type,
...rest
} = Astro.props;
const variants = {
primary: 'btn-primary',
secondary: 'btn-secondary',
tertiary: 'btn btn-tertiary',
link: 'cursor-pointer hover:text-primary',
};
---
{
type === 'button' || type === 'submit' || type === 'reset' ? (
<button type={type} class={twMerge(variants[variant] || '', className)} {...rest}>
<Fragment set:html={text} />
{icon && <Icon name={icon} class="w-5 h-5 ml-1 -mr-1.5 rtl:mr-1 rtl:-ml-1.5 inline-block" />}
</button>
) : (
<a
class={twMerge(variants[variant] || '', className)}
{...(target ? { target: target, rel: 'noopener noreferrer' } : {})}
{...(link ? { href: link} : {})}
{...rest}
>
<Fragment set:html={text} />
{icon && <Icon name={icon} class="w-5 h-5 ml-1 -mr-1.5 rtl:mr-1 rtl:-ml-1.5 inline-block" />}
</a>
)
}