This commit is contained in:
tooppaaa 2020-06-24 22:50:58 +02:00
parent 0eac7661fe
commit 18902467a7
3 changed files with 25 additions and 20 deletions

View File

@ -1,4 +1,4 @@
import React, { FunctionComponent, HTMLAttributes } from 'react';
import React, { FC } from 'react';
const styles = {
border: '1px solid #eee',
@ -10,8 +10,10 @@ const styles = {
margin: 10,
};
export type ButtonProps = HTMLAttributes<HTMLButtonElement>;
export const Button: FunctionComponent<ButtonProps> = ({ children, onClick }: ButtonProps) => (
export interface ButtonProps {
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
}
export const Button: FC<ButtonProps> = ({ children, onClick }) => (
<button onClick={onClick} style={styles} type="button">
{children}
</button>

View File

@ -11,15 +11,18 @@ export default {
},
};
const ButtonStory = (args) => ({
const ButtonStory = ({ onClick, ...args }) => ({
Component: Button,
props: args,
on: {
click: onClick,
},
});
export const Text = ButtonStory.bind({});
Text.args = {
text: 'Button',
click: action('onClick'),
onClick: action('onClick'),
};
export const Emoji = ButtonStory.bind({});

View File

@ -1,17 +1,17 @@
{
"@storybook/angular": "6.0.0-beta.34",
"@storybook/aurelia": "6.0.0-beta.34",
"@storybook/ember": "6.0.0-beta.34",
"@storybook/html": "6.0.0-beta.34",
"@storybook/marionette": "6.0.0-beta.34",
"@storybook/marko": "6.0.0-beta.34",
"@storybook/mithril": "6.0.0-beta.34",
"@storybook/preact": "6.0.0-beta.34",
"@storybook/rax": "6.0.0-beta.34",
"@storybook/react": "6.0.0-beta.34",
"@storybook/riot": "6.0.0-beta.34",
"@storybook/server": "6.0.0-beta.34",
"@storybook/svelte": "6.0.0-beta.34",
"@storybook/vue": "6.0.0-beta.34",
"@storybook/web-components": "6.0.0-beta.34"
"@storybook/angular": "6.0.0-beta.35",
"@storybook/aurelia": "6.0.0-beta.35",
"@storybook/ember": "6.0.0-beta.35",
"@storybook/html": "6.0.0-beta.35",
"@storybook/marionette": "6.0.0-beta.35",
"@storybook/marko": "6.0.0-beta.35",
"@storybook/mithril": "6.0.0-beta.35",
"@storybook/preact": "6.0.0-beta.35",
"@storybook/rax": "6.0.0-beta.35",
"@storybook/react": "6.0.0-beta.35",
"@storybook/riot": "6.0.0-beta.35",
"@storybook/server": "6.0.0-beta.35",
"@storybook/svelte": "6.0.0-beta.35",
"@storybook/vue": "6.0.0-beta.35",
"@storybook/web-components": "6.0.0-beta.35"
}