@@ -2,27 +2,30 @@ import React from 'react';
22import PropTypes from 'prop-types' ;
33import styled from 'styled-components' ;
44import { useSelector } from 'react-redux' ;
5- import { withRouter , Link } from 'react-router' ;
5+ import { withRouter } from 'react-router' ;
66
77import Screen from '../../components/mobile/MobileScreen' ;
88import Header from '../../components/mobile/Header' ;
99import IconButton from '../../components/mobile/IconButton' ;
10- import { ExitIcon } from '../../common/icons' ;
10+ import { ExitIcon , MoreIcon } from '../../common/icons' ;
1111import Footer from '../../components/mobile/Footer' ;
12- import { prop , remSize } from '../../theme' ;
12+ import { remSize , prop } from '../../theme' ;
1313import SketchList from '../IDE/components/SketchList' ;
1414import CollectionList from '../IDE/components/CollectionList' ;
1515import AssetList from '../IDE/components/AssetList' ;
1616import Content from './MobileViewContent' ;
1717import { SketchSearchbar , CollectionSearchbar } from '../IDE/components/Searchbar' ;
1818import 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' ;
1923
2024const EXAMPLE_USERNAME = 'p5' ;
2125
2226const ContentWrapper = styled ( Content ) `
2327 table {
2428 table-layout: fixed;
25- /* white-space: nowrap; */
2629 }
2730
2831 td ,thead button {
@@ -31,38 +34,47 @@ const ContentWrapper = styled(Content)`
3134 text-align: left;
3235 };
3336
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; };
4137
4238 tbody th {
43- font-size: ${ remSize ( 12 ) } ;
39+ font-size: ${ remSize ( 16 ) } ;
4440 width: 100%;
45- padding-right: ${ remSize ( 12 ) }
41+ padding-right: ${ remSize ( 12 ) } ;
42+ font-weight: bold;
43+ display: flex;
44+ grid-area: name;
4645 };
4746
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' ) }
5051 }
5152
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 } */
5357 tbody {
5458 height: ${ remSize ( 48 ) } ;
5559 }
5660
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+ }
5968
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+ };
6678` ;
6779
6880const Subheader = styled . div `
@@ -81,23 +93,17 @@ const SubheaderButton = styled(Button)`
8193 border-radius: 0px !important;
8294` ;
8395
84-
85- const FooterTabSwitcher = styled . div `
86- display: flex;
87-
88- h3 { text-align: center; width: 100%; }
89- ` ;
90-
9196const Panels = {
9297 sketches : SketchList ,
9398 collections : CollectionList ,
9499 assets : AssetList
95100} ;
96101
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+ ] ;
101107
102108
103109const getPanel = ( pathname ) => {
@@ -106,35 +112,52 @@ const getPanel = (pathname) => {
106112 return matches && matches . length > 0 && matches [ 0 ] ;
107113} ;
108114
109- const getCreatePathname = ( panel , username ) => ( CreatePathname [ panel ] || '#' ) . replace ( ':username' , username ) ;
115+ const NavItem = styled . li `
116+ position: relative;
117+ ` ;
118+
110119
111120const isOwner = ( user , params ) => user && params && user . username === params . username ;
112121
113122const renderPanel = ( name , props ) => ( Component => ( Component && < Component { ...props } mobile /> ) ) ( Panels [ name ] ) ;
114123
115124const MobileDashboard = ( { params, location } ) => {
116125 const user = useSelector ( state => state . user ) ;
117- const { username } = params ;
126+ const { username : paramsUsername } = params ;
118127 const { pathname } = location ;
119128
120129 const Tabs = Object . keys ( Panels ) ;
121- const isExamples = username === EXAMPLE_USERNAME ;
130+ const isExamples = paramsUsername === EXAMPLE_USERNAME ;
122131 const panel = getPanel ( pathname ) ;
123132
133+
134+ const [ toggleNavDropdown , NavDropdown ] = useAsModal ( < Dropdown
135+ items = { navOptions ( user . username ) }
136+ align = "right"
137+ /> ) ;
138+
124139 return (
125140 < Screen fullscreen key = { pathname } >
126141 < 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 >
127151 < IconButton to = "/mobile" icon = { ExitIcon } aria-label = "Return to ide view" />
128152 </ Header >
129153
130154
131155 < ContentWrapper slimheader >
132156 < Subheader >
133- { isOwner ( user , params ) && ( panel !== Tabs [ 2 ] ) && < SubheaderButton to = { getCreatePathname ( panel , username ) } > new</ SubheaderButton > }
134157 { panel === Tabs [ 0 ] && < SketchSearchbar /> }
135158 { panel === Tabs [ 1 ] && < CollectionSearchbar /> }
136159 </ Subheader >
137- { renderPanel ( panel , { username, key : pathname } ) }
160+ { renderPanel ( panel , { username : paramsUsername , key : pathname } ) }
138161 </ ContentWrapper >
139162 < Footer >
140163 { ! isExamples &&
0 commit comments