update button

This commit is contained in:
Benjamin Palko 2025-03-18 11:40:46 -04:00
parent fac4298ac4
commit d40a04afbd
2 changed files with 24 additions and 20 deletions

View file

@ -12,11 +12,11 @@
}, },
argTypes: { argTypes: {
active: { control: 'boolean' }, active: { control: 'boolean' },
animation: { control: 'boolean' },
block: { control: 'boolean' }, block: { control: 'boolean' },
color: { color: {
control: 'select', control: 'select',
options: [ options: [
undefined,
'neutral', 'neutral',
'primary', 'primary',
'secondary', 'secondary',
@ -30,17 +30,19 @@
}, },
disabled: { control: 'boolean' }, disabled: { control: 'boolean' },
full: { control: 'boolean' }, full: { control: 'boolean' },
glass: { control: 'boolean' },
shape: { shape: {
control: 'select', control: 'select',
options: ['circle', 'square'], options: ['square', 'circle'],
}, },
size: { size: {
control: 'select', control: 'select',
options: ['xs', 'sm', '-', 'lg'], options: ['xs', 'sm', 'md', 'lg'],
defaultValue: 'Default', defaultValue: 'md',
},
style: {
control: 'select',
options: [undefined, 'outline', 'dash', 'soft', 'ghost', 'link'],
}, },
variant: { control: 'select', options: ['link', 'outline'] },
wide: { control: 'boolean' }, wide: { control: 'boolean' },
}, },
}); });

View file

@ -1,3 +1,8 @@
<script lang="ts" module>
export type ButtonShape = 'square' | 'circle';
export type ButtonStyle = 'outline' | 'dash' | 'soft' | 'ghost' | 'link';
</script>
<script lang="ts"> <script lang="ts">
import type { DaisyColor, DaisySize } from '$lib/types'; import type { DaisyColor, DaisySize } from '$lib/types';
import clsx from 'clsx'; import clsx from 'clsx';
@ -6,30 +11,26 @@
type Props = { type Props = {
active?: boolean; active?: boolean;
animation?: boolean;
block?: boolean; block?: boolean;
color?: DaisyColor; color?: DaisyColor;
full?: boolean; full?: boolean;
glass?: boolean; shape?: ButtonShape;
shape?: 'circle' | 'square';
size?: DaisySize; size?: DaisySize;
variant?: 'link' | 'outline'; style?: ButtonStyle;
wide?: boolean; wide?: boolean;
} & SvelteHTMLElements['button']; } & SvelteHTMLElements['button'];
let { let {
active = false, active = false,
animation = true,
block = false, block = false,
children, children,
class: className, class: className,
color, color,
full = false, full = false,
glass = false,
shape, shape,
size, size,
style,
wide = false, wide = false,
variant,
...props ...props
}: Props = $props(); }: Props = $props();
</script> </script>
@ -38,27 +39,28 @@
{...props} {...props}
class={twMerge('btn', clsx(className))} class={twMerge('btn', clsx(className))}
class:btn-active={active} class:btn-active={active}
class:no-animation={!animation}
class:btn-block={block} class:btn-block={block}
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-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-disabled={props.disabled} class:btn-disabled={props.disabled}
class:w-full={full} class:w-full={full}
class:glass
class:btn-circle={shape === 'circle'} class:btn-circle={shape === 'circle'}
class:btn-square={shape === 'square'} class:btn-square={shape === 'square'}
class:btn-xs={size === 'xs'} class:btn-xs={size === 'xs'}
class:btn-sm={size === 'sm'} class:btn-sm={size === 'sm'}
class:btn-md={size === 'md'}
class:btn-lg={size === 'lg'} class:btn-lg={size === 'lg'}
class:btn-link={variant === 'link'} class:btn-outline={style === 'outline'}
class:btn-outline={variant === 'outline'} class:btn-dash={style === 'dash'}
class:btn-soft={style === 'soft'}
class:btn-ghost={style === 'ghost'}
class:btn-link={style === 'link'}
class:btn-wide={wide} class:btn-wide={wide}
> >
{@render children?.()} {@render children?.()}