-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.stories.js
64 lines (55 loc) · 1.3 KB
/
index.stories.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react'
import { storiesOf } from '@storybook/react' //eslint-disable-line
import { action } from '@storybook/addon-actions' //eslint-disable-line
import withReadme from 'storybook-readme/with-readme' //eslint-disable-line
// Helpers
import { clone } from 'lodash'
// Component imports
import { EditorBlock } from '../..'
import { EditorQuill } from '../editor-quill'
import componentReadme from './README.md'
// Example Config
const exampleBlock = {
id: 5,
type: 'richtext',
data: {
value: ''
},
meta: {
title: 'Input Box'
}
}
class Wrapper extends React.Component {
constructor(props) {
super(props)
this.state = {
block: exampleBlock
}
this.onChange = this.onChange.bind(this)
}
onChange(change) {
const newBlock = clone(this.state.block)
newBlock.data = change.data
action('onChange')(change)
this.setState({ block: newBlock })
}
render() {
const { block } = this.state
return (
<EditorBlock
block={block}
onAction={action('onAction')}
>
<EditorQuill
block={block}
onChange={this.onChange}
/>
</EditorBlock>
)
}
}
storiesOf('Components/EditorBlock', module)
.addDecorator(withReadme(componentReadme))
.add('default', () => (
<Wrapper />
))