Generates a component directory for use with Storybook + Twig/Drupal
Requires Yeoman
npm install -g yo
npm i -g @bryanbuchs/generator-component
Or, to simplify the yo
command to component
:
npm i -g generator-component@npm:@bryanbuchs/generator-component
Run the generator from the theme directory, files will be scaffolded into components/{component-name}
:
-
yo component
and follow the prompts. -
yo component componentname
to prefill the name prompt -
yo component groupname-componentname
to prefill the name and group prompts -
yo component --js
to prefill "y" in the "Include *.behavior.js file?"
Running the generator will create a directory with a series of boilerplate files:
components/{component-name}/{component-name}.less
components/{component-name}/{component-name}.library.js
components/{component-name}/{component-name}.stories.js
components/{component-name}/{component-name}.twig
-
components/{component-name}/{component-name}.behavior.js
(if specified) components/{component-name}/{component-name}.yml