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 a storybook for the ui package #2504

Merged
merged 23 commits into from
Dec 22, 2017
Merged

Add a storybook for the ui package #2504

merged 23 commits into from
Dec 22, 2017

Conversation

tmeasday
Copy link
Member

@tmeasday tmeasday commented Dec 18, 2017

Issue:

No storybook exists for storybook's UI itself 😮

What I did

Added stories for the lib/ui package

How to test

Run yarn storybook from the top level.

I'm not sure if this is the best approach. We could also add a storybook inside lib/ui but we'd have a circular dependency issue.

Note as well that I added the stories for the lib/components package to this storybook; I note they've also been added to the cra-kitchen-sink app -- perhaps this is a better approach?

Let me know what you think.

Is this testable with jest or storyshots?

Potentially we could use storyshots?

Does this need a new example in the kitchen sink apps?

NO

Does this need an update to the documentation?

NO

@tmeasday tmeasday changed the title Tmeasday/add stories Add a storybook for the ui package Dec 18, 2017
@@ -0,0 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
Copy link
Member

Choose a reason for hiding this comment

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

Can we not use a /examples/<any> here? Do we really have to add something to the root of the project?

Copy link
Member

Choose a reason for hiding this comment

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

I would be happy with an examples/official or something, where we have a storybook to demo storybook's UI components.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have any problem with that. The only thing is potentially wanting to combine all react-based storybooks in a single storybook (components, ui, cra-vanilla).

[This works better for chromatic for instance. I'm not sure it helps much else -- maybe storyshots?]

Maybe examples/offical-storybook or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or examples/meta[-storybook]?

Copy link
Member

Choose a reason for hiding this comment

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

examples/offical-storybook would get my vote

@ndelangen
Copy link
Member

Lot's of love here, This will be fantastic to have!

Just hoping we can move the files away from the project root, since we're already crowding the project root folder a lot.

@ndelangen ndelangen added maintenance User-facing maintenance tasks ui labels Dec 18, 2017
@Hypnosphi
Copy link
Member

Note as well that I added the stories for the lib/components package to this storybook; I note they've also been added to the cra-kitchen-sink app -- perhaps this is a better approach?

In fact, I originally put them to lib/components, but @ndelangen asked me to move them to cra-kitchen-sink.
And now I actually feel very convenient to have all the examples in a single storybook instance. So maybe we should move the lib/ui stories there as well

@tmeasday
Copy link
Member Author

I actually kind of feel like a storybook/ directory at the top level would be kind of a cool thing to have?

@ndelangen
Copy link
Member

ndelangen commented Dec 18, 2017

I don't that will convey meaning to anyone just browsing through the code, where-as a folder /examples/official-storybook would.

Of course this is really subjective, Personally I feel fairly strongly, that grouping the examples together is the right approach, but I can change my mind, if 3/4 others vote in favour of your proposal @tmeasday.

To me, it's just another example of storybook that we use internally to develop and test our work on.

@Hypnosphi
Copy link
Member

Hypnosphi commented Dec 18, 2017

I actually kind of feel like a storybook/ directory at the top level would be kind of a cool thing to have?

Maybe, but only if we move all the other sample stories there

I'm strongly inclined into having all the React examples in one place. Currently it's example-kitchen-sink. That way, the workflow is pretty much the same for any of the changes made or reviewed.

One of the cool parts about it is that we deploy kitchen-sink apps to netlify for each PR, so there's a way to test things without actually cheking out the code locally

@tmeasday
Copy link
Member Author

I'm not very opinionated about this, but I would say as a new developer I would probably not expect to find the stories about the storybook UI in the "kitchen sink" example.

I think we all agree that all the react-based stories (ui, components, various addons, other stuff in KS) should be in the one storybook. My vote would be examples/official-storybook. Then we can make KS simple again (like the other KSs) and move any tricky stuff like netlify over to official-storybook.

@Hypnosphi
Copy link
Member

Sounds good

@ndelangen
Copy link
Member

Let's do it!

@tmeasday
Copy link
Member Author

On the case.

@ndelangen
Copy link
Member

That chromatic is fantastic @tmeasday !

Will Chromatic also show up as a github status?

@tmeasday
Copy link
Member Author

@ndelangen sure does! Check out the chromatic PR: #2505

screenshot 2017-12-21 11 04 53

I'll take the lack of negative comments as a positive and I'll get the tests passing on this branch.

@tmeasday
Copy link
Member Author

I'm getting this error from storyshots:

[187:0x36cbe80]   105747 ms: Mark-sweep 1400.4 (1454.0) -> 1400.4 (1454.0) MB, 1403.1 / 0.0 ms  allocation failure GC in old space requested
[187:0x36cbe80]   107011 ms: Mark-sweep 1400.4 (1454.0) -> 1400.4 (1452.5) MB, 1262.8 / 0.0 ms  last resort GC in old space requested
[187:0x36cbe80]   108309 ms: Mark-sweep 1400.4 (1452.5) -> 1400.4 (1452.5) MB, 1297.2 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3719efba5ee1 <JSObject>
    1: read [/tmp/storybook/node_modules/react-dom/cjs/react-dom-server.node.development.js:~2206] [pc=0x23f6ad3e54b2](this=0x2bc5637e721 <ReactDOMServerRenderer map = 0x51a975c0841>,bytes=0x3795986829a9 <Number inf>)
    3: renderToStaticMarkup [/tmp/storybook/node_modules/react-dom/cjs/react-dom-server.node.development.js:2512] [bytecode=0x3b8b963a9489 offset=31](this=0x1665b6d8da41 <Object ma...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x121a7ac [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node]
 6: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node]
 7: 0x23f6ace0463d

Have you guys seen this before?

@codecov
Copy link

codecov bot commented Dec 21, 2017

Codecov Report

Merging #2504 into release/3.3 will increase coverage by 0.73%.
The diff coverage is 83.14%.

Impacted file tree graph

@@               Coverage Diff               @@
##           release/3.3    #2504      +/-   ##
===============================================
+ Coverage        19.45%   20.18%   +0.73%     
===============================================
  Files              387      398      +11     
  Lines             8733     8838     +105     
  Branches           940      961      +21     
===============================================
+ Hits              1699     1784      +85     
+ Misses            6303     6300       -3     
- Partials           731      754      +23
Impacted Files Coverage Δ
...b/components/src/navigation/routed_link.stories.js 100% <100%> (ø)
.../ui/src/modules/ui/components/menu_item.stories.js 100% <100%> (ø)
...ules/ui/components/stories_panel/header.stories.js 100% <100%> (ø)
...ui/components/stories_panel/text_filter.stories.js 100% <100%> (ø)
lib/components/src/navigation/menu_link.stories.js 100% <100%> (ø)
...modules/ui/components/addon_panel/index.stories.js 100% <100%> (ø)
.../src/modules/ui/components/layout/index.stories.js 100% <100%> (ø)
lib/ui/src/libs/withLifecycleDecorator.js 17.14% <37.5%> (ø)
...ui/src/modules/ui/components/search_box.stories.js 62.5% <62.5%> (ø)
...dules/ui/components/stories_panel/index.stories.js 90.9% <90.9%> (ø)
... and 91 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c97eaf9...1a0e285. Read the comment docs.

@ndelangen
Copy link
Member

Definitely the right the direction @tmeasday, fantastic work!

@tmeasday
Copy link
Member Author

The segfault was something to do with react-modal. Should probably figure it out but I'll just disable that test for storyshots for now.

Fun times! babel/babel#6226

We don't want to copy `.storyshots` files even though babel doesn't think they are JS
@tmeasday tmeasday force-pushed the tmeasday/add-stories branch from ae4ed52 to e4be9f5 Compare December 21, 2017 21:57
@tmeasday
Copy link
Member Author

@ndelangen shall I merge this?

@ndelangen
Copy link
Member

Yes merge when ready, after, we should add a netlify site for the newly created example!

@tmeasday tmeasday merged commit cbe6560 into release/3.3 Dec 22, 2017
@tmeasday tmeasday deleted the tmeasday/add-stories branch December 22, 2017 00:34
@Hypnosphi
Copy link
Member

Hypnosphi commented Dec 22, 2017

Why UI and components stories are not part of official-storybook?

@tmeasday
Copy link
Member Author

tmeasday commented Dec 22, 2017 via email

@Hypnosphi
Copy link
Member

Oh, now I see that they are. But their sources are in packages. We probably should use a single approach then. That is, either move ui and components stories sources to examples/official-storybook directory, or move all the addons' stories to corresponding packages.

CC: @ndelangen

@ndelangen
Copy link
Member

Move all stories into the examples please.

Our packages shouldn't contain stories I think. Please let me know if you disagree on that.

I think co-locating the stories makes a bit more sense in this case. Reason for this is that we want to use the example/* as a way of showing off how to write stories.

@tmeasday
Copy link
Member Author

Hmm, I can see the argument for this but it'd be a bit weird -- in particular the lib/ui stories mirror the .test.js files in that project (in the future it would be good to consolidate those further). When someone works on that project, wouldn't it be annoying to have to update a story file in a completely different location?

Maybe we should use a symlink or something?

@ndelangen
Copy link
Member

🤔

@tmeasday
Copy link
Member Author

I'm stumped too ;)

@tmeasday
Copy link
Member Author

@ndelangen still willing to make whichever changes make sense here, I'm just not sure what's best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants