Skip to content

Commit

Permalink
Storybook upgrade to 6.4 final (#215)
Browse files Browse the repository at this point in the history
# Pull Request

## 🀨 Rationale

We've been running Storybook 6.4 beta for awhile, but Storybook 6.4 [recently](storybookjs/storybook#15355) went final.

## πŸ‘©β€πŸ’» Implementation

1. Updated to 6.4 final packages
2. Installed new [Interactions add-on](https://www.npmjs.com/package/@storybook/addon-interactions)
3. Installed new [Storybook eslint rules](https://github.com/storybookjs/eslint-plugin-storybook)
4. Fixed `Story` typing within the stories. Using `StoryObj` for CSF 3 stories.
5. Removed the `layout: 'fullscreen'` parameter, to restore default Storybook padding around each control. Also, removed non-functional `preview-head.html` styling.

## πŸ§ͺ Testing

 1. Local build, lint, test
 2. Run Storybook and review all pages, add-ons, etc.
 3. Reviewed Chromatic to confirm all changes related only to padding change

## βœ… Checklist

- [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
  • Loading branch information
fredvisser committed Dec 6, 2021
1 parent 3969021 commit 2f623ef
Show file tree
Hide file tree
Showing 27 changed files with 4,397 additions and 2,302 deletions.
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "upgrade to 6.4 final",
"packageName": "@ni/nimble-components",
"email": "1458528+fredvisser@users.noreply.github.com",
"dependentChangeType": "prerelease"
}
6,566 changes: 4,328 additions & 2,238 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/nimble-components/.storybook/main.js
Expand Up @@ -13,7 +13,8 @@ module.exports = {
}
},
'storybook-addon-xd-designs',
'@storybook/addon-a11y'
'@storybook/addon-a11y',
'@storybook/addon-interactions'
],
features: {
previewCsfV3: true
Expand Down
13 changes: 0 additions & 13 deletions packages/nimble-components/.storybook/preview-head.html

This file was deleted.

1 change: 0 additions & 1 deletion packages/nimble-components/.storybook/preview.js
Expand Up @@ -6,7 +6,6 @@ import { backgroundStates } from '../dist/esm/utilities/tests/matrix';
const [defaultBackground] = backgroundStates;

export const parameters = {
layout: 'fullscreen',
backgrounds: {
default: defaultBackground.name,
values: backgroundStates.map(({ name, value }) => ({ name, value }))
Expand Down
24 changes: 14 additions & 10 deletions packages/nimble-components/package.json
Expand Up @@ -52,16 +52,19 @@
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.13.15",
"@ni/eslint-config-typescript": "^3.0.0",
"@storybook/addon-a11y": "^6.4.0-alpha.28",
"@storybook/addon-actions": "^6.4.0-alpha.28",
"@storybook/addon-docs": "^6.4.0-alpha.28",
"@storybook/addon-essentials": "^6.4.0-alpha.28",
"@storybook/addon-links": "^6.4.0-alpha.28",
"@storybook/addons": "^6.4.0-alpha.28",
"@storybook/builder-webpack5": "^6.4.0-alpha.28",
"@storybook/html": "^6.4.0-alpha.28",
"@storybook/manager-webpack5": "^6.4.0-alpha.28",
"@storybook/theming": "^6.4.0-alpha.28",
"@storybook/addon-a11y": "^6.4.0",
"@storybook/addon-actions": "^6.4.0",
"@storybook/addon-docs": "^6.4.0",
"@storybook/addon-essentials": "^6.4.0",
"@storybook/addon-interactions": "^6.4.0",
"@storybook/addon-links": "^6.4.0",
"@storybook/addons": "^6.4.0",
"@storybook/builder-webpack5": "^6.4.0",
"@storybook/html": "^6.4.0",
"@storybook/jest": "^0.0.5",
"@storybook/manager-webpack5": "^6.4.0",
"@storybook/testing-library": "^0.0.7",
"@storybook/theming": "^6.4.0",
"@types/jasmine": "^3.6.0",
"@types/webpack-env": "^1.15.2",
"babel-loader": "^8.2.2",
Expand All @@ -70,6 +73,7 @@
"css-loader": "^6.2.0",
"dotenv-webpack": "^7.0.2",
"eslint-plugin-jsdoc": "^36.1.0",
"eslint-plugin-storybook": "^0.5.1",
"html-webpack-plugin": "^5.3.1",
"jasmine-core": "^3.7.0",
"karma": "^6.3.0",
Expand Down
9 changes: 7 additions & 2 deletions packages/nimble-components/src/.eslintrc.js
Expand Up @@ -35,7 +35,10 @@ module.exports = {
'@typescript-eslint/no-non-null-assertion': 'off',

// Improves readability of templates to avoid return types in template expressions
'@typescript-eslint/explicit-function-return-type': ['error', {allowExpressions: true}],
'@typescript-eslint/explicit-function-return-type': [
'error',
{ allowExpressions: true }
],

'no-restricted-imports': [
'error',
Expand All @@ -55,13 +58,15 @@ module.exports = {
overrides: [
{
files: ['*.stories.ts'],
extends: ['plugin:storybook/recommended'],
rules: {
// Storybook files will not be in published package and are allowed to use devDependencies
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: true }
],
'import/no-default-export': 'off'
'import/no-default-export': 'off',
'storybook/prefer-pascal-case': 'off'
}
},
{
Expand Down
Expand Up @@ -29,7 +29,7 @@ const metadata: Meta = {

export default metadata;

export const defaultButton = createRenderer(
export const defaultButton: Story = createRenderer(
html`<nimble-button>Default Button</nimble-button>`
);
const noContent = 'NO_CONTENT';
Expand Down Expand Up @@ -58,6 +58,6 @@ export const buttonThemeMatrix: Story = createRenderer(
)
);

export const hiddenButton = createRenderer(
export const hiddenButton: Story = createRenderer(
hiddenWrapper(html`<nimble-button hidden>Hidden Button</nimble-button>`)
);
9 changes: 5 additions & 4 deletions packages/nimble-components/src/button/tests/button.stories.ts
@@ -1,4 +1,4 @@
import type { Story, Meta } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import { html, when } from '@microsoft/fast-element';
import { ButtonAppearance } from '../types';
Expand Down Expand Up @@ -58,12 +58,13 @@ const metadata: Meta<ButtonArgs> = {

export default metadata;

export const outlineButton: Story<ButtonArgs> = {
export const outlineButton: StoryObj<ButtonArgs> = {
args: { label: 'Outline Button', appearance: ButtonAppearance.Outline }
};
export const ghostButton: Story<ButtonArgs> = {

export const ghostButton: StoryObj<ButtonArgs> = {
args: { label: 'Ghost Button', appearance: ButtonAppearance.Ghost }
};
export const blockButton: Story<ButtonArgs> = {
export const blockButton: StoryObj<ButtonArgs> = {
args: { label: 'Block Button', appearance: ButtonAppearance.Block }
};
Expand Up @@ -45,7 +45,7 @@ export const checkboxThemeMatrix: Story = createRenderer(
themeWrapper(createMatrix(component, [disabledStates, checkedStates]))
);

export const hiddenCheckbox = createRenderer(
export const hiddenCheckbox: Story = createRenderer(
hiddenWrapper(
html`<nimble-checkbox hidden>Hidden Checkbox</nimble-checkbox>`
)
Expand Down
@@ -1,5 +1,5 @@
import { html } from '@microsoft/fast-element';
import type { Story, Meta } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import { createRenderer } from '../../utilities/tests/storybook';
import '../index';
Expand Down Expand Up @@ -45,4 +45,4 @@ const metadata: Meta<CheckboxArgs> = {

export default metadata;

export const checkbox: Story<CheckboxArgs> = {};
export const checkbox: StoryObj<CheckboxArgs> = {};
4 changes: 2 additions & 2 deletions packages/nimble-components/src/drawer/tests/drawer.stories.ts
@@ -1,5 +1,5 @@
import { html, ViewTemplate } from '@microsoft/fast-element';
import type { Meta, Story } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import { createRenderer } from '../../utilities/tests/storybook';
import '../../button/index';
Expand Down Expand Up @@ -167,4 +167,4 @@ const metadata: Meta<DrawerArgs> = {

export default metadata;

export const drawer: Story<DrawerArgs> = {};
export const drawer: StoryObj<DrawerArgs> = {};
Expand Up @@ -36,7 +36,7 @@ export const iconThemeMatrix: Story = createRenderer(
themeWrapper(createMatrix(component, [iconStatusStates]))
);

export const hiddenIcon = createRenderer(
export const hiddenIcon: Story = createRenderer(
hiddenWrapper(
html`<nimble-check-icon class="pass" hidden></nimble-check-icon>`
)
Expand Down
@@ -1,4 +1,4 @@
import type { Story, Meta } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import * as nimbleIconsMap from '@ni/nimble-tokens/dist-icons-esm/nimble-icons-inline';
import { withXD } from 'storybook-addon-xd-designs';
import type { NimbleIcon } from '@ni/nimble-tokens/dist-icons-esm/nimble-icons-inline';
Expand Down Expand Up @@ -50,7 +50,7 @@ const metadata: Meta<IconArgs> = {
export default metadata;

// prettier-ignore
export const rawIcons: Story<IconArgs> = {
export const rawIcons: StoryObj<IconArgs> = {
parameters: {
controls: { hideNoControlsWarning: true }
},
Expand Down Expand Up @@ -86,7 +86,7 @@ const iconTemplate = html<IconClass, IconArgs>`
`;

// prettier-ignore
export const componentIcons: Story<IconArgs> = {
export const componentIcons: StoryObj<IconArgs> = {
args: { status: IconStatus.Regular },
argTypes: {
status: {
Expand Down
Expand Up @@ -46,7 +46,7 @@ export const menuThemeMatrix: Story = createRenderer(
themeWrapper(createMatrix(component, [iconVisibleStates]))
);

export const hiddenMenu = createRenderer(
export const hiddenMenu: Story = createRenderer(
hiddenWrapper(
html`<nimble-menu hidden>
<nimble-menu-item>Item 1</nimble-menu-item>
Expand Down
6 changes: 3 additions & 3 deletions packages/nimble-components/src/menu/tests/menu.stories.ts
@@ -1,4 +1,4 @@
import type { Story, Meta } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import { html, repeat, when } from '@microsoft/fast-element';
import { createRenderer } from '../../utilities/tests/storybook';
Expand Down Expand Up @@ -45,7 +45,7 @@ const metadata: Meta<MenuArgs> = {

export default metadata;

export const menu: Story<MenuArgs> = {
export const menu: StoryObj<MenuArgs> = {
parameters: {
docs: {
description: {
Expand Down Expand Up @@ -134,7 +134,7 @@ export const menu: Story<MenuArgs> = {
}
};

export const customMenu: Story = {
export const customMenu: StoryObj<MenuArgs> = {
parameters: {
docs: {
description: {
Expand Down
Expand Up @@ -47,7 +47,7 @@ export const numberFieldThemeMatrix: Story = createRenderer(
themeWrapper(createMatrix(component, [disabledStates, valueStates]))
);

export const hiddenNumberField = createRenderer(
export const hiddenNumberField: Story = createRenderer(
hiddenWrapper(
html`<nimble-number-field hidden
>Hidden number field</nimble-number-field
Expand Down
@@ -1,5 +1,5 @@
import { html } from '@microsoft/fast-element';
import type { Story, Meta } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import { createRenderer } from '../../utilities/tests/storybook';
import '../index';
Expand Down Expand Up @@ -46,6 +46,6 @@ const metadata: Meta<NumberFieldArgs> = {

export default metadata;

export const numberField: Story<NumberFieldArgs> = {
export const numberField: StoryObj<NumberFieldArgs> = {
args: { label: 'Number Field' }
};
Expand Up @@ -39,7 +39,7 @@ export const selectThemeMatrix: Story = createRenderer(
themeWrapper(createMatrix(component, [disabledStates]))
);

export const hiddenSelect = createRenderer(
export const hiddenSelect: Story = createRenderer(
hiddenWrapper(
html`<nimble-select hidden>
<nimble-listbox-option value="1">Option 1</nimble-listbox-option>
Expand Down
4 changes: 2 additions & 2 deletions packages/nimble-components/src/select/tests/select.stories.ts
@@ -1,4 +1,4 @@
import type { Story, Meta } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import '../index';
import '../../listbox-option/index';
Expand Down Expand Up @@ -64,4 +64,4 @@ const metadata: Meta<SelectArgs> = {

export default metadata;

export const select: Story<SelectArgs> = {};
export const select: StoryObj<SelectArgs> = {};
Expand Up @@ -58,7 +58,7 @@ export const tabsThemeMatrix: Story = createRenderer(
themeWrapper(createMatrix(component, [tabsToolbarState, disabledStates]))
);

export const hiddenTabs = createRenderer(
export const hiddenTabs: Story = createRenderer(
hiddenWrapper(
html`<nimble-tabs hidden>
<nimble-tab>Tab One</nimble-tab>
Expand Down
6 changes: 3 additions & 3 deletions packages/nimble-components/src/tabs/tests/tabs.stories.ts
@@ -1,5 +1,5 @@
import { html, repeat, when } from '@microsoft/fast-element';
import type { Meta, Story } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import { createRenderer } from '../../utilities/tests/storybook';
import '../index';
Expand Down Expand Up @@ -73,9 +73,9 @@ const metadata: Meta<TabsArgs> = {

export default metadata;

export const tabs: Story<TabsArgs> = {};
export const tabs: StoryObj<TabsArgs> = {};

export const toolbar: Story<TabsArgs> = {
export const toolbar: StoryObj<TabsArgs> = {
args: {
toolbar:
'<nimble-button appearance="ghost">Toolbar Button</nimble-button>'
Expand Down
Expand Up @@ -74,7 +74,7 @@ export const textFieldThemeMatrix: Story = createRenderer(
)
);

export const hiddenTextField = createRenderer(
export const hiddenTextField: Story = createRenderer(
hiddenWrapper(
html`<nimble-text-field hidden>Hidden text field</nimble-text-field>`
)
Expand Down
@@ -1,5 +1,5 @@
import { html } from '@microsoft/fast-element';
import type { Story, Meta } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import { createRenderer } from '../../utilities/tests/storybook';
import '../index';
Expand Down Expand Up @@ -60,10 +60,10 @@ const metadata: Meta<TextFieldArgs> = {

export default metadata;

export const textField: Story<TextFieldArgs> = {
export const textField: StoryObj<TextFieldArgs> = {
args: { label: 'Text Field' }
};

export const passwordField: Story<TextFieldArgs> = {
export const passwordField: StoryObj<TextFieldArgs> = {
args: { label: 'Password Field', type: 'password' }
};
Expand Up @@ -80,7 +80,7 @@ export const treeViewThemeMatrix: Story = createRenderer(
)
);

export const hiddenTreeView = createRenderer(
export const hiddenTreeView: Story = createRenderer(
hiddenWrapper(
html`<nimble-tree-view hidden>
<nimble-tree-item>Item 1</nimble-tree-item>
Expand Down
@@ -1,4 +1,4 @@
import type { Story, Meta } from '@storybook/html';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import '../index';
import '../../tree-item/index';
Expand Down Expand Up @@ -113,4 +113,4 @@ const metadata: Meta<TreeArgs> = {

export default metadata;

export const treeView: Story<TreeArgs> = {};
export const treeView: StoryObj<TreeArgs> = {};
3 changes: 2 additions & 1 deletion packages/nimble-components/tsconfig.json
Expand Up @@ -13,7 +13,8 @@
"importHelpers": true,
"resolveJsonModule": true,
"sourceMap": true,
"skipLibCheck": false,
// Set to 'true' to work around – https://github.com/ni/nimble/issues/219
"skipLibCheck": true,
"lib": ["DOM", "ES2015", "ES2016.Array.Include", "ES2017.Object"],
// Whitelist imported @types instead of using them all
"types": ["jasmine", "webpack-env"],
Expand Down

0 comments on commit 2f623ef

Please sign in to comment.