2026-06-04 12:09:34 +02:00
|
|
|
---
|
|
|
|
|
export interface Props {
|
2026-06-23 10:07:39 +02:00
|
|
|
type?: 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
|
|
|
size?: 'sm' | 'md' | 'lg';
|
|
|
|
|
disabled?: boolean;
|
|
|
|
|
icon?: boolean;
|
|
|
|
|
href?: string;
|
|
|
|
|
htmlType?: 'button' | 'submit' | 'reset';
|
2026-06-04 12:09:34 +02:00
|
|
|
}
|
2026-06-23 10:07:39 +02:00
|
|
|
const {
|
|
|
|
|
type = 'primary',
|
|
|
|
|
size = 'md',
|
|
|
|
|
disabled = false,
|
|
|
|
|
icon = false,
|
|
|
|
|
href,
|
|
|
|
|
htmlType = 'button',
|
|
|
|
|
...rest
|
|
|
|
|
} = Astro.props;
|
|
|
|
|
|
|
|
|
|
const classes = [
|
|
|
|
|
'button',
|
|
|
|
|
`button__${type}`,
|
|
|
|
|
`button--${size}`,
|
|
|
|
|
icon ? 'button--icon' : '',
|
|
|
|
|
disabled ? 'button--disabled' : '',
|
|
|
|
|
].filter(Boolean).join(' ');
|
|
|
|
|
|
|
|
|
|
const Tag = href ? 'a' : 'button';
|
2026-06-04 12:09:34 +02:00
|
|
|
---
|
|
|
|
|
|
2026-06-23 10:07:39 +02:00
|
|
|
<Tag
|
|
|
|
|
class={classes}
|
|
|
|
|
href={href}
|
|
|
|
|
type={href ? undefined : htmlType}
|
|
|
|
|
aria-disabled={disabled ? 'true' : undefined}
|
|
|
|
|
{...rest}
|
|
|
|
|
>
|
|
|
|
|
<slot name="icon-left" />
|
|
|
|
|
<slot />
|
|
|
|
|
<slot name="icon-right" />
|
|
|
|
|
</Tag>
|
2026-06-04 12:09:34 +02:00
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@use './_button.scss';
|
2026-06-23 10:07:39 +02:00
|
|
|
</style>
|