config.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { configure, addDecorator } from '@storybook/react';
  2. import { withKnobs } from '@storybook/addon-knobs';
  3. import { withTheme } from '../src/utils/storybook/withTheme';
  4. import { withPaddedStory } from '../src/utils/storybook/withPaddedStory';
  5. import 'jquery';
  6. import '../../../public/vendor/flot/jquery.flot.js';
  7. import '../../../public/vendor/flot/jquery.flot.selection';
  8. import '../../../public/vendor/flot/jquery.flot.time';
  9. import '../../../public/vendor/flot/jquery.flot.stack';
  10. import '../../../public/vendor/flot/jquery.flot.pie';
  11. import '../../../public/vendor/flot/jquery.flot.stackpercent';
  12. import '../../../public/vendor/flot/jquery.flot.fillbelow';
  13. import '../../../public/vendor/flot/jquery.flot.crosshair';
  14. import '../../../public/vendor/flot/jquery.flot.dashes';
  15. import '../../../public/vendor/flot/jquery.flot.gauge';
  16. // @ts-ignore
  17. import lightTheme from '../../../public/sass/grafana.light.scss';
  18. // @ts-ignore
  19. import darkTheme from '../../../public/sass/grafana.dark.scss';
  20. const handleThemeChange = (theme: string) => {
  21. if (theme !== 'light') {
  22. lightTheme.unuse();
  23. darkTheme.use();
  24. } else {
  25. darkTheme.unuse();
  26. lightTheme.use();
  27. }
  28. };
  29. // automatically import all files ending in *.stories.tsx
  30. const req = require.context('../src/components', true, /.story.tsx$/);
  31. addDecorator(withKnobs);
  32. addDecorator(withPaddedStory);
  33. addDecorator(withTheme(handleThemeChange));
  34. function loadStories() {
  35. req.keys().forEach(req);
  36. }
  37. configure(loadStories, module);