|
1 | 1 | import React from "react"; |
2 | 2 | import "./../../styles.scss"; |
3 | 3 | import { Button } from "./button"; |
| 4 | +import { withKnobs, text, boolean, select } from "@storybook/addon-knobs"; |
4 | 5 |
|
5 | | -export default { title: "Button" }; |
| 6 | +export default { |
| 7 | + title: "Button", |
| 8 | + decorators: [withKnobs] |
| 9 | +}; |
6 | 10 |
|
7 | 11 | function sayMyName() { |
8 | 12 | alert("Hello Friend"); |
9 | 13 | } |
10 | 14 |
|
11 | | -export const primary = () => { |
12 | | - return ( |
13 | | - <Button type="primary" onClick={sayMyName}> |
14 | | - Hello Friend |
15 | | - </Button> |
16 | | - ); |
17 | | -}; |
18 | | - |
19 | | -export const inverted = () => { |
20 | | - return ( |
21 | | - <Button inverted={true} onClick={sayMyName}> |
22 | | - Hello Friend |
23 | | - </Button> |
24 | | - ); |
25 | | -}; |
26 | | - |
27 | | -export const disabled = () => { |
28 | | - return ( |
29 | | - <Button disabled={true} onClick={sayMyName}> |
30 | | - Hello Friend |
31 | | - </Button> |
32 | | - ); |
33 | | -}; |
34 | | - |
35 | | -export const disabledAndInverted = () => { |
36 | | - return ( |
37 | | - <Button disabled={true} inverted={true} onClick={sayMyName}> |
38 | | - Hello Friend |
39 | | - </Button> |
40 | | - ); |
| 15 | +const typeOptions = { |
| 16 | + Primary: "primary", |
| 17 | + Danger: "danger", |
| 18 | + Warning: "warning" |
41 | 19 | }; |
42 | 20 |
|
43 | | -export const danger = () => { |
44 | | - return ( |
45 | | - <Button type="danger" onClick={sayMyName}> |
46 | | - Hello Friend |
47 | | - </Button> |
48 | | - ); |
49 | | -}; |
50 | | - |
51 | | -export const warning = () => { |
| 21 | +export const primary = () => { |
52 | 22 | return ( |
53 | | - <Button type="warning" onClick={sayMyName}> |
54 | | - Hello Friend |
| 23 | + <Button |
| 24 | + inverted={boolean("Inverted", false)} |
| 25 | + disabled={boolean("Disabled", false)} |
| 26 | + type={select("Type", typeOptions, "primary")} |
| 27 | + onClick={sayMyName} |
| 28 | + > |
| 29 | + {text("Text", "Hello Friend")} |
55 | 30 | </Button> |
56 | 31 | ); |
57 | 32 | }; |
0 commit comments