config.js 2.7 KB

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