Skip to content
This repository was archived by the owner on Feb 28, 2019. It is now read-only.

Commit 9c88b2e

Browse files
committed
Merged develop
2 parents 72dc9d9 + 18077fd commit 9c88b2e

File tree

15 files changed

+166
-13
lines changed

15 files changed

+166
-13
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.env.development.local
1818
.env.test.local
1919
.env.production.local
20+
.idea*
2021

2122
npm-debug.log*
2223
yarn-debug.log*

.idea/workspace.xml

+126
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.storybook/StateContainer.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React, { useState } from 'react'
2+
3+
interface StateContainerProps {
4+
initialState?: any
5+
children: any
6+
}
7+
8+
export const StateContainer: React.FC<StateContainerProps> = ({ initialState = {}, children }) => {
9+
const [state, setState] = useState(initialState)
10+
11+
return children(state, setState)
12+
}
13+
14+
export default StateContainer

.storybook/StateDecorator.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
import StateContainer from './StateContainer'
3+
4+
export const withState = (initialState = {}) => (storyFunc: any, context: any) => (
5+
<StateContainer initialState={initialState}>
6+
{ (state: any, storeState: any) => {
7+
context.state = state
8+
context.storeState = storeState
9+
return storyFunc()
10+
}}
11+
</StateContainer>
12+
)

src/components/Input/Checkbox/Checkbox.test.tsx src/components/atoms/Input/Checkbox/Checkbox.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { configure, shallow } from 'enzyme'
55
import Adapter from 'enzyme-adapter-react-16'
66

77
import Checkbox from '.'
8-
import theme from '../../../theme'
8+
import theme from '../../../../theme'
99

1010
configure({ adapter: new Adapter() })
1111

src/components/Input/Checkbox/index.tsx src/components/atoms/Input/Checkbox/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
22
import styled from 'styled-components'
3-
import { Theme } from '../../../theme';
3+
import { Theme } from '../../../../theme';
44

55
export interface IProps {
66
checked: boolean
File renamed without changes.

src/stories/input.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import React from 'react';
1+
import React from 'react'
22

3-
import { storiesOf } from '@storybook/react';
4-
import { action } from '@storybook/addon-actions';
3+
import { storiesOf } from '@storybook/react'
4+
import { action } from '@storybook/addon-actions'
5+
import { withState } from '../../.storybook/StateDecorator'
56

6-
import TextInput from '../components/Input/TextInput'
7-
import Checkbox from '../components/Input/Checkbox'
8-
import Button from '../components/Input/Button'
9-
10-
let textInputValue = "Hello there!"
7+
import TextInput from '../components/atoms/Input/TextInput'
8+
import Checkbox from '../components/atoms/Input/Checkbox'
9+
import Button from '../components/atoms/Input/Button'
1110

1211
export default storiesOf('Input', module)
13-
.add('TextInput', () => <TextInput value={textInputValue} onChange={(value) => {
14-
textInputValue = value
15-
action('New Value: ' + value)
12+
.addDecorator(withState('Testing'))
13+
.add('TextInput', ({ state, storeState }) => <TextInput value={state} onChange={(value) => {
14+
storeState(value)
15+
action('typing')(value)
1616
}}>Hello Button</TextInput>)
1717
.add('Checkbox', () => <Checkbox onClick={action('clicked')}/>)
1818
.add('Button', () => <Button onClick={action('clicked')}>Hello Button</Button>)

0 commit comments

Comments
 (0)