Skip to content

Commit

Permalink
Merge pull request #6858 from storybooks/tech/remove-sort-docs
Browse files Browse the repository at this point in the history
REMOVE `sortStoriesByKind` from docs & implementation
  • Loading branch information
shilman authored May 25, 2019
2 parents 3217faf + c83d4a7 commit 6caf544
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
23 changes: 23 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,29 @@ Please refer to the [current custom webpack documentation](https://github.com/st

Storybook 5.0 includes sweeping UI changes as well as changes to the addon API and custom webpack configuration. We've tried to keep backwards compatibility in most cases, but there are some notable exceptions documented below.

### sortStoriesByKind

In Storybook 5.0 we changed a lot of UI related code, and 1 oversight caused the `sortStoriesByKind` options to stop working.
We're working on providing a better way of sorting stories for now the feature has been removed. Stories appear in the order they are loaded.

If you're using webpack's `require.context` to load stories, you can sort the execution of requires:

```js
var context = require.context('../stories', true, /\.stories\.js$/);
var modules = context.keys();

// sort them
var sortedModules = modules.slice().sort((a, b) => {
// sort the stories based on filename/path
return a < b ? -1 : (a > b ? 1 : 0);
});

// execute them
sortedModules.forEach((key) => {
context(key);
});
```

## Webpack config simplification

The API for custom webpack configuration has been simplifed in 5.0, but it's a breaking change. Storybook's "full control mode" for webpack allows you to override the webpack config with a function that returns a configuration object.
Expand Down
5 changes: 0 additions & 5 deletions addons/options/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ addParameters({
* @type {Boolean}
*/
addonPanelInRight: false,
/**
* sorts stories
* @type {Boolean}
*/
sortStoriesByKind: false,
/**
* regex for finding the hierarchy separator
* @example:
Expand Down
5 changes: 0 additions & 5 deletions docs/src/pages/configurations/options-parameter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ addParameters({
* @type {('bottom'|'right')}
*/
panelPosition: 'bottom',
/**
* sorts stories
* @type {Boolean}
*/
sortStoriesByKind: false,
/**
* regex for finding the hierarchy separator
* @example:
Expand Down
1 change: 0 additions & 1 deletion examples/cra-kitchen-sink/.storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ addParameters({
showAddonsPanel: true,
showSearchBox: false,
panelPosition: 'right',
sortStoriesByKind: false,
hierarchySeparator: /\./,
hierarchyRootSeparator: /\|/,
enableShortcuts: true,
Expand Down
2 changes: 0 additions & 2 deletions lib/api/src/modules/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface UI {
name?: string;
url?: string;
enableShortcuts: boolean;
sortStoriesByKind: boolean;
sidebarAnimations: boolean;
}

Expand Down Expand Up @@ -132,7 +131,6 @@ const checkDeprecatedLayoutOptions = (options: Options) => {
const initial: SubState = {
ui: {
enableShortcuts: true,
sortStoriesByKind: false,
sidebarAnimations: true,
},
layout: {
Expand Down
1 change: 0 additions & 1 deletion lib/api/src/tests/layout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('layout API', () => {
currentState = {
ui: {
enableShortcuts: true,
sortStoriesByKind: false,
sidebarAnimations: true,
},
layout: {
Expand Down

1 comment on commit 6caf544

@vercel
Copy link

@vercel vercel bot commented on 6caf544 May 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.