-
-
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 branch 'next' into feature/24070/convert-babel-plugins
- Loading branch information
Showing
6 changed files
with
126 additions
and
2 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,31 @@ | ||
```js | ||
// my-component/component.stories.js|jsx | ||
|
||
import { useArgs } from '@storybook/preview-api'; | ||
import { Checkbox } from './checkbox'; | ||
|
||
export default { | ||
title: 'Inputs/Checkbox', | ||
component: Checkbox, | ||
}; | ||
|
||
export const Example = { | ||
args: { | ||
isChecked: false, | ||
label: 'Try Me!', | ||
}, | ||
/** | ||
* 👇 To avoid linting issues, it is recommended to use a function with a capitalized name. | ||
* If you are not concerned with linting, you may use an arrow function. | ||
*/ | ||
render: function Render(args) { | ||
const [{ isChecked }, updateArgs] = useArgs(); | ||
|
||
function onChange() { | ||
updateArgs({ isChecked: !isChecked }); | ||
} | ||
|
||
return <Checkbox {...args} onChange={onChange} isChecked={isChecked} />; | ||
}, | ||
}; | ||
``` |
35 changes: 35 additions & 0 deletions
35
docs/snippets/react/page-story-args-within-story.ts-4-9.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
```ts | ||
// my-component/component.stories.ts|tsx | ||
|
||
import { StoryObj, Meta } from '@storybook/react'; | ||
import { useArgs } from '@storybook/preview-api'; | ||
import { Checkbox } from './checkbox'; | ||
|
||
const meta = { | ||
title: 'Inputs/Checkbox', | ||
component: Checkbox, | ||
} satisfies Meta<typeof Checkbox>; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof Checkbox>; | ||
|
||
export const Example = { | ||
args: { | ||
isChecked: false, | ||
label: 'Try Me!', | ||
}, | ||
/** | ||
* 👇 To avoid linting issues, it is recommended to use a function with a capitalized name. | ||
* If you are not concerned with linting, you may use an arrow function. | ||
*/ | ||
render: function Render(args) { | ||
const [{ isChecked }, updateArgs] = useArgs(); | ||
|
||
function onChange() { | ||
updateArgs({ isChecked: !isChecked }); | ||
} | ||
|
||
return <Checkbox {...args} onChange={onChange} isChecked={isChecked} />; | ||
}, | ||
} satisfies 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,35 @@ | ||
```ts | ||
// my-component/component.stories.ts|tsx | ||
|
||
import { StoryObj, Meta } from '@storybook/react'; | ||
import { useArgs } from '@storybook/preview-api'; | ||
import { Checkbox } from './checkbox'; | ||
|
||
const meta: Meta<typeof Checkbox> = { | ||
title: 'Inputs/Checkbox', | ||
component: Checkbox, | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof Checkbox>; | ||
|
||
export const Example: Story = { | ||
args: { | ||
isChecked: false, | ||
label: 'Try Me!', | ||
}, | ||
/** | ||
* 👇 To avoid linting issues, it is recommended to use a function with a capitalized name. | ||
* If you are not concerned with linting, you may use an arrow function. | ||
*/ | ||
render: function Render(args) { | ||
const [{ isChecked }, updateArgs] = useArgs(); | ||
|
||
function onChange() { | ||
updateArgs({ isChecked: !isChecked }); | ||
} | ||
|
||
return <Checkbox {...args} onChange={onChange} isChecked={isChecked} />; | ||
}, | ||
}; | ||
``` |
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