@@ -7,7 +7,7 @@ import { withRouter, Link } from 'react-router';
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
12
import { prop , remSize } from '../../theme' ;
13
13
import SketchList from '../IDE/components/SketchList' ;
@@ -16,6 +16,8 @@ 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' ;
19
21
20
22
const EXAMPLE_USERNAME = 'p5' ;
21
23
@@ -94,10 +96,11 @@ const Panels = {
94
96
assets : AssetList
95
97
} ;
96
98
97
- const CreatePathname = {
98
- sketches : '/mobile' ,
99
- collections : '/mobile/:username/collections/create' ,
100
- } ;
99
+
100
+ const navOptions = username => [
101
+ { title : 'Create Sketch' , href : '/mobile' } ,
102
+ { title : 'Create Collection' , href : `/mobile/${ username } /collections/create` }
103
+ ] ;
101
104
102
105
103
106
const getPanel = ( pathname ) => {
@@ -106,35 +109,52 @@ const getPanel = (pathname) => {
106
109
return matches && matches . length > 0 && matches [ 0 ] ;
107
110
} ;
108
111
109
- const getCreatePathname = ( panel , username ) => ( CreatePathname [ panel ] || '#' ) . replace ( ':username' , username ) ;
112
+ const NavItem = styled . li `
113
+ position: relative;
114
+ ` ;
115
+
110
116
111
117
const isOwner = ( user , params ) => user && params && user . username === params . username ;
112
118
113
119
const renderPanel = ( name , props ) => ( Component => ( Component && < Component { ...props } mobile /> ) ) ( Panels [ name ] ) ;
114
120
115
121
const MobileDashboard = ( { params, location } ) => {
116
122
const user = useSelector ( state => state . user ) ;
117
- const { username } = params ;
123
+ const { username : paramsUsername } = params ;
118
124
const { pathname } = location ;
119
125
120
126
const Tabs = Object . keys ( Panels ) ;
121
- const isExamples = username === EXAMPLE_USERNAME ;
127
+ const isExamples = paramsUsername === EXAMPLE_USERNAME ;
122
128
const panel = getPanel ( pathname ) ;
123
129
130
+
131
+ const [ toggleNavDropdown , NavDropdown ] = useAsModal ( < Dropdown
132
+ items = { navOptions ( user . username ) }
133
+ align = "right"
134
+ /> ) ;
135
+
124
136
return (
125
137
< Screen fullscreen key = { pathname } >
126
138
< Header slim inverted title = { isExamples ? 'Examples' : 'My Stuff' } >
139
+ < NavItem >
140
+ < IconButton
141
+ onClick = { toggleNavDropdown }
142
+ icon = { MoreIcon }
143
+ aria-label = "Options"
144
+ />
145
+ < NavDropdown />
146
+
147
+ </ NavItem >
127
148
< IconButton to = "/mobile" icon = { ExitIcon } aria-label = "Return to ide view" />
128
149
</ Header >
129
150
130
151
131
152
< ContentWrapper slimheader >
132
153
< Subheader >
133
- { isOwner ( user , params ) && ( panel !== Tabs [ 2 ] ) && < SubheaderButton to = { getCreatePathname ( panel , username ) } > new</ SubheaderButton > }
134
154
{ panel === Tabs [ 0 ] && < SketchSearchbar /> }
135
155
{ panel === Tabs [ 1 ] && < CollectionSearchbar /> }
136
156
</ Subheader >
137
- { renderPanel ( panel , { username , key : pathname } ) }
157
+ { renderPanel ( panel , { paramsUsername , key : pathname } ) }
138
158
</ ContentWrapper >
139
159
< Footer >
140
160
{ ! isExamples &&
0 commit comments