-
Notifications
You must be signed in to change notification settings - Fork 81
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
Storybook & some KButton stories #312
Storybook & some KButton stories #312
Conversation
0e05acb
to
66557d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @nucleogenesis for your effort. I am not sure if we need Storybook in KDS and would suggest discussing the idea of using the KDS documentation site itself for this purpose in more detail at first. Posted more details on Slack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To sum it up briefly, my main concern is that I don't see a single story for KButton
here that we couldn't visualize and eventually test in our KDS documentation using regular Vue template syntax in DocsShow
while improving the documentation itself on that opportunity which seems to be a promising alternative to Storybook to me, that I'd welcome to explore in more detail before introducing new tooling for everyone.
It seems that @bjester can see some benefits in Storybook, particularly in regards to testing, and has some ideas about how to overcome duplicate stories/examples (@bjester please correct me or specify more).
We can chat about it more for sure. It might take me a while to get to this again, and I don't want to block it for everyone, so if the majority prefers playing around with it rather sooner than later, feel free to go ahead and we can see how it works.
You can see this thread for details https://learningequality.slack.com/archives/CTG8XDTCL/p1644482179585449
Maybe having a file with stories for a component in a directory together with that component? It's similar to how Jest tests can be organized. I find it helpful since it's easy to navigate and I think we discussed having the same structure in Studio and Kolibri one day ideally in regards to Jest files (story file is similar to the spec file, in a way) |
20b20ff
to
7b2d110
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @nucleogenesis, code looks good to me.
I'm going to need to release kolibri-tools so that KDS can depend on it here because Storybook requires >=14 Node. I'll come back to this and take care of that later this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! I appreciate the instructions in the README, too. They are clear and informative.
Noting that with @MisRob 's presentation of how to use KDS for the same purpose we'd use Storybook, this may not really be useful anymore. Thoughts @marcellamaki ? |
@nucleogenesis - I think that's a good point. I don't think there's harm in having it set up, but I also don't think it's necessary. If you'd like to get this merged, I think we could - otherwise, okay with me to backburner this and close it. |
One possible harm is that we now have 2 ways of doing something - and ideally editing the documentation is preferable, because then it's not only doing a live test of the component, but also creating documentation for it too? |
Ah this conversation is coming back to me now. In the Slack thread @MisRob shared, I had an idea for how we could leverage Storybook stories in the KDS docs, that could also enrich our documentation. I imagined it would allow us to do something like the Shopify Polaris design system (try out the buttons at the top, and how it switches between different examples) From the slack thread:
|
Following up to this, I realized I have some lingering work in my KDS repo, something like an example along the lines of my last comment. |
@bjester Switching between different examples is something that'd need to be added to our KDS documentation system common components, no matter whether we use Storybook or not. You can see |
I second @rtibbles's comment:
Plus I'd add maintenance costs. @bjester Regarding your proposal about using Storybook stories as a source for KDS stories: On a high level, writing stories in 3rd party system that uses a different syntax (see https://storybook.js.org/docs/vue/writing-stories/args#story-args) just to convert them to our own system is unnecessarily complicated in my view, when compared to writing them directly in Vue like we currently do, with the help of some common documentation components that are already implemented, work well, and can be extended to our needs. It would open relatively lots of issues affecting the way we work with KDS documentation that would need to be answered first. I can elaborate on it but before that, I think it'd be good to answer the most important question - do we need this, and why? If you want to move in such a direction, at first I'd suggest hearing from the team what benefits Storybook can offer us in the KDS context that the existing KDS documentation system can't. Not in a sense of its general features, but rather real things that we lack and want to start using on daily basis. |
@MisRob defining some information architecture for organizing examples is a good motivation, something that's common place with any code files, database tables, or test structures. If we add multiple examples, it seems unscalable to plop them directly into the documentation component along the lines of "writing them directly in Vue like we currently do." Utilizing an existing architecture that's simple and well documented like Storybook's means we can leverage their documentation for that architecture. Having a defined information architecture opens the door to further enhancements like I've already mentioned that bring real benefits that we lack. I view it as forward looking.
What sorts of issues? |
I've been lurking on this thread out of curiosity, and will briefly chime in with some context and thoughts. Of course, I fully respect what ever direction the current team chooses to take KDS in, and will probably not add much else here unless someone has a specific follow-up question. When KDS was first being built I investigated both basing it fully on Storybook and also integrating Storybook as a way to show examples as discussed here. I also investigated Vue Styleguidist for similar purposes. I eventually came to believe that:
Overall my recommendation would be to see whether more automated testing is worth the effort based on recent history of regressions. If so, storybook could be a useful engineering and CI tool to prevent these in the future. However I think it's less useful for user-facing documentation. That said, if the decision is made to integrate Storybook within the documentation, some details to watch out for:
|
Oh - one other very important note: 🎉 Happy new year! 🎉 I miss you all... keep up the great work 😄 |
Good to still see you around from time to time @indirectlylit, thank you, and happy new year to you too and everyone who's reading this. |
Thanks @indirectlylit for your thoughts! I did some short investigation into the visual diffs using Percy a few years ago, on that project you proposed for Kolibri. With that background, it seemed like utilizing Storybook for rendering individual examples and capturing screenshots for Percy could work really well. There are certainly other ways we could accomplish that, but I think extracting those screenshots from the documentation pages could be more subject to regressions if we make updates to documentation layouts and/or components. So in my thoughts, using some shared information architecture for the examples could support both independently while minimizing the chance and overhead of maintaining everything in the docs pages. I think having something like Percy run on every PR, on examples connected to components that were modified in the PR, could be really valuable, let alone a really cool development tool. |
Perhaps a matter of opinion, I see this simplicity and flexibility as one of the best features of the current KDS documentation system. We typically don't need to write documentation with 20 examples at the top like in Shopify's Polaris. I appreciate the Jupyter Notebook feel of telling an interactive story. Another important benefit is that you can take exactly the same code from
Mostly related to areas that @indirectlylit already mentioned above I agree that automated testing would be very good. In an ideal world, we would be able to use the same source of data and follow general best practices. Often, things are not ideal and premature generalization can introduce complexity. I am suspicious that it may be the case with using Storybook for user documentation, even when just partially. Perhaps I'm wrong or maybe some more complexity would be worth it, I only suggest that before solutions or more discussions, we are very clear on what are the limitations we need to improve here as the needs for Storybook as a tool for automated testing are different from the needs for Storybook as documentation. |
@nucleogenesis Just to be sure, I still think that this particular PR is okay to be merged if folks want to play around with Storybook, as noted when approving it couple of months ago. My recent comments about the need to discuss various motivations and research things are related to refactoring KDS to be built around it as documenation tool. Apologies if that wasn't clear. cc @bjester |
This PR needs to be fixed up a bit before merging and I've not come back to it in some time. I'm not sure when I'll fix it up but I think that it depends largely on the discussion around moving our documentation to use Storybook. It's unclear to me what the path forward would look like and what changes would have to be made to fully leverage Storybook.
I do think that, overall, we'll have a hard time prioritizing this given the many other things we have going right now, but I think it will be worth continuing to bear it in mind as we find ways to improve KDS and our dev experience with it because even without the bells and whistles of automated visual diff testing or whatever, it will be a straightforward experience to test changes made to components. |
This PR is one example of work where Storybook for testing may help us: #429. The PR fixes |
This will need to be rebased and retargeted to |
Closing. We can revisit this if/when the topic comes up again |
Description
We've discussed in the past wanting to try out Storybook, particularly for KDS, and I had set it up with ease on a personal toy project a few months back so I have been optimistic about setting it up here and working with it.
kolibri-tools
in Webpack 5 upgrade kolibri#9014 because Storybook requires Node >= 14 andkolibri-tools
currently requires Node 10.npx sb init
(very convenient, excellent install process)preview.js
config to bootstrapKThemePlugin
(may still need to do the same in the main.js config file to accommodate building Storybook - still more to learn here)sass
andsass-loader
to devDependenciesSteps to test
cd
intopackages/kolibri-tools
and runyarn link
yarn link kolibri-tools
yarn storybook
should spin up the server(optional) Implementation notes
Does this introduce any tech-debt items?
Story organization is something I'm not sure about. Dumping them all in one folder may not be easy to track over a long period of time but that's a problem we can figure out when we get there I suppose.