Add migration instructions for isToolshown rename

This commit is contained in:
Michael Shilman 2022-05-09 09:51:38 +08:00
parent 99f3070c36
commit aad962bb1a
3 changed files with 33 additions and 7 deletions

View File

@ -2,6 +2,7 @@
- [From version 6.4.x to 6.5.0](#from-version-64x-to-650)
- [React18 new root API](#react18-new-root-api)
- [Renamed isToolshown to showToolbar](#renamed-istoolshown-to-showtoolbar)
- [Deprecated register.js](#deprecated-registerjs)
- [Dropped support for addon-actions addDecorators](#dropped-support-for-addon-actions-adddecorators)
- [Vite builder renamed](#vite-builder-renamed)
@ -213,6 +214,21 @@ module.exports = {
};
```
### Renamed isToolshown to showToolbar
Storybook's [manager API](docs/addons/addons-api.md) has deprecated the `isToolshown` option (to show/hide the toolbar) and renamed it to `showToolbar` for consistency with other similar UI options.
Example:
```js
// .storybook/manager.js
import { addons } from '@storybook/addons';
addons.setConfig({
showToolbar: false,
});
```
### Deprecated register.js
In ancient versions of Storybook, addons were registered by referring to `addon-name/register.js`. This is going away in SB7.0. Instead you should just add `addon-name` to the `addons` array in `.storybook/main.js`.

View File

@ -18,11 +18,11 @@ addons.setConfig({
collapsedRoots: ['other'],
},
toolbar: {
title: { hidden: false, },
zoom: { hidden: false, },
eject: { hidden: false, },
copy: { hidden: false, },
fullscreen: { hidden: false, },
title: { hidden: false },
zoom: { hidden: false },
eject: { hidden: false },
copy: { hidden: false },
fullscreen: { hidden: false },
},
});
```
```

View File

@ -3,6 +3,8 @@ import pick from 'lodash/pick';
import deepEqual from 'fast-deep-equal';
import { themes } from '@storybook/theming';
import type { ThemeVars } from '@storybook/theming';
import { once } from '@storybook/client-logger';
import dedent from 'ts-dedent';
import merge from '../lib/merge';
import type { State, ModuleFn } from '../index';
@ -25,7 +27,10 @@ export interface Layout {
showNav: boolean;
showTabs: boolean;
showToolbar: boolean;
isToolshown?: boolean; // deprecated
/**
* @deprecated
*/
isToolshown?: boolean;
}
export interface UI {
@ -222,6 +227,11 @@ export const init: ModuleFn = ({ store, provider, singleStory }) => {
const { theme, selectedPanel, ...options } = provider.getConfig();
if (options?.layout?.isToolshown !== undefined) {
once.warn(dedent`
The "isToolshown" option is deprecated. Please use "showToolbar" instead.
See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#renamed-istoolshown-to-showtoolbar
`);
options.layout.showToolbar = options.layout.isToolshown;
}