Skip to content

Commit

Permalink
Merge pull request #14794 from storybookjs/docs/npx-sb-init
Browse files Browse the repository at this point in the history
Prefer `npx sb init` installation
  • Loading branch information
shilman authored May 4, 2021
2 parents 6daa34d + cff4653 commit 60c864b
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 64 deletions.
16 changes: 0 additions & 16 deletions .bettercodehub.yml

This file was deleted.

2 changes: 1 addition & 1 deletion app/angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-angular-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
2 changes: 1 addition & 1 deletion app/aurelia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-aurelia-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
6 changes: 4 additions & 2 deletions app/ember/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-ember-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand All @@ -29,13 +29,15 @@ You can also build a [static version](https://storybook.js.org/docs/ember/workfl
- [Addons](https://storybook.js.org/docs/ember/configure/storybook-addons)

## Working with polyfills

If you need to use a polyfill that is already in use in our Ember application,
you will need to add some options to have Storybook working with them.

In this example we'll use the [named-block-polyfill](https://github.com/ember-polyfills/ember-named-blocks-polyfill).
This example also assume that you already have the package in your `package.json`.

In your `.storybook/main.js` you can add the following lines:
In your `.storybook/main.js` you can add the following lines:

```javascript
const namedBlockPolyfill = require('ember-named-blocks-polyfill/lib/named-blocks-polyfill-plugin');

Expand Down
2 changes: 1 addition & 1 deletion app/html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-app
npx -p @storybook/cli sb init -t html
npx sb init -t html
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
6 changes: 3 additions & 3 deletions app/marionette/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Storybook for Marionette.js
# Storybook for Marionette.js

---

Expand All @@ -14,12 +14,12 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)

---

Storybook also comes with a lot of [addons](https://storybook.js.org/docs/marionette/configure/storybook-addons) and a great API to customize as you wish.
You can also build a [static version](https://storybook.js.org/docs/marionette/workflows/publish-storybook) of your storybook and deploy it anywhere you want.
You can also build a [static version](https://storybook.js.org/docs/marionette/workflows/publish-storybook) of your storybook and deploy it anywhere you want.
2 changes: 1 addition & 1 deletion app/marko/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-marko-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
2 changes: 1 addition & 1 deletion app/mithril/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-mithril-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
2 changes: 1 addition & 1 deletion app/preact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-preact-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
2 changes: 1 addition & 1 deletion app/rax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-rax-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
2 changes: 1 addition & 1 deletion app/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-react-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
2 changes: 1 addition & 1 deletion app/riot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-riot-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
48 changes: 26 additions & 22 deletions app/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-app
npx -p @storybook/cli sb init -t server
npx sb init -t server
```

To configure the server that Storybook will connect to, export a global parameter `parameters.server.url` in `.storybook/preview.js`:
Expand Down Expand Up @@ -70,16 +70,16 @@ export default {
parameters: {
options: {
component: 'my_widget',
}
}
},
},
};

export const Default = (args) => {};
Default.storyName = 'Default';
Default.parameters = {
server: {
id: 'path/of/your/story"'
}
id: 'path/of/your/story"',
},
};
```

Expand Down Expand Up @@ -110,7 +110,7 @@ Static parameters can be defined using the `params` story parameter. For example
{
"name": "Red",
"parameters": {
"server": {
"server": {
"id": "button",
"params": { "color": "red", "label": "Stop" }
}
Expand All @@ -119,7 +119,7 @@ Static parameters can be defined using the `params` story parameter. For example
{
"name": "Green",
"parameters": {
"server": {
"server": {
"id": "button",
"params": { "color": "green", "label": "OK" }
}
Expand All @@ -137,15 +137,15 @@ Like all story parameters server params can be defined in the default export and
{
"title": "Buttons",
"parameters": {
"server": {
"server": {
"params": { "color": "red" }
}
},
"stories": [
{
"name": "Default",
"parameters": {
"server": {
"server": {
"id": "button",
"params": { "label": "Stop" }
}
Expand All @@ -154,7 +154,7 @@ Like all story parameters server params can be defined in the default export and
{
"name": "Green",
"parameters": {
"server": {
"server": {
"id": "button",
"params": { "color": "green", "label": "OK" }
}
Expand All @@ -175,7 +175,7 @@ Dynamic parameters can be defined using args and the Controls addon
{
"name": "Red",
"parameters": {
"server": {
"server": {
"id": "button"
}
},
Expand All @@ -184,7 +184,7 @@ Dynamic parameters can be defined using args and the Controls addon
{
"name": "Green",
"parameters": {
"server": {
"server": {
"id": "button"
}
},
Expand All @@ -208,7 +208,7 @@ Just like CSF stories we can define `argTypes` to specify the controls used in t
{
"name": "Red",
"parameters": {
"server": {
"server": {
"id": "button"
}
},
Expand All @@ -217,7 +217,7 @@ Just like CSF stories we can define `argTypes` to specify the controls used in t
{
"name": "Green",
"parameters": {
"server": {
"server": {
"id": "button"
}
},
Expand Down Expand Up @@ -248,7 +248,7 @@ To configure controls, simple add `args` and `argTypes` keys to the story JSON m
},
"args": { "button_text": "Push Me", "color": "red" },
"argTypes": { "button_text": { "control": { "type": "color" } } }
},
}
]
}
```
Expand Down Expand Up @@ -282,7 +282,6 @@ To use actions, use the `parameters.actions.handles` parameter:

For control over how `@storybook/server` fetches Html from the server you can provide a `fetchStoryHtml` function as a parameter. You would typically set this in `.storybook/preview.js` but it's just a regular Storybook parameter so could be overridden at the stories or story level.


```javascript
// .storybook/preview.js

Expand All @@ -295,18 +294,23 @@ const fetchStoryHtml = async (url, path, params, context) => {
export const parameters = {
server: {
url: `http://localhost:${port}/storybook_preview`,
fetchStoryHtml
fetchStoryHtml,
},
};
```

`fetchStoryHtml` should be an async function with the following signature

```javascript
type FetchStoryHtmlType = (url: string, id: string, params: any, context: StoryContext) => Promise<string | Node>;
type FetchStoryHtmlType = (
url: string,
id: string,
params: any,
context: StoryContext
) => Promise<string | Node>;
```

* url: Server url configured by the `parameters.server.url`
* id: Id of the story being rendered given by `parameters.server.id`
* params: Merged story params `parameters.server.params`and story args
* context: The context of the story
- url: Server url configured by the `parameters.server.url`
- id: Id of the story being rendered given by `parameters.server.id`
- params: Merged story params `parameters.server.params`and story args
- context: The context of the story
2 changes: 1 addition & 1 deletion app/svelte/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-svelte-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
2 changes: 1 addition & 1 deletion app/vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-vue-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
6 changes: 4 additions & 2 deletions app/vue3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-vue3-app
npx -p @storybook/cli sb init
npx sb init
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand All @@ -37,5 +37,7 @@ import { app } from '@storybook/vue3';

app.use(MyPlugin);
app.component('my-component', MyComponent);
app.mixin({ /* My mixin */ });
app.mixin({
/* My mixin */
});
```
2 changes: 1 addition & 1 deletion app/web-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ So you can develop UI components in isolation without worrying about app specifi

```sh
cd my-app
npx -p @storybook/cli sb init -t web_components
npx sb init -t web_components
```

For more information visit: [storybook.js.org](https://storybook.js.org)
Expand Down
2 changes: 1 addition & 1 deletion docs/addons/writing-addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ We'll need to add the necessary dependencies and make some adjustments. Run the
yarn add react react-dom @babel/cli

# Adds Storybook:
npx -p @storybook/cli sb init
npx sb init
```

<div class="aside">
Expand Down
4 changes: 2 additions & 2 deletions docs/get-started/installation-command-section/ember.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Use the Storybook CLI to install it with a couple of commands. Run this inside y

```shell
# Add Storybook:
npx -p @storybook/cli sb init
npx sb init

# Add Ember storybook adapter
ember install @storybook/ember-cli-storybook

```

If you run into issues with the installation, check the troubleshooting section below for guidance on how to solve it.
If you run into issues with the installation, check the troubleshooting section below for guidance on how to solve it.
Loading

0 comments on commit 60c864b

Please sign in to comment.