1
1
import React from 'react' ;
2
- import { storiesOf , action , setAddon , addDecorator } from '@kadira/storybook' ;
2
+ import { storiesOf , action , setAddon } from '@kadira/storybook' ;
3
3
import infoAddon from '@kadira/react-storybook-addon-info' ;
4
- import { withKnobs , text , boolean , number , object } from '@kadira/storybook-addon-knobs' ;
4
+ import { withKnobs , text , object } from '@kadira/storybook-addon-knobs' ;
5
5
6
6
// import MaterialColorPicker from 'react-material-color-picker';
7
7
import MaterialColorPicker from '../MaterialColorPicker.jsx' ;
@@ -10,8 +10,16 @@ import MaterialColorPicker from '../MaterialColorPicker.jsx';
10
10
setAddon ( infoAddon ) ;
11
11
12
12
13
- storiesOf ( 'Material Color Picker' , module )
13
+ function actionLog ( title ) {
14
+ return ( event ) => {
15
+ const data = { ...event } ;
16
+ data . target . node = 'console.log(event.target.node)' ;
14
17
18
+ action ( `${ title || '' } ${ data . type } : ${ data . target . value } ` . trim ( ) ) ( data ) ;
19
+ } ;
20
+ }
21
+
22
+ storiesOf ( 'Material Color Picker' , module )
15
23
. addDecorator ( ( story ) => (
16
24
< div
17
25
style = { {
@@ -29,29 +37,29 @@ storiesOf('Material Color Picker', module)
29
37
. addDecorator ( withKnobs )
30
38
. add ( 'default view' , ( ) => (
31
39
32
- < div style = { { width : 400 , backgroundColor : '#c7c7c7' } } >
40
+ < div style = { { width : 400 , backgroundColor : '#c7c7c7' } } >
33
41
< MaterialColorPicker
34
- initColor = "#3f51b5"
35
- onSubmit = { actionLog ( ) }
36
- onReset = { actionLog ( ) }
42
+ initColor = "#3f51b5"
43
+ onSubmit = { actionLog ( ) }
44
+ onReset = { actionLog ( ) }
37
45
/>
38
46
</ div >
39
47
40
48
) )
41
49
. add ( 'fullwidth view' , ( ) => (
42
50
43
- < div style = { { width : '70%' } } >
51
+ < div style = { { width : '70%' } } >
44
52
< MaterialColorPicker
45
- initColor = "#9ccc65"
46
- onSubmit = { actionLog ( ) }
47
- onReset = { actionLog ( ) }
48
- style = { { backgroundColor : '#c7c7c7' } }
53
+ initColor = "#9ccc65"
54
+ onSubmit = { actionLog ( ) }
55
+ onReset = { actionLog ( ) }
56
+ style = { { backgroundColor : '#c7c7c7' } }
49
57
/>
50
58
</ div >
51
59
52
60
) )
53
61
// storiesOf('Material Color Picker', module)
54
- . addWithInfo ( 'API' , `
62
+ . addWithInfo ( 'API' , `
55
63
[](https://badge.fury.io/gh/sm-react%2Freact-material-color-picker)
56
64
[](https://badge.fury.io/js/react-material-color-picker)
57
65
@@ -62,7 +70,8 @@ storiesOf('Material Color Picker', module)
62
70
63
71
**submitLabel** and **resetLabel** are titles of the appropriate buttons
64
72
65
- **onSubmit** and **onReset** are callbacks wich will be invoked by clicking the appropriate buttons. It will recieve an argument with the following structure:
73
+ **onSubmit** and **onReset** are callbacks wich will be invoked by clicking the
74
+ appropriate buttons. It will recieve an argument with the following structure:
66
75
~~~js
67
76
event = {
68
77
type, // 'submit' || 'reset',
@@ -79,18 +88,18 @@ event = {
79
88
80
89
[](https://github.com/UsulPro)
81
90
[](https://github.com/sm-react)
82
- ` , ( ) => (
83
- < div style = { { width : 600 } } >
91
+ ` , ( ) => (
92
+ < div style = { { width : 600 } } >
84
93
< MaterialColorPicker
85
- initColor = "rgba(0, 0, 0, 0.26)"
86
- onSubmit = { actionLog ( ) }
87
- onReset = { actionLog ( ) }
88
- style = { { width : 400 , backgroundColor : '#c7c7c7' } }
89
- submitLabel = ' Apply'
90
- resetLabel = ' Undo'
91
- />
94
+ initColor = "rgba(0, 0, 0, 0.26)"
95
+ onSubmit = { actionLog ( ) }
96
+ onReset = { actionLog ( ) }
97
+ style = { { width : 400 , backgroundColor : '#c7c7c7' } }
98
+ submitLabel = " Apply"
99
+ resetLabel = " Undo"
100
+ />
92
101
</ div >
93
- ) , { inline : true , source : false } )
102
+ ) , { inline : true , source : false } )
94
103
. addWithInfo ( 'try props' ,
95
104
`
96
105
->
@@ -99,29 +108,18 @@ event = {
99
108
#### select the \`KNOBS\` tab to get access for props
100
109
` ,
101
110
( ) => {
102
- const style = {
103
- width : 400 ,
104
- backgroundColor : '#c7c7c7' ,
105
- }
106
- return ( < div >
111
+ const style = {
112
+ width : 400 ,
113
+ backgroundColor : '#c7c7c7' ,
114
+ } ;
115
+ return ( < div >
107
116
< MaterialColorPicker
108
- initColor = { text ( 'initColor' , '#ec407a' ) }
109
- onSubmit = { actionLog ( ) }
110
- onReset = { actionLog ( ) }
111
- submitLabel = { text ( 'submitLabel' , 'OK' ) }
112
- resetLabel = { text ( 'resetLabel' , 'Cansel' ) }
113
- style = { object ( 'style' , style ) }
117
+ initColor = { text ( 'initColor' , '#ec407a' ) }
118
+ onSubmit = { actionLog ( ) }
119
+ onReset = { actionLog ( ) }
120
+ submitLabel = { text ( 'submitLabel' , 'OK' ) }
121
+ resetLabel = { text ( 'resetLabel' , 'Cansel' ) }
122
+ style = { object ( 'style' , style ) }
114
123
/>
115
- </ div > )
116
-
117
- } , { inline : true , source : false , header : false } ) ;
118
-
119
-
120
- function actionLog ( title ) {
121
- return ( event ) => {
122
- const data = { ...event } ;
123
- data . target . node = 'console.log(event.target.node)' ;
124
-
125
- action ( `${ title || '' } ${ data . type } : ${ data . target . value } ` . trim ( ) ) ( data ) ;
126
- }
127
- }
124
+ </ div > ) ;
125
+ } , { inline : true , source : false , header : false } ) ;
0 commit comments