forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
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 storybookjs#15470 from storybookjs/chore_loader_do…
…cs_updates Chore: (Docs) Updates the loader docs
- Loading branch information
Showing
11 changed files
with
210 additions
and
27 deletions.
There are no files selected for viewing
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,28 @@ | ||
```md | ||
<!-- TodoItem.stories.mdx --> | ||
|
||
import { Meta, Story } from '@storybook/addon-docs/blocks'; | ||
|
||
import TodoItem from './TodoItem'; | ||
|
||
import fetch from 'node-fetch'; | ||
|
||
<Meta title="Examples/Loader" component={TodoItem} /> | ||
|
||
<Story | ||
name="Primary" | ||
loaders={[ | ||
async () => ({ | ||
todo: await ( | ||
await fetch("https://jsonplaceholder.typicode.com/todos/1") | ||
).json(), | ||
}), | ||
]} | ||
> | ||
{(args, { loaded: { todo } }) => ({ | ||
props: { | ||
todo: todo, | ||
}, | ||
})} | ||
</Story> | ||
``` |
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,37 @@ | ||
```ts | ||
// TodoItem.stories.ts | ||
|
||
import { moduleMetadata, Story, Meta } from '@storybook/angular'; | ||
|
||
import fetch from 'node-fetch'; | ||
|
||
import { CommonModule } from '@angular/common'; | ||
|
||
import TodoItem from './TodoItem'; | ||
|
||
export default { | ||
component: TodoItem, | ||
decorators: [ | ||
moduleMetadata({ | ||
declarations: [TodoItem], | ||
imports: [CommonModule], | ||
}), | ||
], | ||
title: 'Examples/Loader', | ||
} as Meta; | ||
|
||
export const Primary = (args, { loaded: { todo } }) => { | ||
return { | ||
props: { | ||
args, | ||
todo, | ||
}, | ||
}; | ||
}; | ||
|
||
Primary.loaders = [ | ||
async () => ({ | ||
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(), | ||
}), | ||
]; | ||
``` |
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
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
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,26 @@ | ||
```md | ||
<!-- TodoItem.stories.mdx --> | ||
|
||
import { Meta, Story } from '@storybook/addon-docs'; | ||
|
||
import fetch from 'node-fetch'; | ||
|
||
import { TodoItem } from './TodoItem'; | ||
|
||
<Meta title="Examples/Loader" component={TodoItem} /> | ||
|
||
<Story | ||
name="Primary" | ||
loaders={[ | ||
async () => ({ | ||
todo: await ( | ||
await fetch("https://jsonplaceholder.typicode.com/todos/1") | ||
).json(), | ||
}), | ||
]} | ||
> | ||
{(args, { loaded: { todo } }) => ( | ||
<TodoItem {...args} todo={todo} /> | ||
)} | ||
</Story> | ||
``` |
13 changes: 0 additions & 13 deletions
13
docs/snippets/react/storybook-preview-global-loader.js.mdx
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
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,30 @@ | ||
```md | ||
<!-- TodoItem.stories.mdx --> | ||
|
||
import { Meta, Story } from '@storybook/addon-docs'; | ||
|
||
import TodoItem from './TodoItem.svelte'; | ||
|
||
import fetch from 'node-fetch'; | ||
|
||
<Meta title="Examples/Loader" component={TodoItem} /> | ||
|
||
<Story | ||
name="Primary" | ||
loaders={[ | ||
async () => ({ | ||
todo: await ( | ||
await fetch("https://jsonplaceholder.typicode.com/todos/1") | ||
).json(), | ||
}), | ||
]} | ||
> | ||
{(args, { loaded: { todo } }) => ({ | ||
Component: SampleLoaderComponent, | ||
props: { | ||
...args, | ||
todo, | ||
}, | ||
})} | ||
</Story> | ||
``` |
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,28 @@ | ||
```js | ||
// TodoItem.stories.js | ||
|
||
import TodoItem from './TodoItem.vue'; | ||
|
||
import fetch from 'node-fetch'; | ||
|
||
export default { | ||
component: TodoItem, | ||
title: 'Examples/Loader', | ||
}; | ||
|
||
export const Primary = (args, { loaded: { todo } }) => { | ||
return { | ||
components: { TodoItem }, | ||
setup() { | ||
return { args, todo: todo }; | ||
}, | ||
template: `<TodoItem :todo="todo"/>`, | ||
}; | ||
}; | ||
|
||
Primary.loaders = [ | ||
async () => ({ | ||
todo: await (await fetch('https://jsonplaceholder.typicode.com/todos/1')).json(), | ||
}), | ||
]; | ||
``` |
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,30 @@ | ||
```md | ||
<!-- TodoItem.stories.mdx --> | ||
|
||
import { Meta, Story } from '@storybook/addon-docs'; | ||
|
||
import TodoItem from './TodoItem.vue'; | ||
|
||
import fetch from 'node-fetch'; | ||
|
||
<Meta title="Examples/Loader" component={TodoItem} /> | ||
|
||
<Story | ||
name="Primary" | ||
loaders={[ | ||
async () => ({ | ||
todo: await ( | ||
await fetch("https://jsonplaceholder.typicode.com/todos/1") | ||
).json(), | ||
}), | ||
]} | ||
> | ||
{(args, { loaded: { todo } }) => ({ | ||
components: { TodoItem }, | ||
setup() { | ||
return { args, todo: todo }; | ||
}, | ||
template: `<TodoItem :todo="todo"/>`, | ||
})} | ||
</Story> | ||
``` |
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