mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 23:02:00 +08:00
33 lines
1.6 KiB
Plaintext
33 lines
1.6 KiB
Plaintext
To use auto-detected controls with Ember, you must fill in the `component` field in your story metadata:
|
|
|
|
```ts
|
|
import { Button } from './Button';
|
|
|
|
export default {
|
|
title: 'Button',
|
|
component: 'button', // name of your button component
|
|
};
|
|
```
|
|
|
|
Storybook uses this to auto-generate the `ArgTypes` for your component based on docgen information created by [ember-cli-addon-docs-yuidoc](https://github.com/ember-learn/ember-cli-addon-docs-yuidoc#documenting-components).
|
|
|
|
You'll need to register that in `.storybook/preview.js`:
|
|
|
|
```js
|
|
import { setJSONDoc } from '@storybook/addon-docs/ember';
|
|
import docJson from '../storybook-docgen/index.json';
|
|
setJSONDoc(docJson);
|
|
```
|
|
|
|
Storybook for Ember relies on [@storybook/ember-cli-storybook addon](https://github.com/storybookjs/ember-cli-storybook), to extract documentation comments from your component source files. If you're using Storybook with Ember, you should already have this addon installed, you will just need to enable it by adding the following config block in your `ember-cli-build.js` file:
|
|
|
|
```js
|
|
let app = new EmberApp(defaults, {
|
|
'ember-cli-storybook': {
|
|
enableAddonDocsIntegration: true,
|
|
},
|
|
});
|
|
```
|
|
|
|
Now, running the ember-cli server will generate a JSON documentation file at `/storybook-docgen/index.json`. Since generation of this file is tied into the ember-cli build, it will get regenerated every time component files are saved. For details on documenting your components, check out the examples in the addon that powers the generation [ember-cli-addon-docs-yuidoc](https://github.com/ember-learn/ember-cli-addon-docs-yuidoc#documenting-components).
|