import SidebarConstants from '../constants/SidebarConstants'

export default function layout (state = {}, action) {
  switch (action.type) {
    case SidebarConstants.OPEN:
      state.sidebar = true
      break
    case SidebarConstants.TOGGLE:
      state.sidebar = !state.sidebar
      break
    default:
      state.sidebar = false
      break
  }
  return state
}

@@ -1,8 +1,43 @@
+/**%0A * layout reducer%0A * @flow%0A */%0A
 import S
@@ -93,312 +93,632 @@
 ts'%0A
-%0Aex
+im
 port 
-default function l
+createReducer from '../lib/createReducer'%0Aimport Immutable from 'immutable'%0A%0A// Record types%0Aexport const L
 ayout
- (s
+S
 tate = 
-%7B%7D, action) %7B%0A  switch (action.type) %7B%0A    case SidebarConstants.OPEN:%0A     
+Immutable.Record(%7B%0A  sidebar: false%0A%7D, 'sidebarState')%0A%0Aexport default createReducer(new LayoutState(), %7B%0A  /**%0A   * Open sidebar%0A   */%0A  %5BSidebarConstants.OPEN%5D (state: LayoutState) %7B%0A    return
  state.
+set('
 sidebar
- =
+',
  true
+)
 %0A  
-    break%0A    case SidebarConstants.TOGGLE:%0A     
+%7D,%0A%0A  /**%0A   * Close sidebar%0A   */%0A  %5BSidebarConstants.CLOSE%5D (state: LayoutState) %7B%0A    return
  state.
+set('
 sidebar
- = !state.sidebar%0A      break%0A    default:%0A      state.sidebar = false%0A      break%0A  %7D%0A  return state%0A%7D
+', false)%0A  %7D,%0A%0A  /**%0A   * Toggle sidebar%0A   */%0A  %5BSidebarConstants.TOGGLE%5D (state: LayoutState) %7B%0A    return state.update('sidebar', sidebar =%3E !sidebar)%0A  %7D%0A%7D)
 %0A

Update layout reducer