Skip to content

Commit bff6978

Browse files
committed
feat: add Icon component
1 parent 3ccbf29 commit bff6978

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
6+
import { Icon } from 'mo/components/icon';
7+
import { Button } from 'mo/components/button';
8+
9+
const stories = storiesOf('Icon', module);
10+
stories.addDecorator(withKnobs);
11+
12+
const propDefinitions = [
13+
{
14+
property: 'render',
15+
propType: '() => React.ReactNode',
16+
required: false,
17+
description: 'Default render content',
18+
defaultValue: null,
19+
},
20+
];
21+
22+
stories.add(
23+
'Basic Usage',
24+
() => {
25+
return (
26+
<div>
27+
<h2>简述</h2>
28+
<p>
29+
This `Icon` Component based on{' '}
30+
<a href="https://microsoft.github.io/vscode-codicons/dist/codicon.html">
31+
vscode codicons
32+
</a>
33+
, so you just can using icons from this library.
34+
</p>
35+
<div>
36+
<h3>使用示例 - Basic</h3>
37+
<div style={{ display: 'flex' }}>
38+
<Button>
39+
<Icon type="edit" />
40+
edit
41+
</Button>
42+
<Button>
43+
<Icon type="check" />
44+
check
45+
</Button>
46+
</div>
47+
</div>
48+
</div>
49+
);
50+
},
51+
{
52+
info: {
53+
inline: true,
54+
TableComponent: () => propsTable({ propDefinitions }),
55+
// propTablesExclude: [],
56+
text: `
57+
代码示例:
58+
~~~js
59+
import { useContextView } from 'mo/components/contextview';
60+
61+
const contextView = useContextView();
62+
63+
const mouseMove = (event: React.MouseEvent): void => {
64+
contextView.show({
65+
x: event.clientX,
66+
y: event.clientY,
67+
}, () => {
68+
return (
69+
<h1>Hello World</h1>
70+
);
71+
});
72+
};
73+
74+
return (
75+
<div>
76+
<div id="topLeft"
77+
onMouseMove={mouseMove}
78+
style={
79+
{
80+
position: 'absolute',
81+
width: 200,
82+
height: 200,
83+
top: 0,
84+
left: 0,
85+
right: 0,
86+
bottom: 0,
87+
background: '#dddddd',
88+
}
89+
}>
90+
Hover me!
91+
</div>
92+
</div>
93+
);
94+
~~
95+
`,
96+
},
97+
}
98+
);

0 commit comments

Comments
 (0)