Merge pull request #1302 from waywardmonkeys/site-components

Update IconSet and Header for coding standard.
This commit is contained in:
Benjy Cui 2016-03-30 18:51:45 +08:00
commit 04ddd8a417
2 changed files with 20 additions and 20 deletions

View File

@ -8,6 +8,10 @@ import './index.less';
import componentsList from '../../../_data/react-components';
export default class Header extends React.Component {
static contextTypes = {
router: React.PropTypes.object.isRequired,
}
constructor(props) {
super(props);
@ -137,7 +141,3 @@ export default class Header extends React.Component {
);
}
}
Header.contextTypes = {
router: React.PropTypes.object.isRequired,
};

View File

@ -3,19 +3,22 @@ import CopyToClipboard from 'react-copy-to-clipboard';
import classNames from 'classnames';
import { Icon } from '../../../';
const CopyableIcon = React.createClass({
getInitialState() {
return {
class CopyableIcon extends React.Component {
constructor(props) {
super(props);
this.state = {
justCopied: false
};
},
onCopied() {
}
onCopied = () => {
this.setState({ justCopied: true }, () => {
setTimeout(() => {
this.setState({ justCopied: false });
}, 1000);
});
},
}
render() {
const text = `<Icon type="${this.props.type}" />`;
return (
@ -27,14 +30,13 @@ const CopyableIcon = React.createClass({
</CopyToClipboard>
);
}
});
}
export default class IconSet extends React.Component {
static defaultProps = {
icons: []
}
const IconSet = React.createClass({
getDefaultProps() {
return {
icons: []
};
},
render() {
const className = this.props.className;
const listClassName = classNames({
@ -48,6 +50,4 @@ const IconSet = React.createClass({
</ul>
);
}
});
export default IconSet;
}