Skip to content

Commit

Permalink
Merge pull request storybookjs#15405 from storybookjs/fix_react_snippets
Browse files Browse the repository at this point in the history
Chore: (Docs snippets) Updates for jsx and tsx support
  • Loading branch information
jonniebigodes authored Jul 2, 2021
2 parents 051a42e + b7f47e9 commit 5096004
Show file tree
Hide file tree
Showing 132 changed files with 153 additions and 147 deletions.
2 changes: 2 additions & 0 deletions docs/essentials/auto-generated-controls/react.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
To use auto-detected controls with React, you must fill in the `component` field in your story metadata:

```ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

import { Button } from './Button';

export default {
Expand Down
2 changes: 2 additions & 0 deletions docs/essentials/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ npm install --save-dev @storybook/addon-essentials
Update your Storybook configuration (in `.storybook/main.js`) to include the essentials addon.

```js
// .storybook/main.js

module.exports = {
addons: ['@storybook/addon-essentials'],
};
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/badge-story-custom-argtypes.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Badge.stories.js | Badge.stories.ts
// Badge.stories.js | Badge.stories.jsx | Badge.stories.ts | Badge.stories.tsx

export default {
component: Badge,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// ButtonGroup.stories.js
// ButtonGroup.stories.js | ButtonGroup.stories.jsx

import { Button, ButtonGroup } from '../ButtonGroup';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```ts
// ButtonGroup.stories.ts
// ButtonGroup.stories.ts | ButtonGroup.stories.tsx

import { Meta } from '@storybook/react/types-6-0';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

const Primary = Template.bind({});
Primary.args = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand Down
6 changes: 3 additions & 3 deletions docs/snippets/common/button-story-default-export.js.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button'
}
title: 'Button',
};
```
2 changes: 1 addition & 1 deletion docs/snippets/common/button-story-disable-addon.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

import { Button } from './Button';

Expand Down
4 changes: 2 additions & 2 deletions docs/snippets/common/button-story-docs-code-type.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand All @@ -10,7 +10,7 @@ export default {
parameters: {
docs: {
source: {
type: 'code'
type: 'code',
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

import { Button } from './Button';

Expand Down
3 changes: 1 addition & 2 deletions docs/snippets/common/button-story-docspage-with-mdx.js.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
```js

// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

import { Button } from './Button';

Expand Down
6 changes: 3 additions & 3 deletions docs/snippets/common/button-story-grouped.js.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Design System/Atoms/Button'
}
title: 'Design System/Atoms/Button',
};
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export const Large = Template.bind({});

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/button-story-hoisted.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

import { Button as ButtonComponent } from './Button';

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/button-story-matching-argtypes.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

const Primary = ButtonStory.bind({});
Primary.args = {
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/button-story-primary-long-name.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export const PrimaryLongName = Template.bind({});

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/button-story-remix-docspage.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js
// Button.stories.js | Button.stories.jsx

import React from 'react';

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/button-story-remix-docspage.ts.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```ts
// Button.stories.tsx
// Button.stories.ts | Button.stories.tsx

import React from 'react';

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/button-story-with-parameters.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export const Primary = Template.bind({});
Primary.args ={
Expand Down
6 changes: 3 additions & 3 deletions docs/snippets/common/checkbox-story-csf.js.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
```js
// Checkbox.stories.js
// Checkbox.stories.js | Checkbox.stories.jsx

import { Checkbox } from './Checkbox';

export default {
title: 'MDX/Checkbox',
component: Checkbox
title: 'MDX/Checkbox',
component: Checkbox,
};

const Template = (args) => <Checkbox {...args} />
Expand Down
6 changes: 3 additions & 3 deletions docs/snippets/common/checkbox-story-grouped.js.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```js
// Checkbox.stories.js | Checkbox.stories.ts
// Checkbox.stories.js | Checkbox.stories.jsx | Checkbox.stories.ts | Checkbox.stories.tsx

export default {
title: 'Design System/Atoms/Checkbox'
}
title: 'Design System/Atoms/Checkbox',
};
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'Button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export default {
title: 'CustomDescription',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

import { Button } from './button';
import { ArrowUp, ArrowDown, ArrowLeft, ArrowRight } from './icons';
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/component-story-custom-source.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export const CustomSource = () => Template.bind({});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// YourComponent.stories.js | YourComponent.stories.ts
// YourComponent.stories.js | YourComponent.stories.jsx | YourComponent.stories.ts | YourComponent.stories.tsx

import { YourComponent } from './your-component'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// YourComponent.stories.js | YourComponent.stories.ts
// YourComponent.stories.js | YourComponent.stories.jsx | YourComponent.stories.ts | YourComponent.stories.tsx

ArrayInclude = Template.bind({})
ArrayInclude.parameters = { controls: { include: ['foo', 'bar'] } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// YourComponent.stories.js | YourComponent.stories.ts
// YourComponent.stories.js | YourComponent.stories.jsx | YourComponent.stories.ts | YourComponent.stories.tsx

import { YourComponent } from './your-component'

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/component-story-dynamic-title.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// MyComponent.stories.js | MyComponent.stories.ts
// MyComponent.stories.js | MyComponent.stories.jsx | MyComponent.stories.ts | MyComponent.stories.tsx

import base from 'paths.macro';

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/component-story-sort-controls.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// YourComponent.stories.js | YourComponent.stories.ts
// YourComponent.stories.js | YourComponent.stories.jsx | YourComponent.stories.ts | YourComponent.stories.tsx

import { YourComponent } from './your-component'

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/custom-docs-page.ts-component.ts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import React from 'react';

export const CustomDocumentationComponent: React.FC<{}> = () => {
export const CustomDocumentationComponent: React.VFC<{}> = () => {
return (
<div>
<h1>Replacing DocsPage with a custom component</h1>
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/foo-bar-baz-story.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// FooBar.stories.js | FooBar.stories.ts
// FooBar.stories.js | FooBar.stories.jsx | FooBar.stories.ts | FooBar.stories.tsx

export default {
title: 'Foo/Bar',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Gizmo.stories.js | Gizmo.stories.ts
// Gizmo.stories.js | Gizmo.stories.jsx | Gizmo.stories.ts | Gizmo.stories.tsx

export default {
title: 'Gizmo',
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/my-component-story-import-json.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// MyComponent.stories.js | MyComponent.stories.ts
// MyComponent.stories.js | MyComponent.stories.jsx | MyComponent.stories.ts | MyComponent.stories.tsx

// This will automatically be parsed to the contents of `data.json`
import data from './data.json';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// MyComponent.stories.js | MyComponent.stories.ts
// MyComponent.stories.js | MyComponent.stories.jsx | MyComponent.stories.ts | MyComponent.stories.tsx

// This will include './static/image.png' in the bundle.
// And return a path to be included in a src attribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// MyComponent.story.js
// MyComponent.story.js | MyComponent.story.jsx | MyComponent.story.ts | MyComponent.story.tsx

import MyComponent from './MyComponent';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// MyComponent.stories.js
// MyComponent.stories.js | MyComponent.stories.jsx | MyComponent.stories.ts | MyComponent.stories.tsx

export const StoryWithLocale = ({ globals: { locale } }) => {
const caption = getCaptionForLocale(locale);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// MyComponent.stories.js
// MyComponent.stories.js | MyComponent.stories.jsx | MyComponent.stories.ts | MyComponent.stories.tsx

const getCaptionForLocale = (locale) => {
switch(locale) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// MyComponent.stories.js
// MyComponent.story.js | MyComponent.story.jsx | MyComponent.story.ts | MyComponent.story.tsx

export const Simple = () => <MyComponent />;

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/my-component-story.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// MyComponent.stories.js | MyComponent.stories.ts
// MyComponent.stories.js | MyComponent.stories.jsx | MyComponent.stories.ts | MyComponent.stories.tsx

import { MyComponent } from './MyComponent';

Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/common/other-foo-bar-story.js.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// FooBar.stories.js | FooBar.stories.ts
// FooBar.stories.js | FooBar.stories.jsx | FooBar.stories.ts | FooBar.stories.tsx

export default {
title: 'OtherFoo/Bar',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

// To apply a set of backgrounds to all stories of Button:
export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

// To apply a grid to all stories of Button:
export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```js
// Button.stories.js | Button.stories.ts
// Button.stories.js | Button.stories.jsx | Button.stories.ts | Button.stories.tsx

export const Large = Template.bind({});
Large.parameters = {
Expand Down
Loading

0 comments on commit 5096004

Please sign in to comment.