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
35 lines
741 B
Svelte
35 lines
741 B
Svelte
<script lang="ts">
|
|
import './button.css';
|
|
|
|
/**
|
|
* Is this the principal call to action on the page?
|
|
*/
|
|
export let primary = false;
|
|
|
|
/**
|
|
* What background color to use
|
|
*/
|
|
export let backgroundColor: string | undefined = undefined;
|
|
/**
|
|
* How large should the button be?
|
|
*/
|
|
export let size: 'small' | 'medium' | 'large' = 'medium';
|
|
/**
|
|
* Button contents
|
|
*/
|
|
export let label: string = '';
|
|
|
|
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
|
|
$: style = backgroundColor ? `background-color: ${backgroundColor}` : '';
|
|
</script>
|
|
|
|
<button
|
|
type="button"
|
|
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
{style}
|
|
on:click
|
|
>
|
|
{label}
|
|
</button>
|