-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathButton.svelte
More file actions
38 lines (34 loc) · 750 Bytes
/
Button.svelte
File metadata and controls
38 lines (34 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<script lang="ts">
import type { Snippet, ComponentProps } from 'svelte';
import { cls } from '@layerstack/tailwind';
import { Button } from 'svelte-ux';
interface Props extends ComponentProps<Button> {
children: Snippet;
}
const {
label,
icon,
href,
variant = 'fill-light',
size = 'md',
class: className,
children,
...restProps
}: Props = $props();
const internal = $derived(href?.startsWith('/') || href?.startsWith('#'));
const rel = $derived(!internal ? 'noopener noreferrer' : undefined);
const target = $derived(!internal ? '_blank' : undefined);
</script>
<Button
{href}
{target}
{rel}
{icon}
{variant}
{size}
class={cls('button', className)}
{...restProps}
>
{@render children?.()}
{label}
</Button>