Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presets documentation #5333

Merged
merged 5 commits into from
May 22, 2019
Merged

Presets documentation #5333

merged 5 commits into from
May 22, 2019

Conversation

shilman
Copy link
Member

@shilman shilman commented Jan 22, 2019

Issue: #5301

What I did

First draft of presets documentation. I think we either need to release some presets before releasing this documentation, or we need to scale things back until we're ready to start releasing some presets.

How to test

N/A

docs/src/pages/presets/introduction/index.md Outdated Show resolved Hide resolved
docs/src/pages/presets/introduction/index.md Outdated Show resolved Hide resolved
docs/src/pages/presets/writing-presets/index.md Outdated Show resolved Hide resolved
docs/src/pages/presets/writing-presets/index.md Outdated Show resolved Hide resolved
@tmeasday
Copy link
Member

Seems great

@codecov
Copy link

codecov bot commented Jan 22, 2019

Codecov Report

Merging #5333 into next will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             next    #5333   +/-   ##
=======================================
  Coverage   30.08%   30.08%           
=======================================
  Files         619      619           
  Lines        9001     9001           
  Branches     1230     1248   +18     
=======================================
  Hits         2708     2708           
  Misses       5628     5628           
  Partials      665      665
Impacted Files Coverage Δ
app/react/src/server/framework-preset-cra.js 0% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be81b1a...27f9561. Read the comment docs.

tmeasday pushed a commit that referenced this pull request Jan 24, 2019
It would be better to use the preset here. cc @shilman / #5333
@ndelangen
Copy link
Member

@shilman What's happening, are we merging this?

Copy link
Member

@igor-dv igor-dv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very good start =)
I am missing a few words about loading presets, for example that users can pass parameters when configuring them

docs/src/pages/presets/writing-presets/index.md Outdated Show resolved Hide resolved
docs/src/pages/presets/writing-presets/index.md Outdated Show resolved Hide resolved
@ndelangen ndelangen added this to the 5.1.0 milestone Apr 26, 2019
@shilman shilman mentioned this pull request May 19, 2019
Co-Authored-By: Joey Cozza <joeycozza@gmail.com>

## Presets API

A preset is a set of hooks that is called by Storybook on initialization and can override configurations for `babel`, `webpack`, `addons`, and `entries`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any thought or plans for allowing presets to handle addDecorator or addParameters calls? My use case is a company with many separate apps, but all fall under the same stack, and my team is in charge of the stack. We'd really like to be able to have a single preset/config that all of our different teams can use (for consistency's sake), and then when we make updates (like when storybook-docs drops) we can update the preset/config in 1 spot, and everyone gets the wonderful changes.

I've tried putting most of my shared configuration into a file and importing it into the .storybook/config.js file, but it appears like it isn't "run" for storybook. Even passing the addDecorator function from .storybook/config.js into the shared configuration file and calling it in there didn't work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should file that as an issue. I'd expect it to work in Storybook. I also think that could be a cool feature to add to presets.


```js
export function addons(entry = []) {
return [...entry, require.resolve('@storybook/addon-storysource/register')];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am using the knobs addon here in the exported addons function of the preset I am making, do I still need to use the addDecorator(withKnobs) in my config.js file? The docs are a little unclear about that in my opinion.

To add onto that thought, should a preset that utilizes the knob addon expose the things the knob addon does? (like boolean, text, etc?) Otherwise the consumer of said preset will also need to install @storybook/addon-knobs to get access to them. (is that what is envisioned)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the addons should export their own presets. That's what I'm doing with addon-docs. So you install the addon and then use its preset. Have not discussed this with @igor-dv regarding storysource.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I'll make an issue and ask igor about what the expected usage/how to do preset of presets.

@joeycozza
Copy link
Contributor

Are the packages in https://github.com/storybooks/presets just on the back-burner while more important things are worked on (like storybook-docs?) Are there things that need to occur before those few presets that exist get published to npm? I may be able to spend some time on the presets if that work would be appreciated (and if some guidance could be given for the vision there)

@shilman
Copy link
Member Author

shilman commented May 22, 2019

@joeycozza Yeah the presets are gathering dust. However, I just updated the Typescript preset and published it. 🎉

https://www.npmjs.com/package/@storybook/preset-typescript

@shilman shilman merged commit 06cc484 into next May 22, 2019
@shilman shilman deleted the shilman/presets-docs branch May 22, 2019 14:48
@shilman shilman added the patch:yes Bugfix & documentation PR that need to be picked to main branch label May 30, 2019
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label Jun 6, 2019
@rwieruch
Copy link
Contributor

rwieruch commented Jul 3, 2019

Will .storybook/presets.js replace .storybook/addons.js in the long run?

If yes, it should be possible to convert

import '@storybook/addon-options/register';
import '@storybook/addon-knobs/register';
import '@storybook/addon-a11y/register';
import '@storybook/addon-storysource/register';

to

module.exports = [
  '@storybook/addon-options/preset',
  '@storybook/addon-knobs/preset',
  '@storybook/addon-a11y/preset,
  '@storybook/addon-storysource/preset',
];

in the future, correct?

@shilman
Copy link
Member Author

shilman commented Jul 3, 2019

@rwieruch In principle you're correct. In actuality, @ndelangen is working on #4169 which will simplify presets, collapse everything into a single file, and have various performance benefits as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch presets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants