Skip to content

Commit

Permalink
fix: sort stories based on their categories
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Oct 1, 2019
1 parent 9013fbe commit 2d03a57
Show file tree
Hide file tree
Showing 3 changed files with 555 additions and 276 deletions.
24 changes: 24 additions & 0 deletions .storybook/config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
import { addParameters, configure } from '@storybook/html';
import { create } from '@storybook/theming';

// List of categories to sort the stories in the order of the InstantSearch.js
// API reference.
// See https://www.algolia.com/doc/api-reference/widgets/js/
const categories = [
'Basics',
'Metadata',
'Pagination',
'Refinements',
'Results',
'Sorting',
];

addParameters({
options: {
theme: create({
base: 'light',
brandTitle: 'InstantSearch.js',
brandUrl: 'https://github.com/algolia/instantsearch.js',
}),
storySort(a: any[], b: any[]) {
const categoryA = a[1].kind.split('|')[0];
const categoryB = b[1].kind.split('|')[0];

if (categories.indexOf(categoryA) === categories.indexOf(categoryB)) {
return 0;
}

return categories.indexOf(categoryA) < categories.indexOf(categoryB)
? -1
: 1;
},
},
});

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
"@babel/preset-env": "7.5.5",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "7.3.3",
"@storybook/addon-actions": "5.1.11",
"@storybook/html": "5.1.11",
"@storybook/theming": "5.1.11",
"@storybook/addon-actions": "5.2.1",
"@storybook/html": "5.2.1",
"@storybook/theming": "5.2.1",
"@types/algoliasearch": "3.30.16",
"@types/classnames": "^2.2.7",
"@types/enzyme": "^3.1.15",
Expand Down

0 comments on commit 2d03a57

Please sign in to comment.