|
| 1 | +import {Component, createElement as h} from 'react'; |
| 2 | +import {storiesOf} from '@storybook/react'; |
| 3 | +import {action} from '@storybook/addon-actions'; |
| 4 | +import {linkTo} from '@storybook/addon-links'; |
| 5 | +import {MediaDeviceSensor, withMediaDevices} from '..'; |
| 6 | +import ShowDocs from '../../../.storybook/ShowDocs' |
| 7 | + |
| 8 | +const Print = (props) => h('pre', { |
| 9 | + style: {fontFamily: 'monospace'} |
| 10 | +}, |
| 11 | + JSON.stringify(props, null, 4) |
| 12 | +); |
| 13 | + |
| 14 | +const PrintWithDevices = withMediaDevices(Print); |
| 15 | + |
| 16 | +@withMediaDevices |
| 17 | +class Printer extends Component<any, any> { |
| 18 | + render () { |
| 19 | + return h('pre', { |
| 20 | + style: {fontFamily: 'monospace'} |
| 21 | + }, |
| 22 | + JSON.stringify(this.props, null, 4) |
| 23 | + ); |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +storiesOf('Sensors/MediaDeviceSensor', module) |
| 28 | + .add('Documentation', () => h(ShowDocs, {name: 'MediaDeviceSensor'})) |
| 29 | + .add('FaCC', () => |
| 30 | + <div> |
| 31 | + <MediaDeviceSensor>{(state) => |
| 32 | + <pre style={{fontFamily: 'monospace'}}> |
| 33 | + {JSON.stringify(state, null, 4)} |
| 34 | + </pre> |
| 35 | + }</MediaDeviceSensor> |
| 36 | + </div> |
| 37 | + ) |
| 38 | + .add('Render prop', () => |
| 39 | + <div> |
| 40 | + <MediaDeviceSensor render={(state) => |
| 41 | + <pre style={{fontFamily: 'monospace'}}> |
| 42 | + {JSON.stringify(state, null, 4)} |
| 43 | + </pre> |
| 44 | + } /> |
| 45 | + </div> |
| 46 | + ) |
| 47 | + .add('HOC', () => <PrintWithDevices />) |
| 48 | + .add('Decorator', () => <Printer />); |
0 commit comments