fill out button props to match what is available on daisy
This commit is contained in:
parent
73c328eb35
commit
817359473c
5 changed files with 41 additions and 31 deletions
|
|
@ -8,9 +8,11 @@
|
||||||
title: 'Actions/Button',
|
title: 'Actions/Button',
|
||||||
component: Button,
|
component: Button,
|
||||||
args: {
|
args: {
|
||||||
onClick: fn(),
|
onclick: fn(),
|
||||||
},
|
},
|
||||||
argTypes: {
|
argTypes: {
|
||||||
|
active: { control: 'boolean' },
|
||||||
|
animation: { control: 'boolean' },
|
||||||
block: { control: 'boolean' },
|
block: { control: 'boolean' },
|
||||||
color: {
|
color: {
|
||||||
control: 'select',
|
control: 'select',
|
||||||
|
|
@ -20,28 +22,25 @@
|
||||||
'secondary',
|
'secondary',
|
||||||
'accent',
|
'accent',
|
||||||
'ghost',
|
'ghost',
|
||||||
'link',
|
|
||||||
'info',
|
'info',
|
||||||
'success',
|
'success',
|
||||||
'warning',
|
'warning',
|
||||||
'error',
|
'error',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
disabled: { control: 'boolean' },
|
||||||
full: { control: 'boolean' },
|
full: { control: 'boolean' },
|
||||||
glass: { control: 'boolean' },
|
glass: { control: 'boolean' },
|
||||||
outline: {
|
shape: {
|
||||||
control: 'boolean',
|
control: 'select',
|
||||||
|
options: ['circle', 'square'],
|
||||||
},
|
},
|
||||||
responsive: { control: 'boolean' },
|
|
||||||
size: {
|
size: {
|
||||||
control: 'select',
|
control: 'select',
|
||||||
options: ['Default', 'xs', 'sm', 'lg'],
|
options: ['xs', 'sm', '-', 'lg'],
|
||||||
defaultValue: 'Default',
|
defaultValue: 'Default',
|
||||||
},
|
},
|
||||||
type: {
|
variant: { control: 'select', options: ['link', 'outline'] },
|
||||||
control: 'select',
|
|
||||||
options: ['button', 'reset', 'submit'],
|
|
||||||
},
|
|
||||||
wide: { control: 'boolean' },
|
wide: { control: 'boolean' },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,57 +3,70 @@
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
import type { HTMLButtonAttributes } from 'svelte/elements';
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
||||||
|
|
||||||
interface Props {
|
interface Props extends HTMLButtonAttributes {
|
||||||
|
active?: boolean;
|
||||||
|
animation?: boolean;
|
||||||
block?: boolean;
|
block?: boolean;
|
||||||
children: Snippet;
|
children: Snippet;
|
||||||
color?: DaisyColor;
|
color?: DaisyColor;
|
||||||
|
disabled?: boolean;
|
||||||
full?: boolean;
|
full?: boolean;
|
||||||
glass?: boolean;
|
glass?: boolean;
|
||||||
outline?: boolean;
|
onclick?: () => void;
|
||||||
onClick?: () => void;
|
shape?: 'circle' | 'square';
|
||||||
responsive?: boolean;
|
|
||||||
size?: DaisySize;
|
size?: DaisySize;
|
||||||
type?: HTMLButtonAttributes['type'];
|
type?: HTMLButtonAttributes['type'];
|
||||||
|
variant?: 'link' | 'outline';
|
||||||
wide?: boolean;
|
wide?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
active = false,
|
||||||
|
animation = true,
|
||||||
block = false,
|
block = false,
|
||||||
children,
|
children,
|
||||||
color,
|
color,
|
||||||
|
disabled = false,
|
||||||
full = false,
|
full = false,
|
||||||
glass = false,
|
glass = false,
|
||||||
outline = false,
|
onclick: onClick,
|
||||||
onClick,
|
shape,
|
||||||
responsive = false,
|
|
||||||
size,
|
size,
|
||||||
type = 'button',
|
type = 'button',
|
||||||
wide = false,
|
wide = false,
|
||||||
|
variant,
|
||||||
|
...props
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
{type}
|
|
||||||
onclick={onClick}
|
onclick={onClick}
|
||||||
class:btn-outline={outline}
|
class:btn-active={active}
|
||||||
|
class:no-animation={!animation}
|
||||||
class:btn-block={block}
|
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-neutral={color === 'neutral'}
|
||||||
class:btn-primary={color === 'primary'}
|
class:btn-primary={color === 'primary'}
|
||||||
class:btn-secondary={color === 'secondary'}
|
class:btn-secondary={color === 'secondary'}
|
||||||
class:btn-accent={color === 'accent'}
|
class:btn-accent={color === 'accent'}
|
||||||
class:btn-ghost={color === 'ghost'}
|
class:btn-ghost={color === 'ghost'}
|
||||||
class:btn-link={color === 'link'}
|
|
||||||
class:btn-info={color === 'info'}
|
class:btn-info={color === 'info'}
|
||||||
class:btn-success={color === 'success'}
|
class:btn-success={color === 'success'}
|
||||||
class:btn-warning={color === 'warning'}
|
class:btn-warning={color === 'warning'}
|
||||||
class:btn-error={color === 'error'}
|
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()}
|
{@render children()}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
export type DaisyColor =
|
export type DaisyColor =
|
||||||
| 'default'
|
|
||||||
| 'neutral'
|
| 'neutral'
|
||||||
| 'primary'
|
| 'primary'
|
||||||
| 'secondary'
|
| 'secondary'
|
||||||
| 'accent'
|
| 'accent'
|
||||||
| 'ghost'
|
| 'ghost'
|
||||||
| 'link'
|
|
||||||
| 'info'
|
| 'info'
|
||||||
| 'success'
|
| 'success'
|
||||||
| 'warning'
|
| 'warning'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue