Build out components #45
1 changed files with 10 additions and 17 deletions
|
|
@ -1,38 +1,33 @@
|
|||
<script lang="ts">
|
||||
import type { DaisyColor, DaisySize } from '$lib/types';
|
||||
|
Yeah, onclick is the default prop name on elements in svelte, its not the same as with React where it follows JS camel case styling. Yeah, onclick is the default prop name on elements in svelte, its not the same as with React where it follows JS camel case styling.
kk thanks, good to know kk thanks, good to know
actually, I think I'm gonig to redo the typing here, there is redundancy actually, I think I'm gonig to redo the typing here, there is redundancy
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { HTMLButtonAttributes } from 'svelte/elements';
|
||||
import type { SvelteHTMLElements } from 'svelte/elements';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
interface Props extends HTMLButtonAttributes {
|
||||
type Props = {
|
||||
active?: boolean;
|
||||
animation?: boolean;
|
||||
block?: boolean;
|
||||
children: Snippet;
|
||||
color?: DaisyColor;
|
||||
disabled?: boolean;
|
||||
full?: boolean;
|
||||
glass?: boolean;
|
||||
onclick?: () => void;
|
||||
shape?: 'circle' | 'square';
|
||||
size?: DaisySize;
|
||||
type?: HTMLButtonAttributes['type'];
|
||||
variant?: 'link' | 'outline';
|
||||
wide?: boolean;
|
||||
}
|
||||
} & SvelteHTMLElements['button'];
|
||||
|
||||
let {
|
||||
active = false,
|
||||
animation = true,
|
||||
block = false,
|
||||
children,
|
||||
class: className,
|
||||
color,
|
||||
disabled = false,
|
||||
disabled,
|
||||
full = false,
|
||||
glass = false,
|
||||
onclick: onClick,
|
||||
shape,
|
||||
size,
|
||||
type = 'button',
|
||||
wide = false,
|
||||
variant,
|
||||
...props
|
||||
|
|
@ -40,8 +35,9 @@
|
|||
</script>
|
||||
|
||||
<button
|
||||
onclick={onClick}
|
||||
class="btn"
|
||||
{...props}
|
||||
{disabled}
|
||||
class={twMerge('btn', className)}
|
||||
class:btn-active={active}
|
||||
class:no-animation={!animation}
|
||||
class:btn-block={block}
|
||||
|
|
@ -65,11 +61,8 @@
|
|||
class:btn-link={variant === 'link'}
|
||||
class:btn-outline={variant === 'outline'}
|
||||
class:btn-wide={wide}
|
||||
{disabled}
|
||||
{type}
|
||||
{...props}
|
||||
>
|
||||
{@render children()}
|
||||
{@render children?.()}
|
||||
</button>
|
||||
|
||||
<style></style>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue
Any reason or standard you had to change the onClick to onclick?