105: Tom Coleman on Storybook v6
Featuring
Links
- Storybook 6.0 Announcement
- Introduction to Storybook for React
- chromatic — Ship UIs faster with automated workflows for Storybook
- chromatic blog and twitter
- Component-Driven Development — article by Tom
People mentioned
Sponsors
Infinite Red
In over your head with a React or React Native app? Infinite Red can help. They're React Native core contributors who've been designing, building and shipping apps for over 10 years. reactpodcast.infinite.red
Transcript
[00:00:00] Michael Chan: This is React Podcast. I'm Chantastic. Today, Tom Coleman tells us what's good in Storybook 6. He elaborates on the headline features of controls, composition, and args, and how they're set to take your component documentation and communication to the next level. We talk about the history of Storybook, its relationship to chromatic visual testing tools, and the power of component-driven development. If you're interested in learning more about Chromatic, check out episode number 91 with Dominic Nguyen. But listen to this one first. Before we dive in, thanks to Infinite Red for supporting this episode. Having access to developers that know the direction React and React Native are headed can completely revolutionize your development process, developer happiness, and customer satisfaction. If you don't have developers like this on your team, you need to find 'em. And I love the people at Infinite Red for this role. Infinite Red has been designing, building, and shipping apps for 10 years, and they wanna bring their expertise and industry connections to your apps. Infinite Red has a sweet deal right now where you get $750 for referring a new project. Get expert help from Infinite Red by visiting reactpodcast.infinite Tom, welcome to React Podcast.
[00:01:35] Tom Coleman: Thanks, Michael. Nice to be here.
[00:01:36] Michael Chan: It's good to have you on the show. Uh, I'm super excited about our topic today. Uh, we had Dom on to talk about Chromatic, uh, maybe like a month and a half ago. And all the things that you're doing there with Chromatic 2. And um, we were like, you know, we need to get a show where we actually talk about Storybook. Because the integration of those things is so uh fascinating and unique. Um so I wanted to invite you on the show and I'm glad you had time. Uh tell me a little bit just about yourself, kind of how you got into working on you know Storybook and Chromatic before we start.
[00:02:11] Tom Coleman: Yeah, of course. Yeah. So my name's Tom, Tom Coleman. Um I'm from Australia, uh live in Melbourne. Um and I guess I've been like in the web development world for 15 years now, something like that, uh maybe 10 years professionally. Um and, you know, once upon a time I was a Rails developer, but-
[00:02:31] Michael Chan: Nice.
[00:02:32] Tom Coleman: Pretty long time ago now, got into JavaScript. Uh, you know, we were we were developing Rails apps and and trying to make them more more interactive in the front end and starting to look at, um, I guess, component libraries for Rails, um, probably before the concept of component library was you know, very popular, um, and actually kind of developed a a tiny little one ourselves back in the day. But anyway, that's uh ancient history. But, um, yeah, so I've been interested in JavaScript ever since, um, and uh particularly Meteor. I'm not sure um how if the audience is super aware of Meteor, but yeah, in the really early days of Meteor, got really into it.
[00:03:13] Michael Chan: Meteor kind of morphed into what is now Apollo, right?
[00:03:17] Tom Coleman: Yeah, exactly. I mean, the company did. I'm not sure that the two JavaScript frameworks, they they cross-pollinate a little, but they're not super- I I don't know if you could say they morphed, but yeah, like Meteor was was all about data and Apollo's all about data, so that was kind of that was kind of the connection there. But they're both really JavaScripty frameworks, I suppose. Um, yeah,
[00:03:40] Michael Chan: but
[00:03:40] Tom Coleman: yeah, I was really into Meteor and and that's kind of what got me like deep into the JavaScript and the open source world. Um, did a lot of open source stuff for Meteor and then ultimately started working for them. Um, and uh, yeah, worked for them for a couple of years, um, and yeah, left Meteor to start our own company, um, alongside Don, who you mentioned, and Zoltan, the other founder. Um, and yeah, we'd all been working for Meteor, and before that we'd all been uh doing some consulting work together, but we we started Chromatic because we were just really jazzed about component- what we call like component-driven development, which is I guess really um nailing down on uh components as like the the primary thing that you develop with. And that's where Storybook comes in. So Storybook is kind of like the tool to do that with. So yeah, that's kind of a really abridged history.
[00:04:33] Michael Chan: I know, it's like you got to pack so much in there. There's like so much uh history and like kind of false turns and whatnot. Um, but that I feel like that gives us some good context. Now, I feel like Storybook and Chromatic kind of have this entangled history.
[00:04:49] Tom Coleman: Yeah.
[00:04:49] Michael Chan: Um, but tell me a little bit about the the actual Storybook um part of it. How does that play into your your kind of transition from, you know, Meteor to Chromatic?
[00:05:00] Tom Coleman: Yeah, it's a it's an interesting story because um it's it's I guess it's a little unusual for an open source project that kind of has a commercial backer. Usually the the project was started like very intentionally by the commercial company. In this case, um Storybook started as React Storybook, was React only at the time, um by by I guess a team, specifically a a single person called Arunoda, um who who was well known in the Meteor community. Um and he had a company called Kadira, uh based out of Sri Lanka, um and and they had developed a Meteor It was a Meteor-based APM. It was a services company for Meteor. And I guess Aranota had this cool idea about Storybook and developed it and did like an awesome job of of making it really popular. Um and it was sort of taking off. Um I guess this was back in 2016, and we were still working for Meteor at the time. So we were very aware of it, um and we we were excited about it because we'd um you know, being into components, and we kind of built our own very, very rudimentary version of the same thing, nowhere near as good as Storybook, that we actually released. It was called um Grammatic, actually. Nice. We we ended up we released that from Meteor, but we ended up stealing the name. They were happy to give it to us. Um anyway, uh so we were following Storybook closely, and then this sort of interesting thing happened where Arunoda uh decided to sort of fold up Codero, the company, and and go and work for Next.js or um Zeit. I I guess they're called Vercel now. Um and uh and so he kind of like just left the project, more or less. Um it had a pretty big community at that point, but it was in this sort of state of flux. Um no one was really um in charge. And and we uh we had started Chromatic by then, um but we hadn't- necessarily locked in on Storybook at that point. We were definitely interested in Storybook and contributing to it, along with a whole bunch of different people around the world. And then slowly over time, it kind of just organically happened that Norbert and Michael, Norbert De Langen and Michael Schulman, who are two of the- who now work for us at Chromatic, sort of alongside some other people in the community who have kind of come and gone. Um, sort of were leading leading development, and I was I was getting pretty involved as well. And then eventually as a company, we kind of decided, you know what, we're gonna double down on Storybook and make our product Storybook only. And like, say it's Storybook, Storybook, everything about Storybook. And and as part of that, we decided to hire the, you know, the the lead maintainers of Storybook so that we could make sure Storybook kept going and and it was as good as it could be. And and so that's kind of just led to the situation we're in now where we're kind of spearheading Storybook development, shepherding it, I guess, um still alongside a massive community of people doing amazing things. Um but yeah, we're, you know, that, you know, uh what is it, 2 years later, we're just really um committed to Storybook and we we think it's the the future of component components, I guess, component-driven development.
[00:08:08] Michael Chan: I love that. Now it it seems kind of odd to think, I mean, they're so integrated now. It seems odd to think of like what Chromatic looked like without that attachment to Storybook.
[00:08:21] Tom Coleman: Yeah.
[00:08:22] Michael Chan: So what did it look like before you doubled down on Storybook?
[00:08:26] Tom Coleman: Yeah, I guess we originally designed it with like any sort of what we- I think we termed them like component explorers. And maybe we should talk a little bit about what Storybook is for people that aren't familiar with it.
[00:08:37] Michael Chan: Sure.
[00:08:38] Tom Coleman: Yeah, so Storybook is a- I guess, yeah, component explorer is a very vague term, but it's a development tool for working on So if you've got a larger, like an app or a design library, a design system, but let's think of an app because it kind of makes it clearer where um Storybook's um value proposition is. So if you've got an app, it's full of components, they're all like intermingled and doing things on on a given screen. If you want to work on a single component, it can be like tricky to get that component into just the right state to like see the thing that you want to change. So So you want to work on the loading state of your search box. Like it may actually not be that easy to do that in your app. You may have to like mess with the backend to make it like hang in a certain position so you can tweak the styles. Um Storybook gives you the ability to take that single component and just render it by itself in a in a certain state. And that state, that certain state is what it's called a story. So that's why it's called Storybook. Um and and so the idea is that when you're working on an app or a design system, you take a single component You whack it up on your screen and you work on it by itself in a certain state, and then you've got all your components cataloged and all the different interesting states of them cataloged. Um, yeah, so that's like what we we we called it Component Explorer. I think I've got a post or two about that. Um, and and there are other tools out there that um also offer similar functionality. Um, so the original vision of Chromatic was that any component explorer Any kind of, I guess, component example system. Um, you could feed these examples into Chromatic. And Chromatic is like a screenshotting tool for these things at the simplest level. So you could feed these examples in from Styleguidist or Storybook or Compositor, I think is another example of these things. And even maybe some of these design system, design libraries, design products have like, they call them symbols usually, but they're like a similar kind of concept. Maybe you could feed all of them in and we would screenshot them and And that input could be generic. That was kind of the original um design. And we've still got like in our codebase, as you could probably imagine, like certain terminology. We call them specs rather than stories. And our developers like all hate me because they're like, what does this even mean, dude? I'm like, sorry, it's historical. Yeah, but yeah, it was quite a while ago now that we said, nah, okay, let's just make this Storybook only. So Um, yeah.
[00:11:06] Michael Chan: It is interesting how how dramatically code changes. Yeah. You know, when you have to build an abstraction over a lot of things and then like maybe you pull that out. And so now you have this historical thing, as you mentioned, of like, oh, like, yeah, no, there a spec is just a story, but it didn't used to be like, it used to be like,
[00:11:22] Tom Coleman: yeah,
[00:11:23] Michael Chan: anything. It didn't have to be a story.
[00:11:25] Tom Coleman: Yeah. It's probably yet another example why like abstracting ahead of time is usually a bad idea, right? Like you just, especially in a startup. You just don't know. So like, what's the point, you know?
[00:11:36] Michael Chan: Yeah.
[00:11:37] Tom Coleman: Might as well just get it done and see what happens. That's that's the lesson there.
[00:11:40] Michael Chan: Well, this is something that I really love about about the story concept. And I think it took me a little bit of time to really kind of wrap my head around. But, and I think it wasn't honestly until Chromatic where I realized like, oh, okay, like this is almost like, like a story is something that like I want to test in isolation, right? Like it's it's some version of this component and its props They're like extremely important to me. Like, you know, if these things, uh, you know, come together, it should definitely show like this kind of state or, you know, reveal an error state or all those kind of things. It's a- I think originally I was like, well, why do I need stories? Like I have components, like I know how to write documentation. But like stories kind of unlock this other thing of like, okay, well, like you have, you know how to write tests, you know how to write documentation, but these, these actually kind of show you When your app comes together, what does that thing look like? You know, all these props are passed in. What does it look like in exactly this state? And I really love- like I love seeing that. Um, as you've developed the concept of stories and how they integrate with integrate with Chromatic and whatnot, um, have you seen patterns kind of emerge as to how like people take these stories and actually use them to their benefit? You know, as opposed to just kind of standard off-the-shelf component documentation?
[00:13:02] Tom Coleman: Yeah, definitely. It's, um, yeah, I think that that that insight of like, oh, hold on, this story is like really useful, uh, it's kind of the genesis of our company, right? Like, um, you know, I I guess the original thing in Chromatic of just taking screenshots, um, is kind of driven from two two key insights. And one of them is that taking screenshots at the level of components. And that gets into doing everything at the level of components, which if you get me started on, I'll talk your ear off about, I think. So I call it like component-driven, and I just think it's like the way to try and build UIs. Um, but but talking specifically about Storybook, the other key insight being that like when you write a story, you might write a story for a bunch of different reasons. Um, so so you mentioned documentation, you know, if you're building a design system. Yeah. Your story is often the example that you want to show someone else. So as you say, like, what are the props that I need to put this into this thing to make it look like that? Um and that's and that's what the story is, it's the example. Um if you're working on an app though, you might build a story as like a test, like a development um scaffold almost. So like, I want to get my um I want to get my dropdown into this state so I can tweak the styles. How do I do that? I write a story where it's in that state, and then every time I want to like change those things, I can just click on the story rather than like messing in the database. And so that's sort of like a different different use case. And then a third thing I might want to do, as you mentioned, is like screenshot it. Um but the insight is that you can actually use the same thing for all of those cases, and um sometimes only one or two of them, sometimes all three. And and you actually kind of it's kind of a a amazing hack that you- a shortcut that you've actually- you've been just working on your app for like the last 2 months and you've built your prototype and it's working well and along the way you built, you know, 100, 200 stories. Oh, it turns out that's 100, 200 test cases that you didn't even realize you were writing. And or maybe that's 100, 200 examples for your design system if it's a design system you've been working on and maybe you've you've written 50 examples as you went, and then all of a sudden your documentation is like 90% written because that's what people want to see, and you just have to add a little bit of text around the edge. That's kind of been the insight that almost happened by accident, you know. I mean, I think a lot of people kind of realized it, but it's amazing. Like, it's just- Yeah. It's such a great- yeah, like I said, almost a hack. Like, it's an accident. Like, You kind of trick people into writing tests. You trick people into writing documentation. It's amazing. It's great.
[00:15:48] Michael Chan: Yeah, it's- so there's this- I love when products come together in this very virtuous way. And one of my favorite products of all time is the is the AeroPress. You use this, the little like plastic coffee maker. And it's so funny, like the one of my favorite things about it is that it's like, because it's a plunger system, it's like self-cleaning, right? And so you're making coffee, but as you're making coffee, you're also cleaning the device. Which it's it's one of those things that just kind of like perfectly formed, right? And it's like it it wasn't designed that way, but like it works awesome because of that thing.
[00:16:23] Tom Coleman: Yeah.
[00:16:23] Michael Chan: And I love hearing how Storybook and Chromatic kind of landed on this. Um because I mean I mean I I I've outed myself on this before, but like I am a you know Storybook Chromatic user. That's what we use for all of our um Um, design system stuff. You've helped me a lot in, in supporting me as a client and, um, or a customer. And I think there is something magical about that Storybook Chromatic integration where you're working on these components and you're working on all the various states and it, it is easier to just make a new story than to have to like change everything all the time and inspect it. And, you know, when you're working with state, keeping that dropdown open, like all that stuff seems very natural. And then as you said, if you're using Chromatic, like boom, now you have test cases, right? And like, these are gonna- these are visual tests. So like, if, if things change the effect to the user and the user experience, like you're gonna see that right away and you got it just by developing.
[00:17:29] Tom Coleman: Yeah. Yeah. And I mean, that, that's right. And it's, it's, it's awesome. But I mean, that's also the same insight that like we kind of had with the documentation, you know, not even outside of Chromatic when Storybook, sort of the 5.x series, 5.1, 5.2, 5.3, has been all about documentation. And and we built this um documentation layer on Storybook that, yeah, often you just get for free as well. Like it's um it's great. It's just uh yeah, it's exciting. And and look, that and maybe that gets to like the future of Storybook as well, where we're sort of thinking um there's There's definitely a lot of value in these stories where you um explicitly say, you explicitly, I guess, enumerate the value of every single input to your story or like prop in React. We call them args as like a general concept. Um, but there is also value in allowing the user, like the viewer of the Storybook, to to to mess with them. And not just the viewer, but also the system to mess with them. So That's kind of like what we're thinking is sort of the next level of this and and should have similar kind of um uh symbiotic, or I don't know quite sure what the right word is, but you know, like multi multi-level wins is Dom's favorite expression. I like that. Multi-level wins. Where whereby making the the inputs to the stories parameterizable, we can we can start doing some other um interesting stuff. So one example You know, um, so I'll talk about like the new version of Storybook that's coming out, um, in, yeah, any day now, in a few weeks, I think. Um, Storybook 6.
[00:19:08] Michael Chan: Which maybe, maybe today by the time that this actually goes out.
[00:19:12] Tom Coleman: There you go. Well, don't put too much pressure on us.
[00:19:15] Michael Chan: The near-term future, whether the past or the near-term future.
[00:19:20] Tom Coleman: Yeah. Um, so, so a headline feature of that is args and, and You know, the the obvious use case, so so as I said, args is is the concept of writing your story in a slightly different way so that the those that set of inputs, that set of props can be parameterized by the system. Um, the the most obvious use case for that is the add-on that we call controls that gives you a little bit of UI that lets you as a viewer of the Storybook sort of change the values. So you might have a value that's a color. It gives you a color picker that lets you change the background color of the button. Say you might have a boolean, it gives you a checkbox to turn it off and on. Um, and and that um builds on an existing add-on that existed in Storybook already called Knobs. Um, and it's it's sort of the next generation of Knobs and it's um built much more into the system. And and that um as a single use case is is good and people People love that, especially in design systems. But what we're thinking is that it can do so much more because now you've got um you know you've got your stories and you've got your interesting cases documented, but you've also got the ability for the system to change them. Now you might be able to, for instance, using a tool like Chromatic, have, say, an embeddable story. So you've you've uploaded your Storybook um to to some service like Chromatic, it's online, Now you can put an iframe on another website and provide values for those args. So you might be like, you know, you might just want to put a single story down or you might want to say, oh, well, let's tweak that thing. Let's put a different text here based on, you know, so maybe like you're embedding a story inside um a design a design tool, um and you you want to pull the actual production code into your design and you want to tweak the input to that button. Um technically, that could work by pulling an iframe and putting the iframe there. Providing different args to the story. Um and so that's that's kind of one idea we've had, and we've had a few others, and they're all kind of just bubbling around at the moment. But we feel like that that um that args concept is kind of gonna unlock gonna unlock another another layer of um another layer of reusability of stories. So we're really excited about that.
[00:21:35] Michael Chan: That sounds amazing.
[00:21:35] Tom Coleman: Yeah, yeah, we'll see. We'll see how it plays out, but it feels good.
[00:21:40] Michael Chan: Yeah, so let's uh let's back up just a little bit. Um, we've been kind of on the last maybe year and a half, you can correct me if I'm wrong, on the like 5, the version 5 release cycle, right?
[00:21:52] Tom Coleman: Yeah.
[00:21:53] Michael Chan: Um, and then upcoming now, I think you just did your first beta maybe at the end of April or early May for version 6.
[00:22:00] Tom Coleman: Mhm, yeah, and we're in the RC now, and speaking on the 28th of July. Yeah.
[00:22:06] Michael Chan: Okay, cool. Um, so, it sounds to me like- so, so, the big headline features, as far as I could tell, were were args, as you you talked about right now, um, composition of Storybooks, um, which we'll talk about, and then also some some some new patterns around, um, you know, server and server frameworks like Rails. Um, I wanna I wanna come back to args in a second, but let's just talk about like kind of like the easiest one I think is probably like the server server support. So, um, what is it- what are some of the things that people have been asking for, um, from Storybook to better support, uh, things like Rails and Laravel per se, frameworks that have that more kind of traditional server response type of thing, or request-response type of lifecycle?
[00:22:53] Tom Coleman: Yeah, I mean, it's really interesting actually. It's, it's actually really exciting for me. Um, I mentioned that I was a Rails developer originally and, and spent a few years like deep in that world, so It's it's kind of fun to come full circle. Um, yeah, I mean, story so the basic way that Storybook works, so Storybook, I mean, we we haven't mentioned, is very much cross-platform. Um, uh, so although it started as a React tool, um, one of the first things that happened as the community kind of took over the project, um, was that we we expanded the support to pretty much cover every JavaScript Um, front-end framework. I'm sure there are some we don't, but we certainly cover a lot, um, and all the big ones for sure. Um, and, you know, the the reason that we can do that is ultimately a story is just, you give me some inputs or args and uh hand it off to your view layer. Let's call it, let's say it's React or it's Angular, and it just needs to kind of render to the screen. Um. And Storybook doesn't really care what the view layer does. It just kind of says, here's your input. And that makes like a heap of sense for a JavaScript framework. And so I imagine that if you're you're a back if you're um I guess a server-side um developer, server-side rendered developer, you probably wouldn't think Storybook was a fit for you. But um you know we kind of had talked about it from time to time and kind of almost I don't want to say jokingly, but kind of just like, oh, hey, it wouldn't be impossible for when I hand you off some args to your framework, your framework actually goes and asks the server, like, give me a little snippet of HTML and then like takes that back and like injects it into the DOM. Sure. And and that like whole process would still be abstracted from Storybook. It would have to be asynchronous. That would be an important difference. But um From Storybook's perspective, it's actually not that different. And so we kind of like mocked up this design for it, but hadn't really taken it any further, um, until John Palmer, who I guess is um active in the Rails community, um, in in the component side of the Rails community, um, came along and kind of said, "Hey, I want to do this." And and we said, "Oh, well, here's how we think it could work." And he was like, "Yeah, that makes sense." And just went ahead and did it. And so That's that's coming, that's shipping in 6.0. It's um it's actually a generic um uh generic tool, generic package. It's called Storybook Server because ultimately it's just making a fetch request to to an endpoint. John's also written uh a sort of an adapter or like a DSL in Rails that lets you kind of define the stories in terms of the component um library. I think it's called Vue Component, I think is the is the library that it's built for. And so that's all that exists on the server side at the moment. There's no reason why someone couldn't quickly put together something similar for Laravel or any other server-rendered framework. We're kind of calling this this release kind of an experimental one because it hasn't been used by a lot of people yet.
[00:25:55] Michael Chan: Sure.
[00:25:56] Tom Coleman: So although it's sort of ready to be used, um I'm sure there'll be kinks that we we discover as as more people start using it.
[00:26:03] Michael Chan: I know that I'm really excited about this because, um you know, I work on a mixed stack, specifically like, you know, Rails and React. Exactly. I imagine a lot of our listeners, you know, work on applications that, you know, have effectively two two minds, right? They have like the- we have, you know, a a legacy application that's basically all in Rails, and we have kind of all, you know, maybe our new hotness that's all in React. But there haven't been a lot of tools that actually support both environments. And so I'm really excited to hear that, you know, you're you're solving that problem because I think that it might bring a whole- you know, once you get it fleshed out, it might- it could bring a whole lot of new, like, um, insight and excitement around these tools that effectively end up in, you know, better user experiences for customers.
[00:26:51] Tom Coleman: Yeah, it's, um, that's right. And I think that use case is super common, and, and hopefully this will allow people to feel more comfortable maybe adding a React or, or whatever front-end layer to their app because they'll know like, oh well, we can use the same tooling to work on both, you know. Yeah. You know, we've still got our backend stack, our legacy stack that we definitely need to support and and and keep keep working on and keep maintaining, but um we can start the new hotness, as you say, in a new framework and uh and and use the one tool. That's sort of that's sort of the hope, and I and I think where I'm sort of out of out of date with the the the sort of server rendered community is exactly how the the the kind of component concept maps through, you know, because Storybook is all about rendering components.
[00:27:43] Michael Chan: Sure, sure.
[00:27:44] Tom Coleman: And at least back when I when we were trying to get components, you know, I mentioned we kind of built a component system in Rails, like a really, really, really like uh simple one. Um, you know, the concept of of having kind of partials that were components, I'm not sure if that's even the right terminology, wasn't exactly like a one-to-one fit. It was kind of- Right. A little bit of shoehorning required. So that'll be really interesting to see. And potentially this um this tooling might might encourage people to start writing their their backend code in a more component-driven way, which I think would be really awesome.
[00:28:17] Michael Chan: Yeah, yeah.
[00:28:18] Tom Coleman: Not not to tell people what to do, because I, as I mentioned, don't even know what people are doing. But uh-
[00:28:23] Michael Chan: I think Rails 6 even um has, uh maybe it's built in, I don't know if it's, you know, just kind of a recommended module, but they have this new kind of component idea, right? And it's designed to, you know, where they've traditionally had partials and that's a very kind of like Rails kind of syntax for all of these things. It seems like they're now supporting, um kind of writing things like components in the syntax of components the way that, you know, React has proven it to be like really effective.
[00:28:53] Tom Coleman: Yeah, and that's really exciting for me because as I mentioned, I'm like all about component So like for me, it's like, hey, there are great reasons why writing writing server-rendered code makes sense, right? For a lot of use cases, you know, everything's a trade-off. And and as much as I write everything in JavaScript, like there's I definitely understand that there are um plenty of plenty of examples where it makes more sense to write things on on the backend.
[00:29:19] Michael Chan: Yeah.
[00:29:19] Tom Coleman: But I still think you should do it with components. I still think it makes sense to like to to to have stories.
[00:29:25] Michael Chan: To have components on all sides.
[00:29:26] Tom Coleman: Yeah, like and and to do it incrementally and and. And think about things from the design onwards, like one component at a time. So that's great. I love that.
[00:29:36] Michael Chan: Now, another cool thing that you're doing to bring all of your documentation together is um composition. And I thought that this was super interesting and something that I think I've wanted as a Storybook user, but wouldn't have been able to articulate that I wanted it. So can you tell me a little bit about Composition, you know, the feature in Storybook 6?
[00:29:59] Tom Coleman: Yeah, for sure. Yeah, it's an interesting one because it hits quite a few different use cases. Kind of sort of over time, it sort of gathered a few different problems that it solves, which is great. Um, so I mean, the simplest description of it is like you've got your Storybook and there may be another Storybook, um, say published online, and you want to look at that other Storybook. Well, Composition gives you a way of actually just bringing that Storybook inside yours. So All the stories of both the ones you're writing and the ones you're like reading are all listed together in two lists in the sidebar, and you can like freely click between them. So like the simplest use cases for that might be, I work at a company, my company has a um a design system that I need to use, um maintained by a separate team. I don't work on that design system, but I'm I I need to know about it, I need to read its documentation, I need to look at its examples. Um, and so I might just compose the design system's um Storybook into mine so that I can- I'm not like having to open a browser tab all the time. I can just like have it right there. Um, and you know, that can get- it can get more complicated than that when your company has like a bunch of different um places that they develop components. So like Dom's example that he likes to talk about is you might have a- you might have your design system, but you might also have your marketing site, you might have your Yep. You might have your actual application, you know, in the case of like a sort of standard startup stack. As a company gets bigger, you'd have more and more things. You might have your backend, you might have your whatever, and it might make sense to put all the components together, especially if you're like a designy, producty kind of person and you want to see the big picture and make sure everything's consistent and click through it all. So it's kind of like the the the straightforward simple use case. But then there are a couple that come out from it that are actually really cool. So um one of them one of them is thinking just unpacking that design system case a bit more. Um if your design system is is not well if it's published to npm, so I guess it can be private, but like I'm thinking more also it's a public design system, um like Solaris, say Polaris, I should say. Um You might- we actually give the author of the design system a way of embedding in their package.json the URL of a published Storybook.
[00:32:24] Michael Chan: Awesome.
[00:32:24] Tom Coleman: And so the composition just happens automatically for the user. The user doesn't have to do anything. Um, they don't have to like go, oh, here it is, and like write some configuration code in their in their Storybook setup. Instead, by installing the package, it just automatically shows up in the sidebar. Of course, they can get rid of it if they want, but it and it also shows up like the exact version that they're using. So say I'm using version 2.1.3, I'll see the published Storybook for version 2.1.3. So I'll know that I'm looking at the exact um APIs that I'm using. Also, we give like a little version chooser so they can like choose a different version. So if they want to see like, oh, what's the latest version of this? Did they fix this? Have they added a prop for that yet? Um they can really you can really easily switch between them. So that's a that's a pretty awesome little feature, I think. It's not it hasn't really like happened yet because it's kind of chicken and egg. We need to publish 6.0 and get users that are using it before all the design systems are gonna start using it. But we're kind of confident that like everyone's gonna add this field to their package.json. It's gonna be really cool.
[00:33:29] Michael Chan: I love this notion because it's it's it's so, as you mentioned in in describing that, Companies get complicated, right? And as your company grows, the the things that you need to use your design system for, they become themselves more composable, right? You know, maybe you you have some, you know, off the shelf, you're like, you know what, we're gonna make design systems somebody else's problem. You have somebody, you use some off the shelf one. Well, now you can incorporate that documentation with your documentation, with the specific compositions of those things that actually make your app like your app, right? You know, so you could have a story for a flight or like hotel booker widget. And now it's like right next to, you know, avatars from Solaris or Polaris. No, I said it wrong.
[00:34:20] Tom Coleman: I've infected you.
[00:34:21] Michael Chan: And that seems that seems really amazing, especially when you think about those like cross-disciplines between teams. Like you said, you might have marketing, you might have a team that works on a product that looks distinctly, you know, maybe a public product, you know, like we have this, we have a public product that looks distinctly different from all of our backend products, like totally different design language. And to have multiple systems represented in the same place and kind of like showing their interdependency,
[00:34:48] Tom Coleman: yeah,
[00:34:49] Michael Chan: um, just seems super cool to me.
[00:34:51] Tom Coleman: Yeah. And I mean, it's also another one of those things where I think it, it augments really well with the commercial side where you know, we have a tool that tells you, you know, this is the paid tool Chromatic that tells you when something changes, um, visually, uh, when you make a code change, you know, when when we know about these relationships between different business units, potentially we can start telling you, hey, if you change this component here, over here in this other Storybook, like this other team is gonna be affected by that. So, you know, you might want to ask them if it's okay.
[00:35:22] Michael Chan: Oh, interesting.
[00:35:24] Tom Coleman: Or you might want to tell them about it. Um, um, and I think that's kind of, from a from a business side of things, I suspect that's gonna be really powerful for companies, um, to kind of unlock that kind of problem of silos and big teams and everything else. Um, yeah. So yeah, it's it's pretty interesting.
[00:35:41] Michael Chan: Would that also help you with, you know, let's say you're using some off-the-shelf design system that uses Storybook, um, in kind of identifying, you know, changes that happen over like major versions to those lower level components that you might be using.
[00:35:56] Tom Coleman: Yeah, yeah, I think we can we can do lots of stuff like that. Like compare comparing visually between different versions is kind of what we do as a company. So there's a lot of a lot of potential in that. And I think uh yeah, it's so it's so it was just scratching the surface really um at the moment. It's it's a lot deeper we can go. So it's gonna be awesome.
[00:36:15] Michael Chan: Yeah, I'm super I'm super excited about- sorry, go ahead.
[00:36:17] Tom Coleman: Oh, I was just gonna say like one final feature of composition that I didn't mention yet, and it's kind of um something we're we're looking to double down on in in upcoming versions is is it does kind of unlock that that problem that you mentioned earlier where you have um your your product or or maybe your company across different stacks. So you you mentioned the um I've got Rails over here and I've got um React over here. Um composition, so firstly, there's Storybook supporting server-rendered frameworks gives you the ability to even put React into Storybook. Composition gives you the ability to put those two Storybooks together.
[00:36:52] Michael Chan: Mm-hm.
[00:36:52] Tom Coleman: And and and really common use case, especially at bigger companies, is you know we've got like some of our library written in React and some of it in Vue or some of it in Angular, or we're migrating right now from Vue to Angular, or we're migrating from React to Vue, you know, and and uh Composition gives these teams the ability to put them all in one place, which I think can be like really game-changing for some teams. So I'm excited about that too. It's that side of things is is is got a little more to go, but this this feature is is adding that ability. So it's gonna be great, I think.
[00:37:24] Michael Chan: Yeah. And you know, you bring up a really interesting point and I feel this sometimes is that, you know, that chromatic relationship and the, you know, Storybook and chromatic and the way you write stories and kind of get that testing as part, the the visual testing, um, it makes these stories like a really powerful migration tool. Exactly. You know, so if you are migrating from, you know, React to Vue or vice versa, or from the server to to frontend, as as you'd mentioned, um you can keep, you know, you keep all these tests intact, you know, kind of regardless of the implementation.
[00:37:57] Tom Coleman: Exactly.
[00:37:58] Michael Chan: And I I really love that.
[00:38:00] Tom Coleman: Yeah.
[00:38:00] Michael Chan: Really love it.
[00:38:01] Tom Coleman: I agree. Yeah, I think it's I think it's really super super powerful. The ability and the ability to put them side by side, you know, like, oh, let's let's make this this exact story for this exact component. In both Rails and in React and make sure it looks the same. I mean, that's- yeah, it behaves the same. Yeah.
[00:38:18] Michael Chan: And, you know, it's, it's funny because, like, you know, we, we talk about testing at the right level, you know, so often, and it feels like for these, you know, for, as you've mentioned, component-driven, um, systems and applications, this does feel like the right level to test them kind of at the visual, um, level. Um, And it makes for a lot fewer false positives of your tests breaking.
[00:38:43] Tom Coleman: Yeah.
[00:38:43] Michael Chan: Which is great.
[00:38:45] Tom Coleman: Yeah. Um,
[00:38:46] Michael Chan: no,
[00:38:46] Tom Coleman: we could go into that in detail, but that's that's probably another chat. Yeah.
[00:38:51] Michael Chan: Oh yeah, yeah. Um, now I know the the final feature is one that you touched on, and I feel like maybe we have enough context now to kind of understand a little bit better, but but args, and this really feels like that like really big thing that's changing. And um, I I know you'd mentioned some of the the applications of this, but I want to talk about the specific of like what that actually looks like in a story.
[00:39:13] Tom Coleman: Sure, sure.
[00:39:14] Michael Chan: And and what this unlocks for for people who have been using Storybook for a while.
[00:39:19] Tom Coleman: Yeah, um, yeah, it's a great question. Um, I think it's probably easiest just to talk in terms of React. Um, so apologies for for people that um aren't familiar with it. Um, so-
[00:39:31] Michael Chan: It's a React podcast.
[00:39:33] Tom Coleman: Oh, oh, of course. Sorry.
[00:39:36] Michael Chan: So we can we can assume, and you know, if we got some Vue people, welcome. Oh, great.
[00:39:42] Tom Coleman: Well, now I don't feel bad at all. Yeah, so, um, so, so yeah, a story, um, in traditionally in Storybook is a function that returns like a React element. So it's basically, hey, I'm gonna call this function, and when I've called it, you give me something renderable to the screen. Um, and so typically you'd write a story, you know, you'd return JSX, um, it would be like a component and a set of props, and it's all like encoded in the JSX. And and that that's great. I mean, that's awesome. What that doesn't tell the system though is really what the- there's two problems with that. Like the first problem is there's no way to look at that function and know what those props are. You have to execute the function, which is kind of weird. Um and secondly, there's no way for the system to change those props. Okay. Um so what we wanted to do Um, is really what we realized really is the story is actually it's actually not really a function that returns something renderable. When you when you take it one level back, it's actually a component and a set of props. That's what it is, a component and a set of inputs. And um, and um, and and that's kind of what a React element is. But um, anyway, without getting into that, What we realized is if we can separate the two things, then it's really powerful. And so the new way you write a story, and the old way is completely still supported, there's no like um there's no breaking change here, it's just some of these new features necessarily require you to write stories in a slightly different way. Um the new way to write a story is to make it a function that takes args, so inputs, and return something renderable. And usually that just means literally just taking those args and giving them directly to the component, like spreading them into some JSX. And so the the function for a story becomes actually quite uninteresting. Um and it's it's that set of args that is the interesting thing. So you write the story function and then you write the args. And the the args for a specific story become like the starting point. So it's like, this is what will first render when we visit the story. But the system can change it. And and that gives you like two immediate, like really powerful features straight out of the bat, straight off the bat. So one is um we can look at those args and we can start um like figuring stuff out about them. And and that's great for the documentation side of things. So we already have, um you know, in in Storybook docs, we already have a bunch of tooling that like will look at your prop types. We'll maybe look at your TypeScript types. There's a few other things for different frameworks that we do to generate like a big table of of like these are the props of your component. And and by using args, you can kind of control that a little more if you want. So you can, if you want to override what we've detected, or if you want to um add add new ones that aren't actually on the component, um because your story is a bit more complicated. Um so there's a bunch of stuff you can do. Um, there. And then the second thing we can do is then we can add a new column to that table, which is the control. So it's like, hey, this is the current value, but do you want to change it? Go ahead. Um, and and what that does technically is it just changes that stored value of the args and then reruns the function with the new value. And so it's kind of, yeah, it's built into the system. It's kind of at at the lower level lowest level. Um, args is kind of all through the system. And it just gives that ability um to sort of understand the inputs of a component and to change them to lots of different add-ons and stuff. So one um add-on that people are probably aware of if they're Storybook users is the Actions add-on. And the way previously um you used an action the Actions add-on is in your story, you like imported a function and then you called that function and passed it as a prop to your Um, story to your component. So you'd be like, onClick equals action foo, and that would do something when the onClick handler got called, something special would happen that was handled by Storybook. And the end result of that was that you would see in the Storybook's UI a little um a log message, essentially, like the onClick happened. So that's cool. But what uh args lets us do is now that we can do some like inference about, we know something about um the props of your component and we can control them. Now we can be like, oh hey, this prop's called onClick. That's probably a callback. So let me automatically pass you one of these things so you don't actually have to write any code for it.
[00:44:26] Michael Chan: Oh wow.
[00:44:27] Tom Coleman: And it will just automatically pump that special callback that does all the Storybook stuff to get it to log on the screen just automatically. And so you don't need to define that arg. For your story, you just leave it off. And then somewhere in your configuration you say any- so the way it works, like, is pretty simple. You just somewhere in your configuration you say any, any arg that starts with on is a callback, make it an action. Um, that's kind of like the simplest configuration for it. Or you can manually say this one should be an action. Um, yeah, and that's the kind of thing we can do. So that's kind of like some ideas that we, we had straight away, but I'm pretty sure the community is gonna have like some really interesting other ideas. Storybook's kind of known for its add-on community. We've got like a lot of add-ons, and that's something we actually want to emphasize like even more in the future. But, um, yeah, so it's gonna be really, really interesting to see how how that like our concept like plays out. I I I'm, as I mentioned earlier, really excited. I think there's a lot of different directions where it could be really cool.
[00:45:28] Michael Chan: Yeah. Now, as you've been talking about this feature, you've mentioned two add-ons, the the the Knobs add-on and then also the um what was the Actions add-on. And it sounds like In a way, args is kind of first-classing those add-ons.
[00:45:43] Tom Coleman: Yeah, or at least the mechanism-
[00:45:44] Michael Chan: Sweet.
[00:45:45] Tom Coleman: The mechanism by which they work, right? Yeah. Actually, as part of 6.0, we've got like a set of add-ons that we're calling the essential add-ons.
[00:45:53] Michael Chan: Oh, cool.
[00:45:53] Tom Coleman: Um, yeah, so the add-on essentials, and that's gonna be installed by default from now on when you boot up a new Storybook. And that's that includes uh uh that includes actions, that includes docs. That includes viewports, that includes this controls add-on, which is the the args one, and it includes backgrounds. So basically, yeah.
[00:46:15] Michael Chan: Awesome. All extremely helpful add-ons.
[00:46:17] Tom Coleman: Yeah, exactly. It's just kind of like the Storybook came a little like stripped down by default and you kind of had to be in the know to know that there was like add-ons that everyone added. So we figured we may as well take some responsibility for them and and install them by default. So that's what we did.
[00:46:31] Michael Chan: It's a hard balance, right? Because you know, you wanna you wanna be courteous of, you know, um, you know, download size and bloat and like how much someone has to know to be able to be effective, you know, because someone could be perfectly effective. All they need is the base one and, you know, uninstalling or kind of ignoring is maybe cumbersome to them. So I do feel like you all have have struck a good balance historically on where that line is.
[00:46:56] Tom Coleman: Yeah. Well, let's hope this this change fits that. I hope so. Certainly the ability to use these add-ons with like zero or less work should help with that too. So, you know, like Viewports and Background, you can use straight away. You don't need to configure them at all. Controls, if you write stories in the way we tell you to, then you'll be able to use that too without doing anything. So I think it should be it should be good for new users too. I'm really hopeful about that.
[00:47:22] Michael Chan: Awesome.
[00:47:23] Tom Coleman: Yeah.
[00:47:23] Michael Chan: Well, hey, we're kind of uh nearing the end of our time. Sure. But I just- I know, it went fast. Um, but I just wanted to ask you, um, you know, I like to close out each episode just finding out what you, um, as a, you know, an open source, you know, creator, uh, maintainer, visionary, product person, like,
[00:47:43] Tom Coleman: yeah,
[00:47:43] Michael Chan: what is it that you're super excited about, you know, over the next, like, you know, 2 or 3 years that you think is just gonna change, um, you know, just change the way we work?
[00:47:51] Tom Coleman: Uh, yeah, you know, I've spoken about it a bit before in this conversation, but it's It's something I'm really big on, which is this kind of component-driven way of working. And I know that like probably a lot of people, if they're React users, are probably true believers already to some degree. But I think I think maybe in the development community we we we're doing it a bit, maybe not as much as we could, but I think across what I'm really talking about is doing it across the entire company, you know, or at least the product side of the company. What I really what I'm really excited about is the idea of, you know, designers, developers, the product people, testers, everyone thinking in terms of the same kind of primitives of these components. And so, and even like the kind of work process sort of being componentized. So it's like, oh, okay, we need to like build this component rather than this like entire feature or this entire screen. Um, I just think there's like a lot of gains to be had there, and we really haven't seen those gains play out. It's kind of like a process thing almost, so maybe in in a sense it's a bit boring, but like for me it's exciting because you know I've been I've been building tools for a long time now and and and uh it's really the one way of working that like really works for me and and seems to be like the the most scalable and the most sort of um repeatable and and predictable. So yeah, it's it's sort of just just the idea of like starting with components, from the design onwards, communicating between teams, between disciplines in terms of components, um and and really like having the tooling, you know, and Storybook is obviously leading that, um that supports that. And you know, having the tooling right across the stack from designs design tool to to um development tool to to to testing tool to communication tool that is all oriented around Those components. And that's that's kind of what gets gets us up in the morning at Chromatic. And we think it's gonna make a really, really big difference. Because in in UI development, um, you know, that that that little piece of of work that's called a component is— we've got a unique power in that it's meaningful to everyone. You know, if you're a if you're a backend developer and and you're working on APIs, like that little slice of the API that might be like a module or something it's probably not gonna like really interest um your manager, you know. True. Whereas if it's like if it's like a a dropdown and I can open it up and play with it and click on it and and and feel it and and see how it works and and just look at it, it's that's actually like a really big advantage that we have as UI developers is that like our work is so much easier to understand in in small chunks and it enables a lot of things and and one of those things is like a better process. So, that's that's what we're really excited about.
[00:50:42] Michael Chan: I love that. And I I'm really I have to say, I'm so excited about the work that you, Chromatic, you know, Storybook, you know, all of that is happening together. I think that you're really leading the leading the way on this. And it's exciting to see your vision for this come to to life in these products. Um, because they really are so good and um. I don't know. I'm I'm just kind of like a huge shill for uh Chromatic right now. I just love everything you're doing. Thank you.
[00:51:12] Tom Coleman: Yeah, well, look, there's a lot more to come. It's like we're a small company, like early stages. There's you know, we've got a lot more written down on the old whiteboard. Tell you tell you what.
[00:51:22] Michael Chan: Yeah, yeah. Well, hey, um, if people want to kind of either get involved or just follow along with what you're doing in Storybook, um, tell me how they can uh get involved and uh and find you.
[00:51:34] Tom Coleman: Yeah, that's a really good question. We have like a Discord for Storybook, um, which is sort of the place where people like chat. So if you want to just jump on the Discord, that's that's great. I mean, as as an open source project, you know, it's always like, can always go into the GitHub issues and see the ones that are marked, you know, um, as as first issue and and and and help out that way. Or just reporting issues is is always good. Um. Otherwise, we have a Storybook blog, we have a Storybook Twitter account that we will kind of do product announcements on if you want to just keep track of that. We're actually building a release notes feature into 6.0, so-
[00:52:10] Michael Chan: Oh, cool.
[00:52:10] Tom Coleman: Kind of get that automatically if you keep up to date. So that's another option. But yeah, probably the Discord is a great way to- great place to start. Just, yeah, come along.
[00:52:21] Michael Chan: And how do people find you as you continue to build and share the things you're excited about?
[00:52:26] Tom Coleman: Oh yeah, if you want to follow me personally, my, my handle online is @tmeazday. Uh, Meazday is my middle name. That's, uh, so there's no real, like, complicated thing there. So, uh, I'm on Twitter, /tmeazday, um, or GitHub likewise. Yeah.
[00:52:41] Michael Chan: I love it. Well, hey, thanks so much for being on the show today. I really appreciate all your insights and your excitement about all the stuff that's gonna be coming up in Storybook 6. I, like, personally, and then also for the listeners,
[00:52:55] Tom Coleman: Yeah, that's great. Me too.
[00:52:58] Michael Chan: This has been episode 105 of React Podcast with Tom Coleman and Chantastic. For links, visit reactpodcast.com/105. And as I mentioned at the top of the episode, if you'd like to hear more about Chromatic, listen to episode 91 with Dominic Nguyen. Thanks again to our sponsor, Infinite Red. If you have a project that's gone off the rails and needs expert help, get Infinite Red on your side. They've been designing, building, and shipping apps for 10 years and want to bring their expertise to your apps, products, and services. They have a deal right now where you get $750 for referring a new project. Get expert help from Infinite Red at reactpodcast.infinite.red. If you like this show, there's a fast, free way to demonstrate your support. Leave us a review on iTunes. It's the best way for you to let me know what you think we're doing right and what we can improve. 2 to 3 minutes of your time helps us make the best show we possibly can. As always, links and show notes for all episodes are available at reactpodcast.com. This episode was edited by Mikael Delport. It was produced by Mikael Delport and Sarah Jackson at Spec, a network to help you level up in design and development. Check out spec.fm for other shows that are sure to fast-track your career. I'm your friend, Chantastic. Thanks for listening. We'll be in your ears again next week.
chantastic.fm