@@ -7,68 +7,22 @@ import {
7
7
import { compose } from 'redux' ;
8
8
import { pathOr } from 'ramda' ;
9
9
10
- import {
11
- withStyles ,
12
- Theme ,
13
- WithStyles ,
14
- StyleRulesCallback ,
15
- } from 'material-ui/styles' ;
16
- import Button from 'material-ui/Button' ;
17
-
10
+ import WithDocumentation from 'src/components/WithDocumentation' ;
18
11
19
12
import LinodesListView from './LinodesListView' ;
20
13
import LinodesGridView from './LinodesGridView' ;
21
- import ViewList from 'material-ui-icons/ViewList' ;
22
- import ViewModule from 'material-ui-icons/ViewModule' ;
23
-
24
- import WithDocumentation from 'src/components/WithDocumentation' ;
25
-
26
14
import ListLinodesEmptyState from './ListLinodesEmptyState' ;
15
+ import ToggleBox from './ToggleBox' ;
27
16
28
17
import './linodes.css' ;
29
18
30
- type CSSClasses =
31
- 'toggleBox'
32
- | 'toggleButton'
33
- | 'toggleButtonActive'
34
- | 'toggleButtonLeft'
35
- | 'toggleButtonRight'
36
- | 'icon' ;
37
-
38
- const styles : StyleRulesCallback < CSSClasses > = ( theme : Theme ) => ( {
39
- toggleBox : {
40
- marginBottom : theme . spacing . unit * 2 ,
41
- } ,
42
- toggleButton : {
43
- border : '1px solid #333' ,
44
- } ,
45
- toggleButtonActive : {
46
- backgroundColor : '#333' ,
47
- color : '#f3f3f3' ,
48
- '&:hover' : {
49
- backgroundColor : '#333' ,
50
- } ,
51
- } ,
52
- toggleButtonLeft : {
53
- borderWidth : '1px 0 1px 1px' ,
54
- borderRadius : '5px 0 0 5px' ,
55
- } ,
56
- toggleButtonRight : {
57
- borderWidth : '1px 1px 1px 0' ,
58
- borderRadius : '0 5px 5px 0' ,
59
- } ,
60
- icon : {
61
- marginRight : theme . spacing . unit ,
62
- } ,
63
- } ) ;
64
-
65
19
interface Props {
66
20
linodes : Linode . Linode [ ] ;
67
21
images : Linode . Image [ ] ;
68
22
types : Linode . LinodeType [ ] ;
69
23
}
70
24
71
- type CombinedProps = Props & WithStyles < CSSClasses > & RouteComponentProps < { } > ;
25
+ type CombinedProps = Props & RouteComponentProps < { } > ;
72
26
73
27
class ListLinodes extends React . Component < CombinedProps > {
74
28
static defaultProps = {
@@ -102,48 +56,20 @@ class ListLinodes extends React.Component<CombinedProps> {
102
56
} ,
103
57
] ;
104
58
105
- changeViewStyle ( style : string ) {
59
+ changeViewStyle = ( style : string ) => {
106
60
const { history } = this . props ;
107
61
history . push ( `#${ style } ` ) ;
108
62
}
109
63
110
- toggleBox ( ) {
111
- const { classes, location : { hash } } = this . props ;
112
-
113
- return (
114
- < div className = { classes . toggleBox } >
115
- < Button
116
- onClick = { ( ) => this . changeViewStyle ( 'list' ) }
117
- className = { `
118
- ${ hash !== '#grid' && classes . toggleButtonActive }
119
- ${ classes . toggleButton }
120
- ${ classes . toggleButtonLeft } `
121
- }
122
- >
123
- < ViewList className = { classes . icon } />
124
- List
125
- </ Button >
126
- < Button
127
- onClick = { ( ) => this . changeViewStyle ( 'grid' ) }
128
- className = { `
129
- ${ hash === '#grid' && classes . toggleButtonActive }
130
- ${ classes . toggleButton }
131
- ${ classes . toggleButtonRight } `
132
- }
133
- >
134
- < ViewModule className = { classes . icon } />
135
- Grid
136
- </ Button >
137
- </ div >
138
- ) ;
139
- }
140
-
141
64
listLinodes ( ) {
142
65
const { location : { hash } } = this . props ;
143
66
144
67
return (
145
68
< React . Fragment >
146
- { this . toggleBox ( ) }
69
+ < ToggleBox
70
+ handleClick = { this . changeViewStyle }
71
+ status = { hash === '#grid' ? 'grid' : 'list' }
72
+ />
147
73
{ hash === '#grid'
148
74
? < LinodesGridView
149
75
linodes = { this . props . linodes }
@@ -183,6 +109,5 @@ const mapStateToProps = (state: any) => ({
183
109
184
110
export default compose (
185
111
connect < Props > ( mapStateToProps ) ,
186
- withStyles ( styles , { withTheme : true } ) ,
187
112
withRouter ,
188
113
) ( ListLinodes ) ;
0 commit comments