parachutehome / create-title.macro

Automatically create storybook titles using a babel macro
https://parachutehome.github.io/create-title.macro
ISC License
3 stars 0 forks source link
auto-create-title babel-macro babel-plugin-macros create-title storybook storybook-macro

create-title.macro

npm (scoped) status status

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.

Getting Started

Install

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"]
}

Example Usage

// src/components/Button/index.stories.js

import createTitle from '@parachutehome/create-title.macro';

export default {
  title: createTitle(); // output: components/Button
  // ...
}

Documentation

You can view the full documentation for this babel macro online here.

Contributing

If you would like to help contribute features or bug fixes to this macro, then please read the contributing guide here.

Previous Art

The paths.macro, created by Storybook, served as inspiration, and a great jumping off point. Big thanks for their work!