prismicio / slice-machine

A series of tools for developing and deploying website sections with Prismic
https://prismic.io/docs
Apache License 2.0
287 stars 53 forks source link

RFC: Add Storybook integration #13

Closed hypervillain closed 3 years ago

hypervillain commented 4 years ago

Setup a Storybook project

Run prismic sm --add-storybook --framework [nuxt/next] to setup a Storybook, configured to preview your local slices. It should install dependencies and add scripts to your package.json.

Create a slice with its model and stories

Run prismic sm --create-slice --framework [nuxt/next] to create a slice folder. If no option is provided, the command would look for a template here. It should create:

The template builder makes use of cpy-template-dir and passes componentName as var.

Custom slice template

Pass the argument --template-path relative-path-to-template to provide your own template folder. You would need to at least create a valid model.json file, for the operation to succeed. If you don't want to pass a path each time you create a slice, the CLI will look for a folder named slice-template at the root of your project and use it if it's found.

Preview of the command here: https://imgur.com/a/XTa04d6

lihbr commented 4 years ago

Looks awesome!

Can't we store the framework after initial setup in sm.json? Looks annoying to use the framework flag every time you want to use the CLI...

hypervillain commented 4 years ago

Annoying indeed! We have an ongoing conversation regarding the flag on Slack, let me ping you there

hypervillain commented 4 years ago

You can store the framework in the sm.json file. You would have to specify it when setting up the project:

prismic sm --setup --framework next

why not. I proposed to parse the package file and look for framework related dependencies (next, nuxt, gatsby..)

Duaner commented 4 years ago

@lihbr this is solved by this now https://github.com/prismicio/slice-machine/issues/14