made this component early so i just fixed up some of the props

This commit is contained in:
Benjamin Palko 2025-01-04 21:41:04 -05:00
parent e42a52e73a
commit d92bbcb5c1

View file

@ -1,38 +1,33 @@
<script lang="ts"> <script lang="ts">
import type { DaisyColor, DaisySize } from '$lib/types'; import type { DaisyColor, DaisySize } from '$lib/types';
import type { Snippet } from 'svelte'; import type { SvelteHTMLElements } from 'svelte/elements';
import type { HTMLButtonAttributes } from 'svelte/elements'; import { twMerge } from 'tailwind-merge';
interface Props extends HTMLButtonAttributes { type Props = {
active?: boolean; active?: boolean;
animation?: boolean; animation?: boolean;
block?: boolean; block?: boolean;
children: Snippet;
color?: DaisyColor; color?: DaisyColor;
disabled?: boolean;
full?: boolean; full?: boolean;
glass?: boolean; glass?: boolean;
onclick?: () => void;
shape?: 'circle' | 'square'; shape?: 'circle' | 'square';
size?: DaisySize; size?: DaisySize;
type?: HTMLButtonAttributes['type'];
variant?: 'link' | 'outline'; variant?: 'link' | 'outline';
wide?: boolean; wide?: boolean;
} } & SvelteHTMLElements['button'];
let { let {
active = false, active = false,
animation = true, animation = true,
block = false, block = false,
children, children,
class: className,
color, color,
disabled = false, disabled,
full = false, full = false,
glass = false, glass = false,
onclick: onClick,
shape, shape,
size, size,
type = 'button',
wide = false, wide = false,
variant, variant,
...props ...props
@ -40,8 +35,9 @@
</script> </script>
<button <button
onclick={onClick} {...props}
class="btn" {disabled}
class={twMerge('btn', className)}
class:btn-active={active} class:btn-active={active}
class:no-animation={!animation} class:no-animation={!animation}
class:btn-block={block} class:btn-block={block}
@ -65,11 +61,8 @@
class:btn-link={variant === 'link'} class:btn-link={variant === 'link'}
class:btn-outline={variant === 'outline'} class:btn-outline={variant === 'outline'}
class:btn-wide={wide} class:btn-wide={wide}
{disabled}
{type}
{...props}
> >
{@render children()} {@render children?.()}
</button> </button>
<style></style> <style></style>