mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
44 lines
885 B
Svelte
44 lines
885 B
Svelte
<script>
|
|
import './button.css';
|
|
import { createEventDispatcher } from 'svelte';
|
|
/**
|
|
* Is this the principal call to action on the page?
|
|
*/
|
|
export let primary = false;
|
|
|
|
/**
|
|
* What background color to use
|
|
*/
|
|
export let backgroundColor;
|
|
/**
|
|
* How large should the button be?
|
|
*/
|
|
export let size = 'medium';
|
|
/**
|
|
* Button contents
|
|
*/
|
|
export let children = '';
|
|
|
|
let mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
|
|
let style = backgroundColor ? `background-color: ${backgroundColor}` : '';
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
/**
|
|
* Optional click handler
|
|
*/
|
|
export let onClick = (event) => {
|
|
dispatch('click', event);
|
|
};
|
|
</script>
|
|
|
|
<button
|
|
type="button"
|
|
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
{style}
|
|
on:click={onClick}
|
|
>
|
|
{children}
|
|
</button>
|