@@ -7,7 +7,7 @@ import { withRouter, Link } from 'react-router';
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' ;
1212import { prop , remSize } from '../../theme' ;
1313import SketchList from '../IDE/components/SketchList' ;
@@ -16,6 +16,8 @@ import 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' ;
1921
2022const EXAMPLE_USERNAME = 'p5' ;
2123
@@ -94,10 +96,11 @@ const Panels = {
9496 assets : AssetList
9597} ;
9698
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+ ] ;
101104
102105
103106const getPanel = ( pathname ) => {
@@ -106,35 +109,52 @@ const getPanel = (pathname) => {
106109 return matches && matches . length > 0 && matches [ 0 ] ;
107110} ;
108111
109- const getCreatePathname = ( panel , username ) => ( CreatePathname [ panel ] || '#' ) . replace ( ':username' , username ) ;
112+ const NavItem = styled . li `
113+ position: relative;
114+ ` ;
115+
110116
111117const isOwner = ( user , params ) => user && params && user . username === params . username ;
112118
113119const renderPanel = ( name , props ) => ( Component => ( Component && < Component { ...props } mobile /> ) ) ( Panels [ name ] ) ;
114120
115121const MobileDashboard = ( { params, location } ) => {
116122 const user = useSelector ( state => state . user ) ;
117- const { username } = params ;
123+ const { username : paramsUsername } = params ;
118124 const { pathname } = location ;
119125
120126 const Tabs = Object . keys ( Panels ) ;
121- const isExamples = username === EXAMPLE_USERNAME ;
127+ const isExamples = paramsUsername === EXAMPLE_USERNAME ;
122128 const panel = getPanel ( pathname ) ;
123129
130+
131+ const [ toggleNavDropdown , NavDropdown ] = useAsModal ( < Dropdown
132+ items = { navOptions ( user . username ) }
133+ align = "right"
134+ /> ) ;
135+
124136 return (
125137 < Screen fullscreen key = { pathname } >
126138 < 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 >
127148 < IconButton to = "/mobile" icon = { ExitIcon } aria-label = "Return to ide view" />
128149 </ Header >
129150
130151
131152 < ContentWrapper slimheader >
132153 < Subheader >
133- { isOwner ( user , params ) && ( panel !== Tabs [ 2 ] ) && < SubheaderButton to = { getCreatePathname ( panel , username ) } > new</ SubheaderButton > }
134154 { panel === Tabs [ 0 ] && < SketchSearchbar /> }
135155 { panel === Tabs [ 1 ] && < CollectionSearchbar /> }
136156 </ Subheader >
137- { renderPanel ( panel , { username , key : pathname } ) }
157+ { renderPanel ( panel , { paramsUsername , key : pathname } ) }
138158 </ ContentWrapper >
139159 < Footer >
140160 { ! isExamples &&
0 commit comments