Automatically generate titles for your stories in Storybook.
This babel macro was created to streamline the developer experience when working with stories inside Storybook. The macro will automatically generate a title for your stories -- eliminating the need to write them out which can be a time saver especially when a story is nested deep inside multiple folders.
npm i --save-dev @parachutehome/create-title.macro
If you haven't set up your project yet to support babel macros then read the guide here.
tl;dr
npm i --save-dev @parachutehome/create-title.macro babel-plugin-macros
Then in your .babelrc
:
{
"plugins": ["macros"]
}
// src/components/Button/index.stories.js
import createTitle from '@parachutehome/create-title.macro';
export default {
title: createTitle(); // output: components/Button
// ...
}
You can view the full documentation for this babel macro online here.
If you would like to help contribute features or bug fixes to this macro, then please read the contributing guide here.
The paths.macro, created by Storybook, served as inspiration, and a great jumping off point. Big thanks for their work!