Skip to content

Commit

Permalink
Updates for type
Browse files Browse the repository at this point in the history
  • Loading branch information
kylegach committed Jun 9, 2023
1 parent c8ab894 commit 55bfceb
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 23 deletions.
32 changes: 9 additions & 23 deletions docs/api/arg-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Type:
}
```

Default: [Inferred](#automatic-argtype-inference); `'select'`, if [`options`](#options) are specified; falling back to `'object'`
Default: Inferred from [`type`](#type); `'select'`, if [`options`](#options) are specified; falling back to `'object'`

Specify the behavior of the [controls addon](../essentials/controls.md) for the arg. If you specify a string, it's used as the [`type`](#controltype) of the control. If you specify an object, you can provide additional configuration.

Expand Down Expand Up @@ -394,10 +394,12 @@ Display the argType under a subcategory heading (which displays under the [`cate

Type: `{ detail?: string; summary: string }`

Default: [Inferred](#automatic-argtype-inference)
Default: Inferred from [`type`](#type)

The documented type of the argType. `summary` is typically used for the type itself, while `detail` is used for additional information.

If you need to specify the actual, semantic type, you should use [`type`](#type), instead.

### `type`

Type: `'boolean' | 'function' | 'number' | 'string' | 'symbol' | SBType`
Expand Down Expand Up @@ -456,40 +458,24 @@ type SBType =

Default: [Inferred](#automatic-argtype-inference)

TK <!-- TODO: Not sure how this differs from `table.type.summary` -->
Specifies the semantic type of the argType. When an argType is [inferred](#automatic-argtype-inference), the information from the various tools is summarized in this property, which is then used to infer other properties, like [`control`](#control) and [`table.type`](#tabletype).

If you only need to specify the documented type, you should use [`table.type`](#tabletype), instead.

<!-- prettier-ignore-start -->

<!-- TODO <CodeSnippets
<CodeSnippets
paths={[
'angular/arg-types-type.ts.mdx',
'web-components/arg-types-type.js.mdx',
'web-components/arg-types-type.ts.mdx',
'common/arg-types-type.js.mdx',
'common/arg-types-type.ts.mdx',
]}
/> -->
/>

<!-- prettier-ignore-end -->

```ts
// Example.stories.ts|tsx

// Replace your-renderer with the renderer you are using (e.g., react, vue3, angular, etc.)
import type { Meta } from '@storybook/your-renderer';

import { Example } from './Example';

const meta: Meta<typeof Example> = {
component: Example,
argTypes: {
// TK
},
};

export default meta;
```

### `defaultValue` (deprecated)

Type: `any`
Expand Down
16 changes: 16 additions & 0 deletions docs/snippets/angular/arg-types-type.ts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```ts
// Example.stories.ts

import type { Meta } from '@storybook/angular';

import { Example } from './Example';

const meta: Meta<Example> = {
component: Example,
argTypes: {
value: { type: 'number' },
},
};

export default meta;
```
12 changes: 12 additions & 0 deletions docs/snippets/common/arg-types-type.js.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```js
// Example.stories.js|jsx

import { Example } from './Example';

export default {
component: Example,
argTypes: {
value: { type: 'number' },
},
};
```
17 changes: 17 additions & 0 deletions docs/snippets/common/arg-types-type.ts-4-9.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```ts
// Example.stories.ts|tsx

// Replace your-renderer with the renderer you are using (e.g., react, vue3, angular, etc.)
import type { Meta } from '@storybook/your-renderer';

import { Example } from './Example';

const meta = {
component: Example,
argTypes: {
value: { type: 'number' },
},
} satisfies Meta<typeof Example>;

export default meta;
```
17 changes: 17 additions & 0 deletions docs/snippets/common/arg-types-type.ts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```ts
// Example.stories.ts|tsx

// Replace your-renderer with the renderer you are using (e.g., react, vue3, angular, etc.)
import type { Meta } from '@storybook/your-renderer';

import { Example } from './Example';

const meta: Meta<typeof Example> = {
component: Example,
argTypes: {
value: { type: 'number' },
},
};

export default meta;
```
10 changes: 10 additions & 0 deletions docs/snippets/web-components/arg-types-type.js.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```js
// Example.stories.js

export default {
component: 'demo-example',
argTypes: {
value: { type: 'number' },
},
};
```
14 changes: 14 additions & 0 deletions docs/snippets/web-components/arg-types-type.ts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```ts
// Example.stories.ts

import type { Meta } from '@storybook/web-components';

const meta: Meta = {
component: 'demo-example',
argTypes: {
value: { type: 'number' },
},
};

export default meta;
```

0 comments on commit 55bfceb

Please sign in to comment.