preview.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { withJsx } from '@mihkeleidast/storybook-addon-source';
  2. import {
  3. configure,
  4. getTimeFormatterRegistry,
  5. smartDateFormatter,
  6. getCategoricalSchemeRegistry,
  7. getSequentialSchemeRegistry,
  8. CategoricalD3,
  9. CategoricalSuperset,
  10. SequentialCommon,
  11. SequentialD3,
  12. } from '@superset-ui/core';
  13. import themeDecorator from './themeDecorator';
  14. import './storybook.css';
  15. export const decorators = [withJsx, themeDecorator];
  16. export const parameters = {
  17. passArgsFirst: false,
  18. options: {
  19. name: '✨ Superset UI',
  20. addonPanelInRight: false,
  21. enableShortcuts: false,
  22. goFullScreen: false,
  23. hierarchyRootSeparator: null,
  24. hierarchySeparator: /\|/,
  25. 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
  26. showAddonPanel: true,
  27. showSearchBox: false,
  28. showStoriesPanel: true,
  29. sidebarAnimations: true,
  30. sortStoriesByKind: false,
  31. url: '#',
  32. storySort: (a, b) => {
  33. if (a.kind === b.kind) {
  34. return 0;
  35. }
  36. if (
  37. a.id.startsWith('core-packages') &&
  38. !b.id.startsWith('core-packages')
  39. ) {
  40. return -1;
  41. }
  42. if (
  43. !a.id.startsWith('core-packages') &&
  44. b.id.startsWith('core-packages')
  45. ) {
  46. return 1;
  47. }
  48. return a.id.localeCompare(b.id, undefined, { numeric: true });
  49. },
  50. },
  51. };
  52. // Superset setup
  53. configure();
  54. // Register color schemes
  55. const categoricalSchemeRegistry = getCategoricalSchemeRegistry();
  56. [CategoricalD3, CategoricalSuperset].forEach(group => {
  57. group.forEach(scheme => {
  58. categoricalSchemeRegistry.registerValue(scheme.id, scheme);
  59. });
  60. });
  61. categoricalSchemeRegistry.setDefaultKey('d3Category10');
  62. const sequentialSchemeRegistry = getSequentialSchemeRegistry();
  63. [SequentialCommon, SequentialD3].forEach(group => {
  64. group.forEach(scheme => {
  65. sequentialSchemeRegistry.registerValue(scheme.id, scheme);
  66. });
  67. });
  68. getTimeFormatterRegistry()
  69. .registerValue('smart_date', smartDateFormatter)
  70. .setDefaultKey('smart_date');