11import * as React from 'react'
2- import styled from 'styled-components'
2+ import styled , { StyledComponentClass } from 'styled-components'
33import { List } from 'react-md/lib/Lists'
4+ import { Button , ButtonProps } from 'react-md/lib/Buttons'
45import { Divider } from 'react-md/lib/Dividers'
5- import { Button } from 'react-md/lib/Buttons'
66
77import { DraggableUser } from './User'
88import { AddUserDialog } from './AddUserDialog'
99
10- const Container = styled . span `
10+ interface IContainerProps {
11+ hidden : boolean
12+ }
13+
14+ const Container = styled . div `
15+ position: fixed;
16+ right: 0;
17+ top: 0;
18+ bottom: 0;
1119 display: flex;
1220 flex-direction: column;
13- justify-content: center;
21+ min-width: 175px;
22+ height: 100%;
1423 background: #fff;
15- min-width: 170px;
24+
25+ @media only screen and (max-width: 600px) {
26+ left: 0;
27+ opacity: ${ ( p : IContainerProps ) => ( p . hidden ? 1 : 0 ) } ;
28+ pointer-events: ${ ( p : IContainerProps ) => ( p . hidden ? 'all' : 'none' ) } ;
29+ transition: opacity: 0.25s;
30+ }
31+
32+ @media only screen and (min-width: 1025px) {
33+ min-width: 225px;
34+ }
35+ `
36+
37+ const Wrapper = styled . div `
38+ display: flex;
39+ flex-direction: column;
40+ margin: auto 0;
41+ max-height: 100%;
42+ `
43+
44+ const ButtonWrapper = styled . div `
45+ display: flex;
46+ justify-content: space-around;
47+ `
48+
49+ const ButtonHideOnBigDevices : StyledComponentClass < ButtonProps , { } > = styled (
50+ Button
51+ ) `
52+ @media only screen and (min-width: 600px) {
53+ display: none;
54+ }
1655`
1756
1857interface IProps {
1958 readonly users : ReadonlyArray < string >
2059 readonly activeUser : number
60+ readonly hideUserList : boolean
2161 readonly moveUser : ( dragIndex : number , hoverIndex : number ) => void
2262 readonly addUser : ( name : string ) => void
2363 readonly removeUser : ( index : number ) => void
2464 readonly setActive : ( index : number ) => void
65+ readonly toggleHideUserList : ( ) => void
2566}
2667
2768interface IState {
@@ -43,33 +84,48 @@ export class UserList extends React.PureComponent<IProps, IState> {
4384
4485 public render ( ) {
4586 return (
46- < Container >
47- < List >
48- { this . props . users . map ( ( user , i ) => (
49- < React . Fragment key = { user } >
50- { i !== 0 && < Divider /> }
51-
52- < DraggableUser
53- user = { user }
54- active = { this . props . activeUser === i }
55- index = { i }
56- moveUser = { this . props . moveUser }
57- removeUser = { this . props . removeUser }
58- setActive = { this . props . setActive }
59- />
60- </ React . Fragment >
61- ) ) }
62- </ List >
63-
64- < Button
65- raised
66- primary
67- iconChildren = "add"
68- style = { { margin : '5px 10px 0' } }
69- onClick = { this . showDialog }
70- >
71- Add User
72- </ Button >
87+ < Container hidden = { this . props . hideUserList } >
88+ < Wrapper >
89+ < List style = { { overflowY : 'auto' } } >
90+ { this . props . users . map ( ( user , i ) => (
91+ < React . Fragment key = { user } >
92+ { i !== 0 && < Divider /> }
93+
94+ < DraggableUser
95+ user = { user }
96+ active = { this . props . activeUser === i }
97+ index = { i }
98+ moveUser = { this . props . moveUser }
99+ removeUser = { this . props . removeUser }
100+ setActive = { this . props . setActive }
101+ />
102+ </ React . Fragment >
103+ ) ) }
104+ </ List >
105+
106+ < Divider />
107+
108+ < ButtonWrapper >
109+ < Button
110+ raised
111+ primary
112+ iconChildren = "add"
113+ style = { { margin : '15px' , width : '100%' } }
114+ onClick = { this . showDialog }
115+ >
116+ Add User
117+ </ Button >
118+
119+ < ButtonHideOnBigDevices
120+ raised
121+ iconChildren = "arrow_back"
122+ onClick = { this . props . toggleHideUserList }
123+ style = { { margin : '15px' , width : '100%' } }
124+ >
125+ Go back
126+ </ ButtonHideOnBigDevices >
127+ </ ButtonWrapper >
128+ </ Wrapper >
73129
74130 < AddUserDialog
75131 visible = { this . state . dialogVisible }
0 commit comments