config.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import React from 'react';
  2. import {ThemeProvider} from 'emotion-theming';
  3. import {configure, setAddon, getStorybook, addDecorator} from '@storybook/react';
  4. import infoAddon, {setDefaults} from '@storybook/addon-info';
  5. import {checkA11y} from '@storybook/addon-a11y';
  6. import {setOptions} from '@storybook/addon-options';
  7. import {withKnobs} from '@storybook/addon-knobs';
  8. import theme from '../src/sentry/static/sentry/app/utils/theme';
  9. import './storybook.less';
  10. const withTheme = storyFn => <ThemeProvider theme={theme}>{storyFn()}</ThemeProvider>;
  11. setDefaults({
  12. inline: true,
  13. header: false,
  14. source: false,
  15. });
  16. setAddon(infoAddon);
  17. addDecorator(checkA11y);
  18. addDecorator(withTheme);
  19. addDecorator(withKnobs);
  20. // Use webpack's require.context to load modules dynamically
  21. // From https://storybook.js.org/basics/writing-stories/
  22. const req = require.context('../docs-ui/components', true, /\.stories\.js$/);
  23. // Option defaults:
  24. setOptions({
  25. /**
  26. * name to display in the top left corner
  27. * @type {String}
  28. */
  29. name: 'Sentry Styleguide',
  30. /**
  31. * URL for name in top left corner to link to
  32. * @type {String}
  33. */
  34. url: '#',
  35. /**
  36. * show story component as full screen
  37. * @type {Boolean}
  38. */
  39. goFullScreen: false,
  40. /**
  41. * display panel that shows a list of stories
  42. * @type {Boolean}
  43. */
  44. showStoriesPanel: true,
  45. /**
  46. * display panel that shows addon configurations
  47. * @type {Boolean}
  48. */
  49. showAddonPanel: true,
  50. /**
  51. * display floating search box to search through stories
  52. * @type {Boolean}
  53. */
  54. showSearchBox: false,
  55. /**
  56. * show addon panel as a vertical panel on the right
  57. * @type {Boolean}
  58. */
  59. addonPanelInRight: false,
  60. /**
  61. * sorts stories
  62. * @type {Boolean}
  63. */
  64. sortStoriesByKind: false,
  65. /**
  66. * regex for finding the hierarchy separator
  67. * @example:
  68. * null - turn off hierarchy
  69. * /\// - split by `/`
  70. * /\./ - split by `.`
  71. * /\/|\./ - split by `/` or `.`
  72. * @type {Regex}
  73. */
  74. hierarchySeparator: /\/|\./, // matches a . or /
  75. /**
  76. * regex for finding the hierarchy root separator
  77. * @example:
  78. * null - turn off multiple hierarchy roots
  79. * /\|/ - split by `|`
  80. * @type {Regex}
  81. */
  82. hierarchyRootSeparator: /\|/, //matches a |
  83. /**
  84. * sidebar tree animations
  85. * @type {Boolean}
  86. */
  87. sidebarAnimations: true,
  88. /**
  89. * id to select an addon panel
  90. * @type {String}
  91. */
  92. selectedAddonPanel: undefined, // The order of addons in the "Addon panel" is the same as you import them in 'addons.js'. The first panel will be opened by default as you run Storybook
  93. });
  94. configure(function() {
  95. require('../docs-ui/index.js');
  96. req.keys().forEach(filename => req(filename));
  97. }, module);