|
| 1 | +import * as React from 'react'; |
| 2 | +import { storiesOf } from '@storybook/react'; |
| 3 | +import { withKnobs } from '@storybook/addon-knobs'; |
| 4 | +import { propsTable } from '../common/propsTable'; |
| 5 | +import { Checkbox } from 'mo/components/checkbox'; |
| 6 | + |
| 7 | +const stories = storiesOf('Checkbox', module); |
| 8 | +stories.addDecorator(withKnobs); |
| 9 | + |
| 10 | +const propDefinitions = [ |
| 11 | + { |
| 12 | + property: 'render', |
| 13 | + propType: '() => React.ReactNode', |
| 14 | + required: false, |
| 15 | + description: 'Default render content', |
| 16 | + defaultValue: null, |
| 17 | + }, |
| 18 | +]; |
| 19 | + |
| 20 | +stories.add( |
| 21 | + 'Basic Usage', |
| 22 | + () => { |
| 23 | + const onSelectOption = (e, option) => { |
| 24 | + console.log('onSelectOption', e, option); |
| 25 | + }; |
| 26 | + return ( |
| 27 | + <div |
| 28 | + style={{ |
| 29 | + backgroundColor: 'rgb(37, 37, 38)', |
| 30 | + color: 'rgb(240, 240, 240)', |
| 31 | + height: 500, |
| 32 | + padding: 20, |
| 33 | + }} |
| 34 | + > |
| 35 | + <h2>简述</h2> |
| 36 | + <p>Checkbox component.</p> |
| 37 | + |
| 38 | + <h3>使用示例 1</h3> |
| 39 | + <div> |
| 40 | + <Checkbox |
| 41 | + id="checkbox1" |
| 42 | + value="1" |
| 43 | + style={{ |
| 44 | + color: 'rgba(255, 255, 255, 0.4)', |
| 45 | + background: '#252526', |
| 46 | + }} |
| 47 | + onChange={onSelectOption} |
| 48 | + > |
| 49 | + Controls whether and how files path are shown in the |
| 50 | + breadcrumbs view. |
| 51 | + </Checkbox> |
| 52 | + </div> |
| 53 | + <div style={{ marginTop: 20 }}> |
| 54 | + <Checkbox |
| 55 | + id="checkbox2" |
| 56 | + value="2" |
| 57 | + style={{ |
| 58 | + color: 'rgba(255, 255, 255, 0.4)', |
| 59 | + background: '#252526', |
| 60 | + }} |
| 61 | + onChange={onSelectOption} |
| 62 | + > |
| 63 | + Render breadcrumb items with icons. |
| 64 | + </Checkbox> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + ); |
| 68 | + }, |
| 69 | + { |
| 70 | + info: { |
| 71 | + inline: true, |
| 72 | + TableComponent: () => propsTable({ propDefinitions }), |
| 73 | + // propTablesExclude: [], |
| 74 | + text: ` |
| 75 | + 代码示例: |
| 76 | + ~~~js |
| 77 | + import { useContextView } from 'mo/components/contextview'; |
| 78 | +
|
| 79 | + const contextView = useContextView(); |
| 80 | +
|
| 81 | + const mouseMove = (event: React.MouseEvent): void => { |
| 82 | + contextView.show({ |
| 83 | + x: event.clientX, |
| 84 | + y: event.clientY, |
| 85 | + }, () => { |
| 86 | + return ( |
| 87 | + <h1>Hello World</h1> |
| 88 | + ); |
| 89 | + }); |
| 90 | + }; |
| 91 | +
|
| 92 | + return ( |
| 93 | + <div> |
| 94 | + <div id="topLeft" |
| 95 | + onMouseMove={mouseMove} |
| 96 | + style={ |
| 97 | + { |
| 98 | + position: 'absolute', |
| 99 | + width: 200, |
| 100 | + height: 200, |
| 101 | + top: 0, |
| 102 | + left: 0, |
| 103 | + right: 0, |
| 104 | + bottom: 0, |
| 105 | + background: '#dddddd', |
| 106 | + } |
| 107 | + }> |
| 108 | + Hover me! |
| 109 | + </div> |
| 110 | + </div> |
| 111 | + ); |
| 112 | + ~~ |
| 113 | + `, |
| 114 | + }, |
| 115 | + } |
| 116 | +); |
0 commit comments