mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 07:52:07 +08:00
Add Button, Header, and Page components with stories for multiple Svelte variations: - JavaScript - Svelte 5 JavaScript - Svelte 5 TypeScript (3.8 and 4.9) - TypeScript (4.9) Include stories, components, and CSS files to support the Storybook template components across different Svelte configurations
30 lines
797 B
Svelte
30 lines
797 B
Svelte
<script lang="ts">
|
|
import './button.css';
|
|
|
|
interface Props {
|
|
/** Is this the principal call to action on the page? */
|
|
primary?: boolean;
|
|
/** What background color to use */
|
|
backgroundColor?: string;
|
|
/** How large should the button be? */
|
|
size?: 'small' | 'medium' | 'large';
|
|
/** Button contents */
|
|
label: string;
|
|
/** The onclick event handler */
|
|
onClick?: () => void;
|
|
}
|
|
|
|
const { primary = false, backgroundColor, size = 'medium', label, onClick }: Props = $props();
|
|
</script>
|
|
|
|
<button
|
|
type="button"
|
|
class={['storybook-button', `storybook-button--${size}`].join(' ')}
|
|
class:storybook-button--primary={primary}
|
|
class:storybook-button--secondary={!primary}
|
|
style:background-color={backgroundColor}
|
|
onclick={onClick}
|
|
>
|
|
{label}
|
|
</button>
|