Skip to content

Commit 3161823

Browse files
author
fe_wangcong
committed
first ci
0 parents  commit 3161823

22 files changed

Lines changed: 1175 additions & 0 deletions

.babelrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"es2015-webpack2",
5+
"stage-0",
6+
"react"
7+
],
8+
"plugins": [
9+
"transform-decorators-legacy",
10+
"transform-async-to-generator",
11+
"syntax-async-functions"
12+
]
13+
}

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
charset = utf-8
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
10+
[{**.js,**.css,**.styl,.babelrc,package.json}]
11+
indent_size = 2
12+
13+
[*.md]
14+
trim_trailing_whitespace = false
15+
16+
[**.html]
17+
indent_size = 2
18+
19+
[.pre-commit]
20+
indent_style = space
21+
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules
3+
npm-debug.log
4+
lib/

.pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
# Ensure all javascript files staged for commit pass standard code style
3+
git diff --name-only --cached --relative | grep '\.jsx\?$' | xargs ./node_modules/.bin/standard
4+
if [ $? -ne 0 ]; then exit 1; fi

.storybook/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { configure } from '@kadira/storybook'
2+
3+
configure(() => {
4+
require('../demo/')
5+
// require as many stories as you need.
6+
}, module)

.storybook/controls.js

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
8+
9+
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
10+
11+
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
12+
13+
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
14+
15+
var _createClass2 = require('babel-runtime/helpers/createClass');
16+
17+
var _createClass3 = _interopRequireDefault(_createClass2);
18+
19+
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
20+
21+
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
22+
23+
var _inherits2 = require('babel-runtime/helpers/inherits');
24+
25+
var _inherits3 = _interopRequireDefault(_inherits2);
26+
27+
var _react = require('react');
28+
29+
var _react2 = _interopRequireDefault(_react);
30+
31+
var _text_filter = require('./text_filter');
32+
33+
var _text_filter2 = _interopRequireDefault(_text_filter);
34+
35+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36+
37+
var StorybookControls = function (_React$Component) {
38+
(0, _inherits3.default)(StorybookControls, _React$Component);
39+
40+
function StorybookControls(props) {
41+
(0, _classCallCheck3.default)(this, StorybookControls);
42+
43+
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(StorybookControls).call(this, props));
44+
45+
_this.state = {
46+
filterText: ''
47+
};
48+
return _this;
49+
}
50+
51+
(0, _createClass3.default)(StorybookControls, [{
52+
key: 'getKindNames',
53+
value: function getKindNames() {
54+
var _this2 = this;
55+
56+
var storyStore = this.props.storyStore;
57+
58+
if (!storyStore) {
59+
return [];
60+
}
61+
var kindNames = storyStore.map(function (_ref) {
62+
var kind = _ref.kind;
63+
return kind;
64+
});
65+
66+
var filterdKindNames = kindNames.filter(function (kind) {
67+
var selectedKind = _this2.props.selectedKind;
68+
var filterText = _this2.state.filterText;
69+
70+
71+
if (kind === selectedKind) {
72+
// Always keep the selected kind name
73+
return true;
74+
}
75+
76+
return kind.toLowerCase().indexOf(filterText.toLowerCase()) > -1;
77+
});
78+
79+
return filterdKindNames;
80+
}
81+
}, {
82+
key: 'getStories',
83+
value: function getStories(kind) {
84+
var storyStore = this.props.storyStore;
85+
86+
var storiesInfo = storyStore.find(function (item) {
87+
return item.kind === kind;
88+
});
89+
90+
if (!storiesInfo) {
91+
return [];
92+
}
93+
return storiesInfo.stories;
94+
}
95+
}, {
96+
key: 'fireOnKind',
97+
value: function fireOnKind(kind) {
98+
var onKind = this.props.onKind;
99+
100+
if (onKind) onKind(kind);
101+
}
102+
}, {
103+
key: 'fireOnStory',
104+
value: function fireOnStory(story) {
105+
var onStory = this.props.onStory;
106+
107+
if (onStory) onStory(story);
108+
}
109+
}, {
110+
key: 'filterStoryList',
111+
value: function filterStoryList(filterText) {
112+
this.setState({ filterText: filterText });
113+
}
114+
}, {
115+
key: 'clearFilterText',
116+
value: function clearFilterText() {
117+
this.setState({ filterText: '' });
118+
}
119+
}, {
120+
key: 'renderStory',
121+
value: function renderStory(story) {
122+
var selectedStory = this.props.selectedStory;
123+
124+
var storyStyle = {
125+
fontSize: 13,
126+
padding: '8px 0px 8px 10px',
127+
cursor: 'pointer'
128+
};
129+
130+
if (story === selectedStory) {
131+
storyStyle.fontWeight = 'bold';
132+
}
133+
return _react2.default.createElement(
134+
'div',
135+
{
136+
key: story,
137+
style: storyStyle,
138+
onClick: this.fireOnStory.bind(this, story)
139+
},
140+
story
141+
);
142+
}
143+
}, {
144+
key: 'renderKind',
145+
value: function renderKind(kind) {
146+
var kindStyle = {
147+
fontSize: 15,
148+
padding: '10px 0px',
149+
cursor: 'pointer',
150+
borderBottom: '1px solid #EEE'
151+
};
152+
153+
var selectedKind = this.props.selectedKind;
154+
155+
if (kind === selectedKind) {
156+
var stories = this.getStories(selectedKind);
157+
kindStyle.fontWeight = 'bold';
158+
return _react2.default.createElement(
159+
'div',
160+
{ key: kind },
161+
_react2.default.createElement(
162+
'div',
163+
{
164+
style: kindStyle,
165+
onClick: this.fireOnKind.bind(this, kind)
166+
},
167+
kind
168+
),
169+
_react2.default.createElement(
170+
'div',
171+
null,
172+
stories.map(this.renderStory.bind(this))
173+
)
174+
);
175+
}
176+
177+
return _react2.default.createElement(
178+
'div',
179+
{
180+
key: kind,
181+
style: kindStyle,
182+
onClick: this.fireOnKind.bind(this, kind)
183+
},
184+
kind
185+
);
186+
}
187+
}, {
188+
key: 'render',
189+
value: function render() {
190+
var kindNames = this.getKindNames();
191+
var mainStyle = {
192+
fontFamily: '\n -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto",\n "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif\n ',
193+
color: '#444'
194+
};
195+
196+
var h1WrapStyle = {
197+
background: '#F7F7F7',
198+
paddingBottom: '20px',
199+
position: 'absolute',
200+
top: '20px',
201+
right: '10px',
202+
left: '20px'
203+
};
204+
205+
var h1Style = {
206+
textTransform: 'uppercase',
207+
letterSpacing: '3.5px',
208+
fontSize: '12px',
209+
fontWeight: 'bolder',
210+
color: '#828282',
211+
// border: '1px solid #C1C1C1',
212+
textAlign: 'center',
213+
borderRadius: '2px',
214+
padding: '5px',
215+
cursor: 'default',
216+
margin: 0,
217+
color: '#fff',
218+
background: '#00ae66'
219+
};
220+
221+
var filterTextWrapStyle = {
222+
position: 'absolute',
223+
top: '68px',
224+
right: '10px',
225+
left: '20px'
226+
};
227+
228+
var listStyle = {
229+
overflowY: 'auto',
230+
position: 'absolute',
231+
top: '108px',
232+
right: '10px',
233+
bottom: 0,
234+
left: '20px'
235+
};
236+
237+
return _react2.default.createElement(
238+
'div',
239+
{ style: mainStyle },
240+
_react2.default.createElement(
241+
'div',
242+
{ style: h1WrapStyle },
243+
_react2.default.createElement(
244+
'h3',
245+
{ style: h1Style },
246+
'HomeLink style'
247+
)
248+
),
249+
_react2.default.createElement(
250+
'div',
251+
{ style: filterTextWrapStyle },
252+
_react2.default.createElement(_text_filter2.default, {
253+
filterText: this.state.filterText,
254+
onChange: this.filterStoryList.bind(this),
255+
onClear: this.clearFilterText.bind(this)
256+
})
257+
),
258+
_react2.default.createElement(
259+
'div',
260+
{ style: listStyle },
261+
kindNames.map(this.renderKind.bind(this))
262+
)
263+
);
264+
}
265+
}]);
266+
return StorybookControls;
267+
}(_react2.default.Component);
268+
269+
exports.default = StorybookControls;
270+
271+
272+
StorybookControls.propTypes = {
273+
storyStore: _react2.default.PropTypes.array,
274+
selectedKind: _react2.default.PropTypes.string,
275+
selectedStory: _react2.default.PropTypes.string,
276+
onKind: _react2.default.PropTypes.func,
277+
onStory: _react2.default.PropTypes.func
278+
};

.storybook/hsplit.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
3+
const wrapStyle = {
4+
cursor: 'row-resize',
5+
width: '100%',
6+
height: '10px',
7+
marginTop: '-8px',
8+
marginBottom: '-10px',
9+
position: 'relative',
10+
};
11+
12+
const spanStyle = {
13+
height: '1px',
14+
width: '20px',
15+
top: '5px',
16+
left: '50%',
17+
marginLeft: '-10px',
18+
position: 'absolute',
19+
borderTop: 'solid 1px rgba(0,0,0,0.1)',
20+
borderBottom: 'solid 1px rgba(0,0,0,0.1)',
21+
};
22+
23+
const HSplit = () => (
24+
<div style={wrapStyle}>
25+
<span style={spanStyle}></span>
26+
</div>
27+
);
28+
29+
export default HSplit;

0 commit comments

Comments
 (0)