-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22970 from storybookjs/api-reference-arg-types
Docs: Add ArgTypes API reference
- Loading branch information
Showing
82 changed files
with
1,834 additions
and
459 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
```ts | ||
// Example.stories.ts | ||
|
||
import type { Meta } from '@storybook/angular'; | ||
|
||
import { Example } from './Example'; | ||
|
||
const meta: Meta<Example> = { | ||
component: Example, | ||
argTypes: { | ||
value: { | ||
control: { | ||
type: 'number', | ||
min: 0, | ||
max: 100, | ||
step: 10, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
```ts | ||
// Example.stories.ts | ||
|
||
import type { Meta } from '@storybook/angular'; | ||
|
||
import { Example } from './Example'; | ||
|
||
const meta: Meta<Example> = { | ||
component: Example, | ||
argTypes: { | ||
value: { | ||
// ❌ Deprecated | ||
defaultValue: 0, | ||
}, | ||
}, | ||
// ✅ Do this instead | ||
args: { | ||
value: 0, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
```ts | ||
// Example.stories.ts | ||
|
||
import type { Meta } from '@storybook/angular'; | ||
|
||
import { Example } from './Example'; | ||
|
||
const meta: Meta<Example> = { | ||
component: Example, | ||
argTypes: { | ||
value: { | ||
description: 'The value of the slider', | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
```ts | ||
// Example.stories.ts | ||
|
||
import type { Meta } from '@storybook/angular'; | ||
|
||
import { Example } from './Example'; | ||
|
||
const meta: Meta<Example> = { | ||
component: Example, | ||
argTypes: { | ||
parent: { control: 'select', options: ['one', 'two', 'three'] }, | ||
|
||
// 👇 Only shown when `parent` arg exists | ||
parentExists: { if: { arg: 'parent', exists: true } }, | ||
|
||
// 👇 Only shown when `parent` arg does not exist | ||
parentDoesNotExist: { if: { arg: 'parent', exists: false } }, | ||
|
||
// 👇 Only shown when `parent` arg value is truthy | ||
parentIsTruthy: { if: { arg: 'parent' } }, | ||
parentIsTruthyVerbose: { if: { arg: 'parent', truthy: true } }, | ||
|
||
// 👇 Only shown when `parent` arg value is not truthy | ||
parentIsNotTruthy: { if: { arg: 'parent', truthy: false } }, | ||
|
||
// 👇 Only shown when `parent` arg value is 'three' | ||
parentIsEqToValue: { if: { arg: 'parent', eq: 'three' } }, | ||
|
||
// 👇 Only shown when `parent` arg value is not 'three' | ||
parentIsNotEqToValue: { if: { arg: 'parent', neq: 'three' } }, | ||
|
||
// Each of the above can also be conditional on the value of a globalType, e.g.: | ||
|
||
// 👇 Only shown when `theme` global exists | ||
parentExists: { if: { global: 'theme', exists: true } }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
```ts | ||
// Button.stories.ts | ||
|
||
import type { Meta } from '@storybook/angular'; | ||
|
||
import { Button } from './button.component'; | ||
|
||
const meta: Meta<Button> = { | ||
component: Button, | ||
argTypes: { | ||
// 👇 All Button stories expect a label arg | ||
label: { | ||
control: 'string', | ||
description: 'Overwritten description', | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...my-component-argtypes-with-mapping.ts.mdx → ...snippets/angular/arg-types-mapping.ts.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.