Add option to enable/diable shortcuts

This commit is contained in:
PunitGr 2018-03-19 20:41:43 +05:30
parent 74610ce1bb
commit dc980abb7f
2 changed files with 17 additions and 13 deletions

View File

@ -6,20 +6,23 @@ const deprecationMessage = (oldName, newName) =>
`The ${oldName} option has been renamed to ${newName} and will not be available in the next major Storybook release. Please update your config.`;
export function keyEventToOptions(currentOptions, event) {
switch (event) {
case features.FULLSCREEN:
return { goFullScreen: !currentOptions.goFullScreen };
case features.ADDON_PANEL:
return { showAddonPanel: !currentOptions.showAddonPanel };
case features.STORIES_PANEL:
return { showStoriesPanel: !currentOptions.showStoriesPanel };
case features.SHOW_SEARCH:
return { showSearchBox: true };
case features.ADDON_PANEL_IN_RIGHT:
return { addonPanelInRight: !currentOptions.addonPanelInRight };
default:
return {};
if (currentOptions.enableShortcuts) {
switch (event) {
case features.FULLSCREEN:
return { goFullScreen: !currentOptions.goFullScreen };
case features.ADDON_PANEL:
return { showAddonPanel: !currentOptions.showAddonPanel };
case features.STORIES_PANEL:
return { showStoriesPanel: !currentOptions.showStoriesPanel };
case features.SHOW_SEARCH:
return { showSearchBox: true };
case features.ADDON_PANEL_IN_RIGHT:
return { addonPanelInRight: !currentOptions.addonPanelInRight };
default:
return {};
}
}
return {};
}
const renamedOptions = {

View File

@ -9,6 +9,7 @@ export default {
showAddonPanel: true,
showSearchBox: false,
addonPanelInRight: false,
enableShortcuts: true,
},
},
};