Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor/remove mixin #133

Merged
merged 8 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions examples/keyPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Menu, { SubMenu, Item as MenuItem } from 'rc-menu';
import createReactClass from 'create-react-class';

import 'rc-menu/assets/index.less';

const Test = createReactClass({
class Test extends React.Component {
onClick(info) {
console.log('click ', info);
},
}

getMenu() {
return (
Expand All @@ -33,14 +32,14 @@ const Test = createReactClass({
<MenuItem key="3">item3</MenuItem>
</Menu>
);
},
}

render() {
return (<div>
<div style={{ width: 400 }}>{this.getMenu()}</div>
</div>);
},
});
}
}


ReactDOM.render(<Test />, document.getElementById('__react-content'));
25 changes: 11 additions & 14 deletions examples/openKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Menu, { SubMenu, Item as MenuItem } from 'rc-menu';
import createReactClass from 'create-react-class';

import 'rc-menu/assets/index.less';

const Test = createReactClass({
getInitialState() {
return {
openKeys: [],
};
},
class Test extends React.Component {
state = {
openKeys: [],
};

onClick(info) {
console.log('click ', info);
},
}

onOpenChange(openKeys) {
onOpenChange = (openKeys) => {
console.log('onOpenChange', openKeys);
this.setState({
openKeys,
});
},
}

getMenu() {
return (
<Menu
Expand All @@ -43,14 +41,13 @@ const Test = createReactClass({
<MenuItem key="3">item3</MenuItem>
</Menu>
);
},
}

render() {
return (<div>
<div style={{ width: 400 }}>{this.getMenu()}</div>
</div>);
},
});

}
}

ReactDOM.render(<Test />, document.getElementById('__react-content'));
42 changes: 19 additions & 23 deletions examples/selectedKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,35 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Menu, { SubMenu, Item as MenuItem } from 'rc-menu';
import createReactClass from 'create-react-class';

import 'rc-menu/assets/index.less';

const Test = createReactClass({
getInitialState() {
return {
destroyed: false,
selectedKeys: [],
openKeys: [],
};
},
class Test extends React.Component {
state = {
destroyed: false,
selectedKeys: [],
openKeys: [],
};

onSelect(info) {
onSelect = (info) => {
console.log('selected ', info);
this.setState({
selectedKeys: info.selectedKeys,
});
},
};

onDeselect(info) {
console.log('deselect ', info);
},
}

onOpenChange(openKeys) {
onOpenChange = (openKeys) => {
console.log('onOpenChange ', openKeys);
this.setState({
openKeys,
});
},
};

onCheck(e) {
onCheck = (e) => {
const value = e.target.value;
if (e.target.checked) {
this.setState({
Expand All @@ -50,9 +47,9 @@ const Test = createReactClass({
selectedKeys,
});
}
},
};

onOpenCheck(e) {
onOpenCheck = (e) => {
const value = e.target.value;
if (e.target.checked) {
this.setState({
Expand All @@ -68,7 +65,7 @@ const Test = createReactClass({
openKeys,
});
}
},
};

getMenu() {
return (
Expand All @@ -91,13 +88,13 @@ const Test = createReactClass({
<MenuItem key="3">item3</MenuItem>
</Menu>
);
},
}

destroy() {
this.setState({
destroyed: true,
});
},
}

render() {
if (this.state.destroyed) {
Expand Down Expand Up @@ -141,8 +138,7 @@ const Test = createReactClass({

<div style={{ width: 400 }}>{this.getMenu()}</div>
</div>);
},
});

}
}

ReactDOM.render(<Test />, document.getElementById('__react-content'));
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@
"dependencies": {
"babel-runtime": "6.x",
"classnames": "2.x",
"create-react-class": "^15.5.2",
"dom-scroll-into-view": "1.x",
"mini-store": "^1.0.2",
"mini-store": "^1.1.0",
"prop-types": "^15.5.6",
"rc-animate": "2.x",
"rc-trigger": "^2.3.0",
Expand Down
25 changes: 9 additions & 16 deletions src/DOMWrap.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

const DOMWrap = createReactClass({
displayName: 'DOMWrap',

propTypes: {
export default class DOMWrap extends React.Component {
static propTypes = {
tag: PropTypes.string,
hiddenClassName: PropTypes.string,
visible: PropTypes.bool,
},
};

getDefaultProps() {
return {
tag: 'div',
className: '',
};
},
static defaultProps = {
tag: 'div',
className: '',
};

render() {
const props = { ...this.props };
Expand All @@ -28,7 +23,5 @@ const DOMWrap = createReactClass({
delete props.hiddenClassName;
delete props.visible;
return <Tag {...props} />;
},
});

export default DOMWrap;
}
}
21 changes: 8 additions & 13 deletions src/Divider.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

const Divider = createReactClass({
displayName: 'Divider',

propTypes: {
export default class Divider extends React.Component {
static propTypes = {
className: PropTypes.string,
rootPrefixCls: PropTypes.string,
},
};

getDefaultProps() {
static defaultProps = {
// To fix keyboard UX.
return { disabled: true };
},
disabled: true,
};

render() {
const { className = '', rootPrefixCls } = this.props;
return <li className={`${className} ${rootPrefixCls}-item-divider`}/>;
},
});

export default Divider;
}
}
Loading