-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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 #17658 from fbredius/preact-code-snippet
Docs: Add remaining Preact code snippets for Get-Started section
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 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
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 @@ | ||
```js | ||
// Button.stories.js|jsx | ||
|
||
/** @jsx h */ | ||
import { h } from 'preact'; | ||
|
||
import { Button } from './Button'; | ||
|
||
export default { | ||
/* 👇 The title prop is optional. | ||
* See https://storybook.js.org/docsreact/configure/overview#configure-story-loading | ||
* to learn how to generate automatic titles | ||
*/ | ||
title: 'Button', | ||
component: Button, | ||
} | ||
//👇 We create a “template” of how args map to rendering | ||
const Template = (args) => <Button {...args} />; | ||
|
||
//👇 Each story then reuses that template | ||
export const Primary = Template.bind({}); | ||
Primary.args = { | ||
primary: true, | ||
label: 'Button', | ||
}; | ||
``` |
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 @@ | ||
```js | ||
// YourComponent.stories.js|jsx | ||
|
||
/** @jsx h */ | ||
import { h } from 'preact'; | ||
|
||
import { YourComponent } from './YourComponent'; | ||
|
||
//👇 This default export determines where your story goes in the story list | ||
export default { | ||
/* 👇 The title prop is optional. | ||
* See https://storybook.js.org/docsreact/configure/overview#configure-story-loading | ||
* to learn how to generate automatic titles | ||
*/ | ||
title: 'YourComponent', | ||
component: YourComponent, | ||
} | ||
|
||
//👇 We create a “template” of how args map to rendering | ||
const Template = (args) => <YourComponent {...args} />; | ||
|
||
export const FirstStory = Template.bind({}); | ||
FirstStory.args = { | ||
//👇 The args you need here will depend on your component | ||
}; | ||
``` |