summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-theme-default/src/reducers/sidebar.js
blob: eef68d408da7871748e3a9e1ec2c8a3beeebeb99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const GitBook = require('gitbook-core');
const { Record } = GitBook.Immutable;
const ActionTypes = require('../actions/types');

const SidebarState = Record({
    open: true
});

function reduceSidebar(state = SidebarState(), action) {
    switch (action.type) {
    case ActionTypes.TOGGLE_SIDEBAR:
        return state.set('open', !state.get('open'));
    default:
        return state;
    }
}

module.exports = reduceSidebar;