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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experience 8346: Add configuration for local instance of Storybook #8803

Merged
merged 1 commit into from Apr 3, 2023

Conversation

stephenkao
Copy link

@stephenkao stephenkao commented Mar 22, 2023

This changeset adds the initial configuration needed to spin up Storybook locally. It's incredibly simple right now, but it should include most addons that we need. Also included are very simple CSF examples for the StaticAlert and USLink components as a proof-of-concept.

There's a known error with React 18 here, but it shouldn't affect us for the time being. We could also install the bleeding-edge version of Storybook, but it looks like there are other issues with that as well -- so I recommend just sticking with the latest stable version until the next version is officially out.

Test Steps:

  1. Run yarn install to get latest dependencies
  2. Run yarn run storybook to run Storybook locally
  3. Go to localhost:6006 (will happen automatically)
  4. Browse the Storybook 馃檹

Changes

Screenshot 2023-03-22 at 09 55 36

Screenshot 2023-03-22 at 09 55 57

Screenshot 2023-03-22 at 09 56 00

Screenshot 2023-03-22 at 09 56 01

Screenshot 2023-03-22 at 09 56 02

Screenshot 2023-03-22 at 09 56 26

Checklist

Testing

  • Tested locally?
    - [ ] Ran ./prime test or ./gradlew testSmoke against local Docker ReportStream container?
  • (For Changes to /frontend-react/...) Ran npm run lint:write?
    - [ ] Added tests?

@stephenkao stephenkao added the experience Team label to flag issues owned by the Experience Team label Mar 22, 2023
@stephenkao stephenkao temporarily deployed to staging March 22, 2023 13:59 — with GitHub Actions Inactive
@stephenkao stephenkao force-pushed the experience/8346/local-storybook branch from aea92ef to 5c14704 Compare March 22, 2023 14:01
@stephenkao stephenkao temporarily deployed to staging March 22, 2023 14:01 — with GitHub Actions Inactive
@stephenkao stephenkao force-pushed the experience/8346/local-storybook branch from 5c14704 to 5c90872 Compare March 22, 2023 14:03
@stephenkao stephenkao temporarily deployed to staging March 22, 2023 14:04 — with GitHub Actions Inactive

initializeWorker();

function withRestHooksCacheProvider(Story) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add an all-in-one HOC like we do in tests, but I figure the granularity might be good. Not really an issue either way, though!

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are included by default on installation, but they're useful!

import "../src/content/generated/global.out.css";

// mock all dates in stories to make sure we don't run into date-related inconsistencies
MockDate.set("2023-01-01");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This'd be especially useful if we start using snapshots with Chromatic.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious how this will interact with faker.js if we end up using it but something to worry about later.

options: {
storySort: {
method: "alphabetical",
order: [],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the order should be yet since our component system is still in a limbo state.

},
};

initializeWorker();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSW isn't hooked up yet, but we might as well get it started 馃し

core: {
builder: "@storybook/builder-webpack5",
},
refs: {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows for composition with other/external Storybooks. Everything's still going through network requests so browsing external stories won't be as snappy as our own, but it's still nice to have everything in one place.

@stephenkao stephenkao force-pushed the experience/8346/local-storybook branch from 5c90872 to 8112f11 Compare March 24, 2023 16:42
@stephenkao stephenkao temporarily deployed to staging March 24, 2023 16:42 — with GitHub Actions Inactive
@stephenkao stephenkao force-pushed the experience/8346/local-storybook branch from 8112f11 to a52b8ce Compare March 28, 2023 14:03
@stephenkao stephenkao temporarily deployed to staging March 28, 2023 14:04 — with GitHub Actions Inactive
@penny-lischer
Copy link
Collaborator

@stephenkao do we need a readme file for storybook that contains at the very least...
All components should have a *.stories.tsx file in their directory next to their tests.

@penny-lischer
Copy link
Collaborator

@stephenkao do we want to include a markdown Introduction file describing an overview and the difference between our components and Trussworks and when to use one over the other?

@stephenkao stephenkao force-pushed the experience/8346/local-storybook branch from a52b8ce to 51ed086 Compare March 30, 2023 16:08
@stephenkao stephenkao temporarily deployed to staging March 30, 2023 16:08 — with GitHub Actions Inactive
@stephenkao stephenkao force-pushed the experience/8346/local-storybook branch from 51ed086 to 2806447 Compare March 30, 2023 18:05
@stephenkao stephenkao temporarily deployed to staging March 30, 2023 18:05 — with GitHub Actions Inactive
@stephenkao
Copy link
Author

@stephenkao do we need a readme file for storybook that contains at the very least... All components should have a *.stories.tsx file in their directory next to their tests.

@stephenkao do we want to include a markdown Introduction file describing an overview and the difference between our components and Trussworks and when to use one over the other?

My feeling is that Storybook documentation can happen as part of a separate ticket since it involves establishing guidelines and conventions as well. This changeset is specifically to get a local instance runnable so we can start to use it now as we're developing new changes. What are your thoughts about this?

Copy link
Collaborator

@penny-lischer penny-lischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

import "../src/content/generated/global.out.css";

// mock all dates in stories to make sure we don't run into date-related inconsistencies
MockDate.set("2023-01-01");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious how this will interact with faker.js if we end up using it but something to worry about later.

This changeset adds the initial configuration needed to spin up Storybook locally.  It's incredibly simple right now, but it should include most addons that we need.  Also included are very simple CSF examples for the StaticAlert and USLink components as a proof-of-concept.

There's a known error with React 18 [here](storybookjs/storybook#17831 (comment)), but it shouldn't affect us for the time being.  We could also install the bleeding-edge version of Storybook, but it looks like there are other issues with that as well -- so I recommend just sticking with the latest stable version until the next version is officially out.
@stephenkao stephenkao force-pushed the experience/8346/local-storybook branch from 2806447 to 93b95b4 Compare April 3, 2023 14:17
@stephenkao stephenkao temporarily deployed to staging April 3, 2023 14:17 — with GitHub Actions Inactive
@stephenkao stephenkao enabled auto-merge (squash) April 3, 2023 14:21
@sonarcloud
Copy link

sonarcloud bot commented Apr 3, 2023

SonarCloud Quality Gate failed.聽 聽 Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@stephenkao stephenkao merged commit 5fc30cd into master Apr 3, 2023
2 of 3 checks passed
@stephenkao stephenkao deleted the experience/8346/local-storybook branch April 3, 2023 14:30
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-a11y",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for later, but this might be a really nice package to see the states of different components without the need of dev tools: https://storybook.js.org/addons/storybook-addon-pseudo-states

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experience Team label to flag issues owned by the Experience Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants