leftiness / react-demo

Other
0 stars 0 forks source link

Refactor who decides sidebar should be visible #49

Open leftiness opened 8 years ago

leftiness commented 8 years ago

This is wrong. Read below.

ApplicationContainer should pass sidebarIsVisible and screenSize props from redux down to Application component. Application component will <SidebarContainer visible={sidebarIsVisible}/> and <componentFromRoutes visible={screenSize !== small} />. If the screen is too small, and they open the sidebar, it'll just show the sidebar. When they close the menu, it'll be a hashchange, so the app will get rendered again, and it'll decide again whether to show just sidebar, sidebar and routeComponent, or just routeComponent.

I'll still need a SidebarContainer for later stuff. It just won't be involved in telling the sidebar whether it should be visible.

leftiness commented 8 years ago

That is wrong. This is why.

Instead of having the application container keep track of that information... What I really want is for the sidebar and the routeComponent to be rendered properly.

Therefore, all I really need to do is complete the task on #41. Then the SidebarContainer can continue telling the Sidebar component whether he should be visible (state.sidebar.visible === true), and the ApplicationContainer can tell the Application component whether he should be visible (hidden = state.screenSize.small && state.sidebar.visible).