@@ -28,18 +28,21 @@ const Header = () => {
2828}
2929
3030const Main = ( ) => {
31+ const [ sidebarVisible , setSidebarVisible ] = React . useState ( true ) ;
32+ const [ sidebarWide , setSidebarWide ] = React . useState ( false ) ;
33+
3134 return (
3235 < Space . Fill style = { { backgroundColor : '#1E1E1E' } } >
3336 < Space . Fill >
3437 < IconPane />
35- < SideBar />
36- < Editor />
38+ < SideBar wide = { sidebarWide } visible = { sidebarVisible } />
39+ < Editor toggleSize = { ( ) => setSidebarWide ( ! sidebarWide ) } toggleVisibility = { ( ) => setSidebarVisible ( ! sidebarVisible ) } />
3740 </ Space . Fill >
3841 </ Space . Fill >
3942 )
4043}
4144
42- const Editor = ( ) => {
45+ const Editor : React . FC < { toggleVisibility : ( ) => void , toggleSize : ( ) => void } > = ( props ) => {
4346 const [ code , setCode ] = React . useState ( 'import * as React from \'react\';\r\nimport * as Space from \'react-spaces\';\r\n\r\nexport const App = () => {\r\n <Space.ViewPort>\r\n <Space.Top size={30}>\r\n Hello!\r\n </Space.Top>\r\n <Space.Fill>\r\n World!\r\n </Space.Fill>\r\n </Space.ViewPort>\r\n}' ) ;
4447
4548 const options = {
@@ -61,7 +64,7 @@ const Editor = () => {
6164 theme = "vs-dark" />
6265 </ Space . Fill >
6366 </ Space . Fill >
64- < BottomPane />
67+ < BottomPane toggleSize = { props . toggleSize } toggleVisibility = { props . toggleVisibility } />
6568 </ Space . Fill >
6669 )
6770}
@@ -73,9 +76,10 @@ const IconPane = () => {
7376 )
7477}
7578
76- const SideBar = ( ) => {
79+ const SideBar : React . FC < { wide : boolean , visible : boolean } > = ( props ) => {
7780 return (
78- < Space . LeftResizable order = { 2 } className = "side-bar" size = { 300 } handleSize = { 2 } overlayHandle = { false } style = { { backgroundColor : '#252526' } } >
81+ props . visible ?
82+ < Space . LeftResizable order = { 2 } className = "side-bar" size = { props . wide ? 500 : 300 } handleSize = { 2 } overlayHandle = { false } style = { { backgroundColor : '#252526' } } >
7983 < SideBarPane order = { 1 } title = "Open editors" height = { 200 } >
8084
8185 </ SideBarPane >
@@ -85,7 +89,8 @@ const SideBar = () => {
8589 < SideBarPane fill = { true } title = "Outline" >
8690
8791 </ SideBarPane >
88- </ Space . LeftResizable >
92+ </ Space . LeftResizable > :
93+ null
8994 )
9095}
9196
@@ -117,9 +122,11 @@ const SideBarPaneInner: React.FC<{ title: string }> = (props) => {
117122 )
118123}
119124
120- const BottomPane = ( ) => {
125+ const BottomPane : React . FC < { toggleVisibility : ( ) => void , toggleSize : ( ) => void } > = ( props ) => {
121126 return (
122- < Space . BottomResizable className = "bottom-pane" size = "25%" handleSize = { 2 } >
127+ < Space . BottomResizable className = "bottom-pane" size = "25%" handleSize = { 2 } centerContent = { Space . CenterType . HorizontalVertical } >
128+ < button onClick = { props . toggleVisibility } > Toggle sidebar visibility</ button >
129+ < button onClick = { props . toggleSize } > Toggle sidebar size</ button >
123130 </ Space . BottomResizable >
124131 )
125132}
0 commit comments