Skip to content

Commit 2ee7024

Browse files
Merge pull request #4126 from oliviertassinari/with-width-hoc
[Style] Add a withWidth HOC
2 parents 99ac508 + 013f1c3 commit 2ee7024

66 files changed

Lines changed: 737 additions & 816 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module.exports = {
110110
'react/no-unknown-property': 'error',
111111
'react/no-is-mounted': 'error',
112112
'react/prefer-arrow-callback': 'off', // Wishlist, one day
113-
'react/prefer-es6-class': 'off', // Wishlist, one day
113+
'react/prefer-es6-class': 'error',
114114
'react/prop-types': 'error',
115115
'react/react-in-jsx-scope': 'error',
116116
'react/require-extension': 'error',

docs/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"doctrine": "^1.1.0",
3030
"eslint": "^2.5.1",
3131
"eslint-plugin-babel": "^3.1.0",
32-
"eslint-plugin-react": "^4.0.0",
32+
"eslint-plugin-react": "^5.0.1",
3333
"highlight.js": "^9.0.0",
3434
"history": "^2.0.0",
3535
"html-webpack-plugin": "^2.8.1",
@@ -39,7 +39,6 @@
3939
"marked": "^0.3.5",
4040
"raw-loader": "^0.5.1",
4141
"react-addons-perf": "^15.0.1",
42-
"react-addons-pure-render-mixin": "^15.0.1",
4342
"react-docgen": "^2.4.0",
4443
"react-hot-loader": "^1.2.8",
4544
"react-motion": "^0.4.2",

docs/src/app/components/AppNavDrawer.js

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {createClass, PropTypes} from 'react';
1+
import React, {Component, PropTypes} from 'react';
22
import Drawer from 'material-ui/Drawer';
33
import {List, ListItem, MakeSelectable} from 'material-ui/List';
44
import Divider from 'material-ui/Divider';
@@ -10,29 +10,43 @@ import {cyan500} from 'material-ui/styles/colors';
1010

1111
const SelectableList = MakeSelectable(List);
1212

13-
const AppNavDrawer = createClass({
13+
const styles = {
14+
logo: {
15+
cursor: 'pointer',
16+
fontSize: 24,
17+
color: typography.textFullWhite,
18+
lineHeight: `${spacing.desktopKeylineIncrement}px`,
19+
fontWeight: typography.fontWeightLight,
20+
backgroundColor: cyan500,
21+
paddingLeft: spacing.desktopGutter,
22+
marginBottom: 8,
23+
},
24+
version: {
25+
paddingLeft: spacing.desktopGutterLess,
26+
fontSize: 16,
27+
},
28+
};
1429

15-
propTypes: {
30+
class AppNavDrawer extends Component {
31+
static propTypes = {
1632
docked: PropTypes.bool.isRequired,
1733
location: PropTypes.object.isRequired,
1834
onChangeList: PropTypes.func.isRequired,
1935
onRequestChangeNavDrawer: PropTypes.func.isRequired,
2036
open: PropTypes.bool.isRequired,
2137
style: PropTypes.object,
22-
},
38+
};
2339

24-
contextTypes: {
40+
static contextTypes = {
2541
muiTheme: PropTypes.object.isRequired,
2642
router: PropTypes.object.isRequired,
27-
},
43+
};
2844

29-
getInitialState: () => {
30-
return ({
31-
muiVersions: [],
32-
});
33-
},
45+
state = {
46+
muiVersions: [],
47+
};
3448

35-
componentDidMount: function() {
49+
componentDidMount() {
3650
const self = this;
3751
const url = '/versions.json';
3852
const request = new XMLHttpRequest();
@@ -48,9 +62,9 @@ const AppNavDrawer = createClass({
4862

4963
request.open('GET', url, true);
5064
request.send();
51-
},
65+
}
5266

53-
firstNonPreReleaseVersion: function() {
67+
firstNonPreReleaseVersion() {
5468
let version;
5569
for (let i = 0; i < this.state.muiVersions.length; i++) {
5670
version = this.state.muiVersions[i];
@@ -60,50 +74,33 @@ const AppNavDrawer = createClass({
6074
}
6175
}
6276
return version;
63-
},
77+
}
6478

65-
handleVersionChange: function(event, index, value) {
79+
handleVersionChange = (event, index, value) => {
6680
if (value === this.firstNonPreReleaseVersion()) {
6781
window.location = 'http://www.material-ui.com/';
6882
} else {
6983
window.location = `http://www.material-ui.com/${value}`;
7084
}
71-
},
85+
};
7286

73-
currentVersion: function() {
87+
currentVersion() {
7488
if (window.location.hostname === 'localhost') return this.state.muiVersions[0];
7589
if (window.location.pathname === '/') {
7690
return this.firstNonPreReleaseVersion();
7791
} else {
7892
return window.location.pathname.replace(/\//g, '');
7993
}
80-
},
94+
}
8195

82-
handleRequestChangeLink(event, value) {
96+
handleRequestChangeLink = (event, value) => {
8397
window.location = value;
84-
},
98+
};
8599

86-
handleTouchTapHeader() {
100+
handleTouchTapHeader = () => {
87101
this.context.router.push('/');
88102
this.props.onRequestChangeNavDrawer(false);
89-
},
90-
91-
styles: {
92-
logo: {
93-
cursor: 'pointer',
94-
fontSize: 24,
95-
color: typography.textFullWhite,
96-
lineHeight: `${spacing.desktopKeylineIncrement}px`,
97-
fontWeight: typography.fontWeightLight,
98-
backgroundColor: cyan500,
99-
paddingLeft: spacing.desktopGutter,
100-
marginBottom: 8,
101-
},
102-
version: {
103-
paddingLeft: spacing.desktopGutterLess,
104-
fontSize: 16,
105-
},
106-
},
103+
};
107104

108105
render() {
109106
const {
@@ -123,10 +120,10 @@ const AppNavDrawer = createClass({
123120
onRequestChange={onRequestChangeNavDrawer}
124121
containerStyle={{zIndex: zIndex.navDrawer - 100}}
125122
>
126-
<div style={this.styles.logo} onTouchTap={this.handleTouchTapHeader}>
123+
<div style={styles.logo} onTouchTap={this.handleTouchTapHeader}>
127124
Material-UI
128125
</div>
129-
<span style={this.styles.version}>Version:</span>
126+
<span style={styles.version}>Version:</span>
130127
<DropDownMenu
131128
value={this.currentVersion()}
132129
onChange={this.handleVersionChange}
@@ -265,7 +262,7 @@ const AppNavDrawer = createClass({
265262
</SelectableList>
266263
</Drawer>
267264
);
268-
},
269-
});
265+
}
266+
}
270267

271268
export default AppNavDrawer;

docs/src/app/components/CodeExample/CodeBlock.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import React, {createClass, PropTypes} from 'react';
1+
import React, {Component, PropTypes} from 'react';
22
import MarkdownElement from '../MarkdownElement';
3-
import PureRenderMixin from 'react-addons-pure-render-mixin';
43
import transitions from 'material-ui/styles/transitions';
54
import CodeBlockTitle from './CodeBlockTitle';
65

@@ -31,25 +30,23 @@ const styles = {
3130
},
3231
};
3332

34-
const CodeBlock = createClass({
35-
propTypes: {
33+
class CodeBlock extends Component {
34+
static propTypes = {
3635
children: PropTypes.string,
3736
description: PropTypes.string,
3837
title: PropTypes.string,
39-
},
40-
mixins: [
41-
PureRenderMixin,
42-
],
43-
getInitialState: function() {
44-
return {
45-
expand: false,
46-
};
47-
},
48-
handleTouchTap() {
38+
};
39+
40+
state = {
41+
expand: false,
42+
};
43+
44+
handleTouchTap = () => {
4945
this.setState({
5046
expand: !this.state.expand,
5147
});
52-
},
48+
};
49+
5350
render() {
5451
const text = `\`\`\`js
5552
${this.props.children}
@@ -73,7 +70,7 @@ ${this.props.children}
7370
<MarkdownElement style={descriptionStyle} text={this.props.description} />
7471
</div>
7572
);
76-
},
77-
});
73+
}
74+
}
7875

7976
export default CodeBlock;

docs/src/app/components/ComponentDoc.js

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)