@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
44import { useDispatch , useSelector } from 'react-redux' ;
55import {
66 closeProjectOptions ,
7+ collapseSidebar ,
78 newFile ,
89 newFolder ,
910 openProjectOptions ,
@@ -13,27 +14,29 @@ import { selectRootFile } from '../selectors/files';
1314import { getAuthenticated , selectCanEditSketch } from '../selectors/users' ;
1415
1516import ConnectedFileNode from './FileNode' ;
16-
17- import DownArrowIcon from '../../../images/down-filled-triangle.svg ' ;
17+ import { PlusIcon } from '../../../common/icons' ;
18+ import { FileDrawer } from './Editor/MobileEditor ' ;
1819
1920// TODO: use a generic Dropdown UI component
2021
2122export default function SideBar ( ) {
2223 const { t } = useTranslation ( ) ;
2324 const dispatch = useDispatch ( ) ;
2425
25- const [ isFocused , setIsFocused ] = useState ( false ) ;
26-
2726 const rootFile = useSelector ( selectRootFile ) ;
27+ const ide = useSelector ( ( state ) => state . ide ) ;
2828 const projectOptionsVisible = useSelector (
2929 ( state ) => state . ide . projectOptionsVisible
3030 ) ;
3131 const isExpanded = useSelector ( ( state ) => state . ide . sidebarIsExpanded ) ;
3232 const canEditProject = useSelector ( selectCanEditSketch ) ;
33- const isAuthenticated = useSelector ( getAuthenticated ) ;
3433
3534 const sidebarOptionsRef = useRef ( null ) ;
3635
36+ const [ isFocused , setIsFocused ] = useState ( false ) ;
37+
38+ const isAuthenticated = useSelector ( getAuthenticated ) ;
39+
3740 const onBlurComponent = ( ) => {
3841 setIsFocused ( false ) ;
3942 setTimeout ( ( ) => {
@@ -65,69 +68,84 @@ export default function SideBar() {
6568 } ) ;
6669
6770 return (
68- < section className = { sidebarClass } >
69- < header className = "sidebar__header" onContextMenu = { toggleProjectOptions } >
70- < h3 className = "sidebar__title" >
71- < span > { t ( 'Sidebar.Title' ) } </ span >
72- </ h3 >
73- < div className = "sidebar__icons" >
74- < button
75- aria-label = { t ( 'Sidebar.ToggleARIA' ) }
76- className = "sidebar__add"
77- tabIndex = "0"
78- ref = { sidebarOptionsRef }
79- onClick = { toggleProjectOptions }
80- onBlur = { onBlurComponent }
81- onFocus = { onFocusComponent }
82- >
83- < DownArrowIcon focusable = "false" aria-hidden = "true" / >
84- </ button >
85- < ul className = "sidebar__project-options" >
86- < li >
87- < button
88- aria-label = { t ( 'Sidebar.AddFolderARIA' ) }
89- onClick = { ( ) => {
90- dispatch ( newFolder ( rootFile . id ) ) ;
91- setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
92- } }
93- onBlur = { onBlurComponent }
94- onFocus = { onFocusComponent }
95- >
96- { t ( 'Sidebar.AddFolder' ) }
97- </ button >
98- </ li >
99- < li >
100- < button
101- aria-label = { t ( 'Sidebar.AddFileARIA' ) }
102- onClick = { ( ) => {
103- dispatch ( newFile ( rootFile . id ) ) ;
104- setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
105- } }
106- onBlur = { onBlurComponent }
107- onFocus = { onFocusComponent }
108- >
109- { t ( 'Sidebar.AddFile' ) }
110- </ button >
111- </ li >
112- { isAuthenticated && (
71+ < FileDrawer >
72+ { ide . sidebarIsExpanded && (
73+ < button
74+ data-backdrop = "filedrawer"
75+ onClick = { ( ) => {
76+ dispatch ( collapseSidebar ( ) ) ;
77+ } }
78+ >
79+ { ' ' }
80+ </ button >
81+ ) }
82+ < section className = { sidebarClass } >
83+ < header
84+ className = "sidebar__header"
85+ onContextMenu = { toggleProjectOptions }
86+ >
87+ < h3 className = "sidebar__title" >
88+ < span > { t ( 'Sidebar.Title' ) } </ span >
89+ </ h3 >
90+ < div className = "sidebar__icons" >
91+ < button
92+ aria-label = { t ( 'Sidebar.ToggleARIA' ) }
93+ className = "sidebar__add"
94+ tabIndex = "0"
95+ ref = { sidebarOptionsRef }
96+ onClick = { toggleProjectOptions }
97+ onBlur = { onBlurComponent }
98+ onFocus = { onFocusComponent }
99+ >
100+ < PlusIcon focusable = "false" aria-hidden = "true" / >
101+ </ button >
102+ < ul className = "sidebar__project-options" >
103+ < li >
104+ < button
105+ aria-label = { t ( 'Sidebar.AddFolderARIA' ) }
106+ onClick = { ( ) => {
107+ dispatch ( newFolder ( rootFile . id ) ) ;
108+ setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
109+ } }
110+ onBlur = { onBlurComponent }
111+ onFocus = { onFocusComponent }
112+ >
113+ { t ( 'Sidebar.AddFolder' ) }
114+ </ button >
115+ </ li >
113116 < li >
114117 < button
115- aria-label = { t ( 'Sidebar.UploadFileARIA ' ) }
118+ aria-label = { t ( 'Sidebar.AddFileARIA ' ) }
116119 onClick = { ( ) => {
117- dispatch ( openUploadFileModal ( rootFile . id ) ) ;
120+ dispatch ( newFile ( rootFile . id ) ) ;
118121 setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
119122 } }
120123 onBlur = { onBlurComponent }
121124 onFocus = { onFocusComponent }
122125 >
123- { t ( 'Sidebar.UploadFile ' ) }
126+ { t ( 'Sidebar.AddFile ' ) }
124127 </ button >
125128 </ li >
126- ) }
127- </ ul >
128- </ div >
129- </ header >
130- < ConnectedFileNode id = { rootFile . id } canEdit = { canEditProject } />
131- </ section >
129+ { isAuthenticated && (
130+ < li >
131+ < button
132+ aria-label = { t ( 'Sidebar.UploadFileARIA' ) }
133+ onClick = { ( ) => {
134+ dispatch ( openUploadFileModal ( rootFile . id ) ) ;
135+ setTimeout ( ( ) => dispatch ( closeProjectOptions ( ) ) , 0 ) ;
136+ } }
137+ onBlur = { onBlurComponent }
138+ onFocus = { onFocusComponent }
139+ >
140+ { t ( 'Sidebar.UploadFile' ) }
141+ </ button >
142+ </ li >
143+ ) }
144+ </ ul >
145+ </ div >
146+ </ header >
147+ < ConnectedFileNode id = { rootFile . id } canEdit = { canEditProject } />
148+ </ section >
149+ </ FileDrawer >
132150 ) ;
133151}
0 commit comments