summaryrefslogtreecommitdiff
path: root/src/components/ui/Button.astro
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-21 21:56:55 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-21 21:56:55 +0300
commitc735556726e75428550a3d28a2cf58e2c8490b7d (patch)
treefd0ae29d1636b825abeedff6b99d3376bb383135 /src/components/ui/Button.astro
Initial template
Diffstat (limited to 'src/components/ui/Button.astro')
-rw-r--r--src/components/ui/Button.astro40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/components/ui/Button.astro b/src/components/ui/Button.astro
new file mode 100644
index 0000000..d3c2398
--- /dev/null
+++ b/src/components/ui/Button.astro
@@ -0,0 +1,40 @@
+---
+import { Icon } from 'astro-icon/components';
+import { twMerge } from 'tailwind-merge';
+import type { CallToAction as Props } from '~/types';
+
+const {
+ variant = 'secondary',
+ target,
+ 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' } : {})}
+ {...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>
+ )
+}