<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marino Linderhof on Medium]]></title>
        <description><![CDATA[Stories by Marino Linderhof on Medium]]></description>
        <link>https://medium.com/@marino.linderhof?source=rss-9525be22af0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mp6r5KxOnFUAb9io.</url>
            <title>Stories by Marino Linderhof on Medium</title>
            <link>https://medium.com/@marino.linderhof?source=rss-9525be22af0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 18:49:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marino.linderhof/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Ghostwriter for Storybook]]></title>
            <link>https://medium.com/mollie-payments/ghostwriter-for-storybook-8c71b04b62c9?source=rss-9525be22af0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c71b04b62c9</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[storybook]]></category>
            <category><![CDATA[ghostwriter]]></category>
            <dc:creator><![CDATA[Marino Linderhof]]></dc:creator>
            <pubDate>Thu, 13 Dec 2018 14:47:55 GMT</pubDate>
            <atom:updated>2018-12-13T16:45:38.805Z</atom:updated>
            <content:encoded><![CDATA[<h4>Automating story creation in Storybook for React.</h4><p><strong>Recently we released Ghostwriter. A flexible and charismatic </strong><a href="/service/ttps://storybook.js.org/"><strong>Storybook</strong></a><strong> add-on that makes story writing fast, smooth and effortless. Try it out here: </strong><a href="https://github.com/mollie/storybook-addon-ghostwriter"><strong>Ghostwriter</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrrYNkTSmrM24J9xYpuMmw.jpeg" /><figcaption>Illustration by <a href="https://svenfranzen.com/">Sven Franzen</a>.</figcaption></figure><h3>A UX story design system for scale-ups</h3><p>As a fast-growing company our roadmap projects are increasing in size as well. We have entered a new, highly challenging scale-up territory. To keep up with the pace, we noticed that we need a better process to share, test and see React components in action. We thus decided to improve our component design process for:</p><ol><li>Coders — allowing them to test and share code between colleagues.</li><li>Designers and UX/UI enthusiasts — to share different style guides between the departments. More specifically, to be able to share department-specific components.</li><li>Marketing and Product Owners — a group that isn&#39;t as directly involved, but we believe that a good process can help create common ground and provide venues for shared language.</li></ol><p>As a result, we started using <a href="https://storybook.js.org/">Storybook</a> to provide a more visual style guide sharing process. Storybook has its main focus on the technical aspects of components, which is a great thing for technically-minded coders. However, we noticed Storybook is far from perfect even for the most tech-savvy. Its main flaw is that for each property variation you have to write another story, which makes Storybook a tool that easily becomes time consuming.</p><p>Thus we created a Storybook add-on to smoothen the process: Ghostwriter.</p><p>Let&#39;s explain what the tool does by providing an example. Say we want to make a story of a component with 4 properties — let’s say all boolean — you end up with code like this:</p><pre>storiesOf(&quot;component&quot;, module)<br>  .add(&quot;variant1&quot;, () =&gt; (<br>    &lt;FourProps <br>      prop1={true} <br>      prop2={false}<br>      prop3={false} <br>      prop4={false}<br>    /&gt;<br>  ))<br>  .add(&quot;variant2&quot;, () =&gt; (    <br>    &lt;FourProps <br>      prop1={false} <br>      prop2={true}<br>      prop3={false} <br>      prop4={false}<br>    /&gt;<br>  ))<br>  .add(&quot;variant3&quot;, () =&gt; (<br>    &lt;FourProps <br>      prop1={false} <br>      prop2={false}<br>      prop3={true} <br>      prop4={false}<br>    /&gt;<br>  ))<br>  <br>  // ETC.<br>  // To show all the possible variants you need 16 variants</pre><pre>  .add(&quot;variant16&quot;, () =&gt; (<br>    &lt;FourProps <br>      prop1={true} <br>      prop2={true}<br>      prop3={true} <br>      prop4={true}<br>    /&gt;<br>  ));</pre><p>This is a lot of work, and such work is repetitive and non-productive. How would you figure out which story to select: variant 2 or 14? Of course, you can give them descriptive names, but selecting the right story does not become any easier.</p><p>But what about leaving some of the props out? Not every prop needs to be shown, and some of the combinations will never occur. This is a valid point, but that would mean you would have to write the stories with premeditated intentions. That could open the gates for untested components. What if prop2 and prop4 are both true and thus will result in an error?</p><p>This example only shows us the problem we encounter with four booleans as props. What if we use strings or numbers? What happens with your component when you entered longer strings or larger numbers? Surely, if there is business logic in your component you have to write tests, but thoroughly testing how it looks becomes a separate problem.</p><p>Luckily, Storybook has a fantastic add-on called <a href="https://github.com/storybooks/storybook/tree/release/3.4/addons/knobs">knobs</a>. This is very close to what we, as a company, need: it makes dynamic props by turning props into knobs. What is more, it decreases the variants, and you can change the input via the knobs in the side panel.</p><p>This is a knob example:</p><pre>// Knobs as dynamic variables.<br>stories.add(&quot;as dynamic variables&quot;, () =&gt; {<br>  const options = [&quot;light&quot;, &quot;dark&quot;, &quot;sky&quot;, &quot;bright&quot;];</pre><pre>  // Notice we changed the props a bit<br>  const prop1 = boolean(&quot;boolean&quot;, true);<br>  const prop2 = number(&quot;number&quot;, 7);<br>  const prop3 = text(&quot;string&quot;, &quot;Default string&quot;);<br>  const prop4 = select(&quot;dropdown&quot;, options, &quot;dark&quot;);</pre><pre>  return (<br>    &lt;FourProps <br>      prop1={prop1} <br>      prop2={prop2} <br>      prop3={prop3} <br>      prop4={prop4} <br>    /&gt;<br>  );<br>});</pre><p>This is great, but still time consuming, because now you have to make a knob for each prop. When you think about it, you already did describe your props in the form of prop-types, flow or typescript. That sounds like twice the work, right? Let&#39;s optimise it!</p><p>If we want to extract the prop info, we can do that by using react-docgen. To use it with Storybook, we use a babel plugin called <a href="https://github.com/storybooks/babel-plugin-react-docgen">babel-plugin-react-docgen</a>, if you use typescript <a href="https://github.com/strothj/react-docgen-typescript-loader">react-docgen-typescript-loader</a>. Basically, this adds an extra property to our component with all the props it can find.</p><p>To show all these extracted properties on your page you can use a module called <a href="https://github.com/storybooks/storybook/tree/release/3.4/addons/info">info</a>.</p><h3>So what does Ghostwriter do?</h3><p><strong>All of the above… and more.</strong> The main objective of Ghostwriter was to decrease the time needed to write your stories. A bonus: it also makes your story look smooth and clean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*UxyuLsJbZNQQHSWNW_JrcQ.gif" /><figcaption>A preview of the Ghostwriter add-on for Storybook.</figcaption></figure><p>To write the story described earlier with our FourProps component, all the code you need for the knobs and additional info — as described above — is this:</p><pre>storiesOf(&quot;components&quot;, module)<br>  .addDecorator(ghostwriter({ component: FourProps }))<br>  .add(&quot;FourProps&quot;, () =&gt; {});</pre><p>But Ghostwriter can do more. We use reactIntl quite a lot, and whenever we use a higher-order component (HOC) like injectIntl() the component went a bit woogie. You would get something like this:</p><pre>&lt;injectIntl(FourProps) /&gt;</pre><p>This is because the HOC will add a wrapper with another displayName. In our case injectIntl(FourProps), that was annoying and not what we intended to achieve. But now Ghostwriter can deal with that for you.</p><p>Another cool thing about Ghostwriter is that it provides space for your creative partners. We call it context. Sometimes you just want to add some default examples, or use multiple components. Think about &lt;Menu/&gt; and &lt;MenuItems/&gt;. Ghostwriter will describe each of the components separately, but in context you maybe want to show them together, like this:</p><pre>const context = (<br>  &lt;Menu&gt;<br>    &lt;MenuItem&gt;menu item one&lt;/MenuItem&gt;<br>    &lt;MenuItem&gt;menu item two&lt;/MenuItem&gt;<br>    &lt;MenuItem&gt;menu item three&lt;/MenuItem&gt;<br>  &lt;/Menu&gt;<br>);</pre><pre>storiesOf(&quot;components&quot;, module)<br>  .addDecorator(ghostwriter({ component: Menu }))<br>  .add(&quot;FourProps&quot;, () =&gt; context);</pre><pre>storiesOf(&quot;components&quot;, module)<br>  .addDecorator(ghostwriter({ component: MenuItem }))<br>  .add(&quot;FourProps&quot;, () =&gt; context);</pre><h3>Bonus things Ghostwriter can do</h3><ol><li>Add Markdown to the description (<a href="https://github.com/mollie/storybook-addon-ghostwriter#writing-stories">see options</a>).</li><li>Overwrite props with other values <strong>or</strong> your own knobs.</li><li>Add additional content to the info tab. This could be useful whenever a component needs an action from outside the prop scope. For example, a Modal that waits for a ref to be called. &lt;button onClick={()=&gt; this.modalRef.open}&gt;Open&lt;/button&gt;. Then additionalContext is the perfect place.</li><li>Write your stories even faster by using the <a href="https://github.com/mollie/storybook-addon-ghostwriter#snippet-for-vscode-atom-and-sublime-text">snippet</a>.</li></ol><h3>Future of Ghostwriter</h3><p>This is only the beginning. We want to further improve the current version and help other companies going through a scale-up phase. Do you have ideas or do you want to help? Please open an issue or make a PR at the <a href="https://github.com/mollie/storybook-addon-ghostwriter">Ghostwriter GitHub</a>.</p><h3>Final note</h3><p>Do you use Storybook to document your component library? Go check out Ghostwriter and spend less time on managing your component library and more time on building new UI components.</p><p>I hope you enjoyed this write-up. Let me know what you think!</p><p><em>Download </em><a href="https://github.com/mollie/storybook-addon-ghostwriter"><em>our Storybook add-on Ghostwriter</em></a><em>.<br>Follow me on </em><a href="https://twitter.com/TweetMimo"><em>Twitter</em></a><em>.<br>Read our other articles </em><a href="https://blog.mollie.com/"><em>here</em></a><em>.<br>Sign up at our </em><a href="https://www.mollie.com/"><em>website</em></a><em>, or find us on </em><a href="https://twitter.com/MolliePayments"><em>Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c71b04b62c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mollie-payments/ghostwriter-for-storybook-8c71b04b62c9">Ghostwriter for Storybook</a> was originally published in <a href="https://medium.com/mollie-payments">Mollie</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>