mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +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
27 lines
822 B
Svelte
27 lines
822 B
Svelte
<script>
|
|
import './button.css';
|
|
|
|
/**
|
|
* @typedef {Object} Props
|
|
* @property {boolean} [primary] Is this the principal call to action on the page?
|
|
* @property {string} [backgroundColor] What background color to use
|
|
* @property {'small' | 'medium' | 'large'} [size] How large should the button be?
|
|
* @property {string} label Button contents
|
|
* @property {() => void} [onClick] The onclick event handler
|
|
*/
|
|
|
|
/** @type {Props} */
|
|
const { primary = false, backgroundColor, size = 'medium', label, onClick } = $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>
|