2020-04-01 21:53:41 -04:00
import { addParameters , addDecorator } from '@storybook/react' ;
import { jsxDecorator } from 'storybook-addon-jsx' ;
2020-12-10 16:58:10 -05:00
import {
configure ,
getTimeFormatterRegistry ,
smartDateFormatter ,
getCategoricalSchemeRegistry ,
getSequentialSchemeRegistry ,
2021-10-18 09:14:56 -04:00
CategoricalD3 ,
CategoricalSuperset ,
SequentialCommon ,
SequentialD3 ,
2020-12-10 16:58:10 -05:00
} from '@superset-ui/core' ;
2020-09-03 15:02:23 -04:00
import { configureEncodable } from '@superset-ui/preset-chart-xy' ;
import themeDecorator from './themeDecorator' ;
2020-04-01 21:53:41 -04:00
import 'bootstrap/dist/css/bootstrap.min.css' ;
import './storybook.css' ;
addDecorator ( jsxDecorator ) ;
2020-05-20 20:04:28 -04:00
addDecorator ( themeDecorator ) ;
2018-11-07 00:56:40 -05:00
2019-04-09 16:19:46 -04:00
addParameters ( {
2021-10-20 04:05:14 -04:00
passArgsFirst : false ,
2019-04-09 16:19:46 -04:00
options : {
name : '✨ Superset UI' ,
2018-11-07 00:56:40 -05:00
addonPanelInRight : false ,
enableShortcuts : false ,
goFullScreen : false ,
2019-06-17 20:35:44 -04:00
hierarchyRootSeparator : null ,
2018-11-07 00:56:40 -05:00
hierarchySeparator : /\|/ ,
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
showAddonPanel : true ,
showSearchBox : false ,
showStoriesPanel : true ,
sidebarAnimations : true ,
sortStoriesByKind : false ,
url : '#' ,
2020-04-01 21:53:41 -04:00
storySort : ( a , b ) => {
2020-09-03 15:02:23 -04:00
if ( a [ 1 ] . kind === b [ 1 ] . kind ) {
2020-04-27 17:57:10 -04:00
return 0 ;
}
2021-11-09 07:42:28 -05:00
if (
a [ 1 ] . id . startsWith ( 'core-packages' ) &&
! b [ 1 ] . id . startsWith ( 'core-packages' )
) {
2020-04-27 17:57:10 -04:00
return - 1 ;
}
2021-11-09 07:42:28 -05:00
if (
! a [ 1 ] . id . startsWith ( 'core-packages' ) &&
b [ 1 ] . id . startsWith ( 'core-packages' )
) {
2020-04-27 17:57:10 -04:00
return 1 ;
}
return a [ 1 ] . id . localeCompare ( b [ 1 ] . id , undefined , { numeric : true } ) ;
2020-04-01 21:53:41 -04:00
} ,
2019-04-09 16:19:46 -04:00
} ,
} ) ;
2020-04-11 01:29:42 -04:00
// Superset setup
configure ( ) ;
// Register color schemes
const categoricalSchemeRegistry = getCategoricalSchemeRegistry ( ) ;
2021-10-18 09:14:56 -04:00
[ CategoricalD3 , CategoricalSuperset ] . forEach ( group => {
2020-04-11 01:29:42 -04:00
group . forEach ( scheme => {
categoricalSchemeRegistry . registerValue ( scheme . id , scheme ) ;
} ) ;
} ) ;
categoricalSchemeRegistry . setDefaultKey ( 'd3Category10' ) ;
const sequentialSchemeRegistry = getSequentialSchemeRegistry ( ) ;
2021-10-18 09:14:56 -04:00
[ SequentialCommon , SequentialD3 ] . forEach ( group => {
2020-04-11 01:29:42 -04:00
group . forEach ( scheme => {
sequentialSchemeRegistry . registerValue ( scheme . id , scheme ) ;
} ) ;
} ) ;
getTimeFormatterRegistry ( )
. registerValue ( 'smart_date' , smartDateFormatter )
. setDefaultKey ( 'smart_date' ) ;
2020-09-03 15:02:23 -04:00
configureEncodable ( ) ;