Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Storybook to version 8 #687

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions .storybook/main.js

This file was deleted.

85 changes: 85 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* eslint-disable no-param-reassign */
import webpack from 'webpack';

module.exports = {
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-essentials', '@storybook/addon-webpack5-compiler-babel'],
staticDirs: ['../static'],
babel: () => ({
plugins: [
// Use @babel/plugin-proposal-class-properties for class arrow functions
require.resolve('@babel/plugin-transform-class-properties'),
require.resolve('@babel/plugin-proposal-private-property-in-object'),
require.resolve('@babel/plugin-proposal-private-methods'),
require.resolve('@babel/plugin-proposal-class-properties'),

// Use babel-plugin-remove-graphql-queries to remove graphql queries from components when rendering in Storybook
// While still rendering content from useStaticQuery in development mode
[
require.resolve('babel-plugin-remove-graphql-queries'),
{
stage: 'build-html',
staticQueryDir: 'page-data/sq/d',
},
],
],
presets: [
require.resolve('@babel/preset-react'),
[
require.resolve('@babel/preset-env'),
{
shippedProposals: true,
loose: false,
},
],
require.resolve('@babel/preset-typescript'),
],
}),
webpackFinal: async (config) => {
// Transpile Gatsby module because Gatsby includes un-transpiled ES6 code.
config.module.rules[0].exclude = [/node_modules\/(?!(gatsby)\/)/];
// Use installed babel-loader which is v8.0-beta (which is meant to work with @babel/core@7)
// config.module.rules[0].test = /\.(js(x)|ts(x))?$/;
// config.module.rules[0].use[0].loader = require.resolve('babel-loader');
config.module.rules.push({
test: /\.(js|ts)x?$/,
// exclude: [/node_modules\/(?!(gatsby)\/)/],
include: {
and: [/node_modules\/((gatsby)\/)/],
not: [/core-js/],
},
use: ['babel-loader'],
}),
config.plugins.unshift(
new webpack.NormalModuleReplacementPlugin(
/lib\/useSiteMetadata/,
require.resolve('./useSiteMetadata')
)
);
config.resolve.alias['../../../hooks/use-addons-search'] = require.resolve(
'./use-addons-search.mock.js'
);

config.plugins.unshift(
new webpack.DefinePlugin({
'process.env.GATSBY_ALGOLIA_API_KEY': JSON.stringify(process.env.GATSBY_ALGOLIA_API_KEY),
})
);
config.resolve.fallback = {
os: require.resolve('os-browserify/browser'),
tty: require.resolve('tty-browserify'),
path: require.resolve('path-browserify'),
};

return config;
},

framework: {
name: '@storybook/react-webpack5',
options: {},
},

docs: {
autodocs: true,
},
};
8 changes: 7 additions & 1 deletion .storybook/preview.js → .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@ global.___loader = {
hovering: () => {},
};
// This global variable prevents the "__BASE_PATH__ is not defined" error inside Storybook.
declare global {
interface Window {
__navigate: (pathname: string) => void;
}
}

global.__PATH_PREFIX__ = '';
global.__BASE_PATH__ = '/';
// Navigating through a gatsby app using gatsby-link or any other gatsby component will use the `___navigate` method.
// In Storybook, it makes more sense to log an action than doing an actual navigate. Check out the actions addon docs for more info: https://storybook.js.org/docs/react/essentials/actions
window.___navigate = (pathname) => {
window.__navigate = (pathname) => {
action('NavigateTo:')(pathname);
};

Expand Down
8 changes: 4 additions & 4 deletions .storybook/useSiteMetadata.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const siteMetadata = require('../site-metadata');

const versionData = {
version: 6.3,
versionString: '6.3',
latestVersion: 6.3,
latestVersionString: '6.3',
version: 8.0,
versionString: '8.0',
latestVersion: 8.0,
latestVersionString: '8.0',
isLatest: true,
};

Expand Down
39 changes: 22 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@chromaui/tetra": "^1.16.9",
"@docsearch/css": "^3.2.1",
"@docsearch/css": "^3.6.0",
"@docsearch/react": "^3.0.0",
"@emotion/server": "^11.4.0",
"@google-cloud/bigquery": "^5.2.0",
Expand All @@ -21,11 +21,9 @@
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-tabs": "^1.0.4",
"@storybook/api": "^6.5.9",
"@storybook/components-marketing": "3.0.2",
"@storybook/design-system": "7.13.1",
"@storybook/design-system": "^7.15.17",
"@storybook/icons": "^1.2.9",
"@storybook/theming": "^6.5.9",
"core-js": "^3.22.8",
"date-fns": "^2.16.1",
"date-fns-tz": "^2.0.0",
Expand Down Expand Up @@ -108,8 +106,9 @@
"format": "prettier --write \"src/**/*.js\"",
"lint": "eslint src .storybook --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives",
"test": "jest",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "test-storybook",
"chromatic": "chromatic --project-token dd2oqshntir",
"generate-types": "graphql-codegen --config graphql-types-codegen.yml",
"build:functions": "netlify-lambda build src/functions",
Expand All @@ -126,31 +125,37 @@
"@graphql-codegen/cli": "^1.9.1",
"@graphql-codegen/introspection": "1.16.3",
"@graphql-codegen/typescript": "^1.9.1",
"@storybook/addon-actions": "^6.5.9",
"@storybook/addon-essentials": "^6.5.9",
"@storybook/builder-webpack5": "^6.5.9",
"@storybook/eslint-config-storybook": "^3.1.2",
"@storybook/jest": "^0.0.10",
"@storybook/manager-webpack5": "^6.5.9",
"@storybook/react": "^6.5.9",
"@storybook/testing-library": "^0.0.11",
"@storybook/addon-actions": "^8.0.4",
"@storybook/addon-essentials": "^8.0.4",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/addon-webpack5-compiler-swc": "^1.0.2",
"@storybook/eslint-config-storybook": "^4.0.0",
"@storybook/react": "^8.0.4",
"@storybook/react-webpack5": "^8.0.4",
"@storybook/test": "^8.0.4",
"@storybook/test-runner": "^0.17.0",
"@storybook/theming": "^8.0.4",
"@types/jest": "^27.0.0",
"@types/react": "^18",
"babel-preset-gatsby": "^2.16.0",
"chromatic": "^6.14.0",
"babel-preset-gatsby": "^3.13.1",
"chromatic": "^11.2.0",
"concurrently": "^5.3.0",
"dedent": "^0.7.0",
"eslint": "^8.17.0",
"eslint-plugin-storybook": "^0.5.12",
"eslint-plugin-storybook": "^0.8.0",
"gatsby-source-ghost": "^4.2.4",
"jest": "^27.0.0",
"netlify-lambda": "^2.0.1",
"os-browserify": "^0.3.0",
"patch-package": "^6.4.7",
"path-browserify": "^1.0.1",
"prettier": "^2.0.5",
"prettier-eslint": "^11.0.0",
"seedrandom": "^3.0.5",
"storybook": "^8.0.4",
"storybook-addon-outline": "^1.4.2",
"ts-jest": "^27.0.0",
"tty-browserify": "^0.0.1",
"webfontloader": "^1.6.28",
"webpack": "^5.76.0"
},
Expand Down
Loading