nickytonline/connect-four

Add Storybook to the project

nickytonline opened this issue ยท 3 comments

Is your feature request related to a problem? Please describe. A clear and
concise description of what the problem is. Ex. I'm always frustrated when [...]

Add Storybook to the project

Describe the solution you'd like A clear and concise description of what you
want to happen.

Describe alternatives you've considered A clear and concise description of
any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature
request here.

Before beginning this issue, #20 needs to be merged

Follow these steps and Storybook should setup properly.

  1. Run npx sb init

  2. When prompted, press y for yes.

๐Ÿ”Ž checking possible migrations..
๐Ÿ”Ž found a 'eslintPlugin' migration:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                                                                                                      โ”‚
โ”‚   We've detected you are not using our eslint-plugin.                                                                                โ”‚
โ”‚                                                                                                                                      โ”‚
โ”‚   In order to have the best experience with Storybook and follow best practices, we advise you to install eslint-plugin-storybook.   โ”‚
โ”‚                                                                                                                                      โ”‚
โ”‚   More info: https://github.com/storybookjs/eslint-plugin-storybook#readme                                                           โ”‚
โ”‚                                                                                                                                      โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
? Do you want to run the 'eslintPlugin' migration on your project? โ€บ (y/N)
  1. Youโ€™ll be prompted to configure npm. Type y for yes
โœ… Configuring eslint rules in .eslintrc.cjs
โœ… Adding Storybook to extends list
โœ… ran eslintPlugin migration
๐Ÿ”Ž found a 'npm7' migration:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                                                                   โ”‚
โ”‚   We've detected you are running npm 8.15.0                                                       โ”‚
โ”‚    which has peer dependency semantics which Storybook is incompatible with.                      โ”‚
โ”‚                                                                                                   โ”‚
โ”‚   In order to work with Storybook's package structure, you'll need to run `npm` with the          โ”‚
โ”‚   `--legacy-peer-deps=true` flag. We can generate an `.npmrc` which will do that automatically.   โ”‚
โ”‚                                                                                                   โ”‚
โ”‚   More info: https://github.com/storybookjs/storybook/issues/18298                                โ”‚
โ”‚                                                                                                   โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
? Do you want to run the 'npm7' migration on your project? โ€บ (y/N)
  1. The first time you run storybook via npm run storybook, youโ€™ll get these errors.
> connect-four@1.0.0 storybook
> start-storybook -p 6006

info @storybook/svelte v6.5.12
info 
ERR! Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/nicktaylor/dev/oss/connect-four/svelte.config.js from /Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs not supported.
ERR! Instead change the require of svelte.config.js in /Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs to a dynamic import() which is available in all CommonJS modules.
ERR!     at Object.<anonymous> (/Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs:16:19)
ERR!     at interopRequireDefault (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-common/dist/cjs/utils/interpret-require.js:64:16)
ERR!     at serverRequire (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-common/dist/cjs/utils/interpret-require.js:101:10)
ERR!     at getPreviewBuilder (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-server/dist/cjs/utils/get-preview-builder.js:25:55)
ERR!     at buildDevStandalone (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-server/dist/cjs/build-dev.js:106:71)
ERR!     at async buildDev (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-server/dist/cjs/build-dev.js:174:5)
ERR!  Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/nicktaylor/dev/oss/connect-four/svelte.config.js from /Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs not supported.
ERR! Instead change the require of svelte.config.js in /Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs to a dynamic import() which is available in all CommonJS modules.
ERR!     at Object.<anonymous> (/Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs:16:19)
ERR!     at interopRequireDefault (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-common/dist/cjs/utils/interpret-require.js:64:16)
ERR!     at serverRequire (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-common/dist/cjs/utils/interpret-require.js:101:10)
ERR!     at getPreviewBuilder (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-server/dist/cjs/utils/get-preview-builder.js:25:55)
ERR!     at buildDevStandalone (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-server/dist/cjs/build-dev.js:106:71)
ERR!     at async buildDev (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-server/dist/cjs/build-dev.js:174:5) {
ERR!   code: 'ERR_REQUIRE_ESM'
ERR! }

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

/Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs:16
    "preprocess": require("../svelte.config.js").preprocess
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/nicktaylor/dev/oss/connect-four/svelte.config.js from /Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs not supported.
Instead change the require of svelte.config.js in /Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/nicktaylor/dev/oss/connect-four/.storybook/main.cjs:16:19)
    at interopRequireDefault (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-common/dist/cjs/utils/interpret-require.js:64:16)
    at serverRequire (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-common/dist/cjs/utils/interpret-require.js:101:10)
    at getFrameworkPackage (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-common/dist/cjs/presets.js:326:50)
    at loadAllPresets (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-common/dist/cjs/presets.js:356:26)
    at buildDev (/Users/nicktaylor/dev/oss/connect-four/node_modules/@storybook/core-server/dist/cjs/build-dev.js:209:50) {
  code: 'ERR_REQUIRE_ESM'
}
  1. In the storybook main.cjs file make the following changes
module.exports = {
  stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx|svelte)'],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-interactions'
  ],
  framework: '@storybook/svelte',
  core: {
    builder: '@storybook/builder-vite'
  },
  svelteOptions: {
-    preprocess: require('../svelte.config.js').preprocess
+    preprocess: import('../svelte.config.js').preprocess
  },
  features: {
    storyStoreV7: true
  }
};
  1. Save the file and rerun the command to start Storybook, npm run storybook.
  2. Storybook loads.

Hi @nickytonline I would like to give this a go!

Sounds good! I've assigned it to you @YolandaHaynes. ๐Ÿ˜Ž

@YolandaHaynes, #20 has been merged, so you can start working on this. No rush though! ๐Ÿ˜