fill out button props to match what is available on daisy

This commit is contained in:
Benjamin Palko 2025-01-02 22:35:54 -05:00
parent 73c328eb35
commit 817359473c
5 changed files with 41 additions and 31 deletions

View file

@ -8,9 +8,11 @@
title: 'Actions/Button',
component: Button,
args: {
onClick: fn(),
onclick: fn(),
},
argTypes: {
active: { control: 'boolean' },
animation: { control: 'boolean' },
block: { control: 'boolean' },
color: {
control: 'select',
@ -20,28 +22,25 @@
'secondary',
'accent',
'ghost',
'link',
'info',
'success',
'warning',
'error',
],
},
disabled: { control: 'boolean' },
full: { control: 'boolean' },
glass: { control: 'boolean' },
outline: {
control: 'boolean',
shape: {
control: 'select',
options: ['circle', 'square'],
},
responsive: { control: 'boolean' },
size: {
control: 'select',
options: ['Default', 'xs', 'sm', 'lg'],
options: ['xs', 'sm', '-', 'lg'],
defaultValue: 'Default',
},
type: {
control: 'select',
options: ['button', 'reset', 'submit'],
},
variant: { control: 'select', options: ['link', 'outline'] },
wide: { control: 'boolean' },
},
});

View file

@ -3,57 +3,70 @@
import type { Snippet } from 'svelte';
import type { HTMLButtonAttributes } from 'svelte/elements';
interface Props {
interface Props extends HTMLButtonAttributes {
active?: boolean;
animation?: boolean;
block?: boolean;
children: Snippet;
color?: DaisyColor;
disabled?: boolean;
full?: boolean;
glass?: boolean;
outline?: boolean;
onClick?: () => void;
responsive?: boolean;
onclick?: () => void;
shape?: 'circle' | 'square';
size?: DaisySize;
type?: HTMLButtonAttributes['type'];
variant?: 'link' | 'outline';
wide?: boolean;
}
let {
active = false,
animation = true,
block = false,
children,
color,
disabled = false,
full = false,
glass = false,
outline = false,
onClick,
responsive = false,
onclick: onClick,
shape,
size,
type = 'button',
wide = false,
variant,
...props
}: Props = $props();
</script>
<button
{type}
onclick={onClick}
class:btn-outline={outline}
class:btn-active={active}
class:no-animation={!animation}
class:btn-block={block}
class:btn-wide={wide}
class:w-full={full}
class:glass
class:btn-xs={size === 'xs'}
class:btn-sm={size === 'sm'}
class:btn-lg={size === 'lg'}
class:btn-neutral={color === 'neutral'}
class:btn-primary={color === 'primary'}
class:btn-secondary={color === 'secondary'}
class:btn-accent={color === 'accent'}
class:btn-ghost={color === 'ghost'}
class:btn-link={color === 'link'}
class:btn-info={color === 'info'}
class:btn-success={color === 'success'}
class:btn-warning={color === 'warning'}
class:btn-error={color === 'error'}
class={`btn ${responsive && 'btn-xs sm:btn-sm md:btn-md lg:btn-lg'}`}
class:btn-disabled={disabled}
class:w-full={full}
class:glass
class:btn-circle={shape === 'circle'}
class:btn-square={shape === 'square'}
class:btn-xs={size === 'xs'}
class:btn-sm={size === 'sm'}
class:btn-lg={size === 'lg'}
class:btn-link={variant === 'link'}
class:btn-outline={variant === 'outline'}
class:btn-wide={wide}
{disabled}
{type}
{...props}
>
{@render children()}
</button>

View file

@ -1 +1 @@
export { default as Loader } from './Loader.svelte';
export { default as Loader } from './Loader.svelte';

View file

@ -1,11 +1,9 @@
export type DaisyColor =
| 'default'
| 'neutral'
| 'primary'
| 'secondary'
| 'accent'
| 'ghost'
| 'link'
| 'info'
| 'success'
| 'warning'

View file

@ -19,4 +19,4 @@
.site-loader {
@apply flex h-screen w-screen flex-col items-center justify-center gap-6;
}
</style>
</style>