@@ -2,27 +2,30 @@ import React from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import styled from 'styled-components' ;
4
4
import { useSelector } from 'react-redux' ;
5
- import { withRouter , Link } from 'react-router' ;
5
+ import { withRouter } from 'react-router' ;
6
6
7
7
import Screen from '../../components/mobile/MobileScreen' ;
8
8
import Header from '../../components/mobile/Header' ;
9
9
import IconButton from '../../components/mobile/IconButton' ;
10
- import { ExitIcon } from '../../common/icons' ;
10
+ import { ExitIcon , MoreIcon } from '../../common/icons' ;
11
11
import Footer from '../../components/mobile/Footer' ;
12
- import { prop , remSize } from '../../theme' ;
12
+ import { remSize , prop } from '../../theme' ;
13
13
import SketchList from '../IDE/components/SketchList' ;
14
14
import CollectionList from '../IDE/components/CollectionList' ;
15
15
import AssetList from '../IDE/components/AssetList' ;
16
16
import Content from './MobileViewContent' ;
17
17
import { SketchSearchbar , CollectionSearchbar } from '../IDE/components/Searchbar' ;
18
18
import Button from '../../common/Button' ;
19
+ import useAsModal from '../../components/useAsModal' ;
20
+ import Dropdown from '../../components/Dropdown' ;
21
+ import FooterTabSwitcher from '../../components/mobile/TabSwitcher' ;
22
+ import FooterTab from '../../components/mobile/Tab' ;
19
23
20
24
const EXAMPLE_USERNAME = 'p5' ;
21
25
22
26
const ContentWrapper = styled ( Content ) `
23
27
table {
24
28
table-layout: fixed;
25
- /* white-space: nowrap; */
26
29
}
27
30
28
31
td ,thead button {
@@ -31,38 +34,47 @@ const ContentWrapper = styled(Content)`
31
34
text-align: left;
32
35
};
33
36
34
- thead th { padding-left: 0; }
35
-
36
- thead th:not(:first-child), tbody td {
37
- width: ${ remSize ( 54 ) } ;
38
- }
39
-
40
- tbody th { font-weight: bold; };
41
37
42
38
tbody th {
43
- font-size: ${ remSize ( 12 ) } ;
39
+ font-size: ${ remSize ( 16 ) } ;
44
40
width: 100%;
45
- padding-right: ${ remSize ( 12 ) }
41
+ padding-right: ${ remSize ( 12 ) } ;
42
+ font-weight: bold;
43
+ display: flex;
44
+ grid-area: name;
46
45
};
47
46
48
- tbody td {
49
- text-align: center;
47
+ tbody td, thead th {
48
+ justify-self: stretch;
49
+ align-self: flex-end;
50
+ color: ${ prop ( 'primaryTextColor' ) }
50
51
}
51
52
52
- .sketch-list__sort-button { padding: 0 }
53
+ tbody td:nth-child(2) { grid-column-start: 2 }
54
+ tbody td:last-child { justify-self: end; text-align: end; }
55
+
56
+ /* .sketch-list__sort-button { padding: 0 } */
53
57
tbody {
54
58
height: ${ remSize ( 48 ) } ;
55
59
}
56
60
57
- .sketches-table-container { padding-bottom: ${ remSize ( 160 ) } }
58
- ` ;
61
+ .sketches-table-container {
62
+ padding-bottom: ${ remSize ( 160 ) } ;
63
+ background: ${ prop ( 'SketchList.background' ) } ;
64
+ }
65
+ .sketches-table__row {
66
+ background: ${ prop ( 'SketchList.card.background' ) } !important; height: auto
67
+ }
59
68
60
- const FooterTab = styled ( Link ) `
61
- background: ${ props => prop ( props . selected ? 'backgroundColor' : 'MobilePanel.default.foreground' ) } ;
62
- color: ${ props => prop ( `MobilePanel.default.${ props . selected ? 'foreground' : 'background' } ` ) } ;
63
- padding: ${ remSize ( 8 ) } ${ remSize ( 16 ) } ;
64
- width: 100%;
65
- display: flex;
69
+ tr {
70
+ align-self: start;
71
+ display: grid;
72
+ grid-template-columns: repeat(4,1fr);
73
+ grid-template-areas: "name name name name" "none content content content";
74
+
75
+ border-radius: ${ remSize ( 4 ) } ; padding: ${ remSize ( 8 ) } ;
76
+ box-shadow: 0 0 18px 0 ${ prop ( 'shadowColor' ) } ;
77
+ };
66
78
` ;
67
79
68
80
const Subheader = styled . div `
@@ -81,23 +93,17 @@ const SubheaderButton = styled(Button)`
81
93
border-radius: 0px !important;
82
94
` ;
83
95
84
-
85
- const FooterTabSwitcher = styled . div `
86
- display: flex;
87
-
88
- h3 { text-align: center; width: 100%; }
89
- ` ;
90
-
91
96
const Panels = {
92
97
sketches : SketchList ,
93
98
collections : CollectionList ,
94
99
assets : AssetList
95
100
} ;
96
101
97
- const CreatePathname = {
98
- sketches : '/mobile' ,
99
- collections : '/mobile/:username/collections/create' ,
100
- } ;
102
+
103
+ const navOptions = username => [
104
+ { title : 'Create Sketch' , href : '/mobile' } ,
105
+ { title : 'Create Collection' , href : `/mobile/${ username } /collections/create` }
106
+ ] ;
101
107
102
108
103
109
const getPanel = ( pathname ) => {
@@ -106,35 +112,52 @@ const getPanel = (pathname) => {
106
112
return matches && matches . length > 0 && matches [ 0 ] ;
107
113
} ;
108
114
109
- const getCreatePathname = ( panel , username ) => ( CreatePathname [ panel ] || '#' ) . replace ( ':username' , username ) ;
115
+ const NavItem = styled . li `
116
+ position: relative;
117
+ ` ;
118
+
110
119
111
120
const isOwner = ( user , params ) => user && params && user . username === params . username ;
112
121
113
122
const renderPanel = ( name , props ) => ( Component => ( Component && < Component { ...props } mobile /> ) ) ( Panels [ name ] ) ;
114
123
115
124
const MobileDashboard = ( { params, location } ) => {
116
125
const user = useSelector ( state => state . user ) ;
117
- const { username } = params ;
126
+ const { username : paramsUsername } = params ;
118
127
const { pathname } = location ;
119
128
120
129
const Tabs = Object . keys ( Panels ) ;
121
- const isExamples = username === EXAMPLE_USERNAME ;
130
+ const isExamples = paramsUsername === EXAMPLE_USERNAME ;
122
131
const panel = getPanel ( pathname ) ;
123
132
133
+
134
+ const [ toggleNavDropdown , NavDropdown ] = useAsModal ( < Dropdown
135
+ items = { navOptions ( user . username ) }
136
+ align = "right"
137
+ /> ) ;
138
+
124
139
return (
125
140
< Screen fullscreen key = { pathname } >
126
141
< Header slim inverted title = { isExamples ? 'Examples' : 'My Stuff' } >
142
+ < NavItem >
143
+ < IconButton
144
+ onClick = { toggleNavDropdown }
145
+ icon = { MoreIcon }
146
+ aria-label = "Options"
147
+ />
148
+ < NavDropdown />
149
+
150
+ </ NavItem >
127
151
< IconButton to = "/mobile" icon = { ExitIcon } aria-label = "Return to ide view" />
128
152
</ Header >
129
153
130
154
131
155
< ContentWrapper slimheader >
132
156
< Subheader >
133
- { isOwner ( user , params ) && ( panel !== Tabs [ 2 ] ) && < SubheaderButton to = { getCreatePathname ( panel , username ) } > new</ SubheaderButton > }
134
157
{ panel === Tabs [ 0 ] && < SketchSearchbar /> }
135
158
{ panel === Tabs [ 1 ] && < CollectionSearchbar /> }
136
159
</ Subheader >
137
- { renderPanel ( panel , { username, key : pathname } ) }
160
+ { renderPanel ( panel , { username : paramsUsername , key : pathname } ) }
138
161
</ ContentWrapper >
139
162
< Footer >
140
163
{ ! isExamples &&
0 commit comments