1- import React , { createClass , PropTypes } from 'react' ;
1+ import React , { Component , PropTypes } from 'react' ;
22import Drawer from 'material-ui/Drawer' ;
33import { List , ListItem , MakeSelectable } from 'material-ui/List' ;
44import Divider from 'material-ui/Divider' ;
@@ -10,29 +10,43 @@ import {cyan500} from 'material-ui/styles/colors';
1010
1111const 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
271268export default AppNavDrawer ;
0 commit comments