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

Add StoryBook #251

Merged
merged 143 commits into from
Jan 16, 2021
Merged

Add StoryBook #251

merged 143 commits into from
Jan 16, 2021

Conversation

Vadorequest
Copy link
Member

@Vadorequest Vadorequest commented Jan 11, 2021

Status

STABLE, the biggest issues have been fixed (babel/webpack/Emotion 10-11/Node vs browser/React providers).

Currently studying Storybook addons (first time using SB) to see what should be included by default.

SB is now configured with proper plugins, adding more stories (ideally, all components should have their stories).

All NRN components have been documented thoroughly.


Resources:

Issues

  • ⚠️ Emotion 11 emotion-js/emotion#1606 (comment) css prop isn't recognized in some part of the code
    • It doesn't seem to be a compilation issue (Next.js compiles properly locally and on Vercel). The error is only visible on the WebStorm IDE. Maybe a TS type override might fix the issue, until Storybook upgrades to Emotion 11? (couldn't find a way to override TS types DOMAttributes in node_modules/@emotion/core/types/index.d.ts)
    • To solve this, I've @ts-ignore the few statements where errors were thrown (~6)
  • ✅ Emotion 11 requires to use a custom babel file. I first tried using the same as the one used by Next.js (babel.config.js) but it uses automatic runtime, which isn't supported by MDX, which is used in Storybook. So, I had to create a custom .storybook/babel.config.js file using classic mode. See https://emotion.sh/docs/css-prop#babel-preset
  • ✅ NRN defines many providers, those need to be mocked using decorators in .storybook/preview.js
  • ✅ Next.js router needs to be mocked (decorator), I used storybook-addon-next-router
  • ✅ Sentry uses @sentry/node, webpack was configured to replace it by @sentry/browser during compilation
  • ✅ The Airtable dataset needed to be mocked
  • ✅ Various issues with node-related modules fs, etc. (webpack config)
  • ✅ Added support for CSS Modules, used storybook-css-modules-preset (they're supported natively in Next.js) - See Next.js + TypeScript + Storybook compatibility issues storybookjs/storybook#9610 (comment) and @next/plugin-storybook issues vercel/next.js#19345

Features

Storybook static site hosted on Vercel

  • Upon code change, automatically export the Storybook static site and deploys it on Vercel

This way, you always have an online up-to-date version of your components!

Demo: https://nrn-v2-mst-aptd-at-lcz-sty-storybook.vercel.app/ (auto-updated)

Support for MDX, TSX, Emotion 11 and CSS Modules

  • Our components can be used normally, with TypeScript and Emotion or CSS Modules (that wasn't as easy to implement as one might believe)

I18n support in Stories

  • Our stories can be localized using a custom locale in the Storybook top toolbar!
  • Locize translations are being fetched upon build and then used within stories (using a filesystem cache to avoid fetching Locize API during navigation, to reduce cost).

Usage

Storybook localhost

Run yarn sb

Storybook online

Automatically built + deployed on another Vercel project (dedicated project), as a static site.

https://nrn-v2-mst-aptd-at-lcz-sty-storybook.vercel.app/

Looking for a way to optionally protect the static site behind Basic Auth.

@github-actions
Copy link

✅  Deployment SUCCESS
Commit f41008e successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-dy4lu8awa.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit f41008e previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-dy4lu8awa.vercel.app

… already installed by Next.js and shouldn't be specified (let Next.js auto-update those) + use fixed versions + ignore storybook-static folder (when exporting static site)
@github-actions
Copy link

✅  Deployment SUCCESS
Commit d5570f8 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-achjbsxj3.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit d5570f8 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-achjbsxj3.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit 206f209 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-k3vj7njcb.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit 206f209 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-k3vj7njcb.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit a2cd983 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-59pt4acow.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit a2cd983 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-59pt4acow.vercel.app

@github-actions
Copy link

❌  Deployment FAILED
Commit 6a3bff2 failed to deploy Storybook static site to
click to see logs

@github-actions
Copy link

✅  Deployment SUCCESS
Commit 6a3bff2 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-gvvn8qawf.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit 6a3bff2 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-gvvn8qawf.vercel.app

@github-actions
Copy link

❌  Deployment FAILED
Commit f6d01a6 failed to deploy Storybook static site to
click to see logs

@github-actions
Copy link

✅  Deployment SUCCESS
Commit f6d01a6 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-lu970cmal.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

…ting + don't deploy to all regions to avoid Vercel error
@github-actions
Copy link

✅  E2E tests SUCCESS for commit f6d01a6 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-lu970cmal.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit f5e4923 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-9tfk8dr3x.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit f5e4923 successfully deployed Storybook static site to https://nrn-v2-mst-aptd-at-lcz-sty-storybook-4m3u29dwh.vercel.app
Deployment aliased as

…useful later to trigger production deployment on master branch)
@github-actions
Copy link

✅  Deployment SUCCESS
Commit e6251e6 successfully deployed Storybook static site to https://nrn-v2-mst-aptd-at-lcz-sty-storybook-4m3u29dwh.vercel.app
Deployment aliased as

@github-actions
Copy link

✅  E2E tests SUCCESS for commit f5e4923 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-9tfk8dr3x.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit 623d2d0 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-fwgk2f52j.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit d179fa4 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-7oaf6d5f4.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit d179fa4 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-7oaf6d5f4.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit 8467569 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-d8wh6xvpg.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit d179fa4 successfully deployed Storybook static site to https://nrn-v2-mst-aptd-at-lcz-sty-storybook-3gv3drgkg.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-storybook

@github-actions
Copy link

✅  Deployment SUCCESS
Commit 8467569 successfully deployed Storybook static site to https://nrn-v2-mst-aptd-at-lcz-sty-storybook-odeivnhpr.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-storybook

@github-actions
Copy link

✅  E2E tests SUCCESS for commit 8467569 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-d8wh6xvpg.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit 833c4e1 successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-ka6iuy3za.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit 833c4e1 previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-ka6iuy3za.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit f1e44ff successfully deployed to https://nrn-v2-mst-aptd-at-lcz-sty-c1-e631etced.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-c1-storybook.vercel.app

@github-actions
Copy link

✅  Deployment SUCCESS
Commit f1e44ff successfully deployed Storybook static site to https://nrn-v2-mst-aptd-at-lcz-sty-storybook-ch60it9z1.vercel.app
Deployment aliased as nrn-v2-mst-aptd-at-lcz-sty-storybook

@github-actions
Copy link

✅  E2E tests SUCCESS for commit f1e44ff previously deployed at https://nrn-v2-mst-aptd-at-lcz-sty-c1-e631etced.vercel.app

@github-actions
Copy link

✅  E2E tests SUCCESS for commit f1e44ff previously deployed Storybook static site at https://nrn-v2-mst-aptd-at-lcz-sty-storybook-ch60it9z1.vercel.app

@Vadorequest Vadorequest marked this pull request as ready for review January 16, 2021 23:55
@Vadorequest Vadorequest merged commit 2d9587a into v2-mst-aptd-at-lcz-sty Jan 16, 2021
@Vadorequest Vadorequest deleted the storybook branch January 16, 2021 23:56
Vadorequest added a commit that referenced this pull request Jan 17, 2021
This was referenced Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Storybook
1 participant