-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
At the develop branch, the Button component is migrated as an example. Let's migrate the rest of them.
Use the guide below to migrate them.
Migration Guide
- To define stories, use object (
StoryObj) instead of function (StoryFn):
// Before
export const Foo = (): JSX.Element => { ... }
// After
export const Foo: StoryObj = {
render: () => {
return ...
}
}- For the return type, use
ReactElementinstead ofJSX.Element. However, if the function is already typed, such as viaStoryObj.render, then we don't need to provide an explicit return type:
export const Foo: StoryObj = {
// Already typed
render: () => {
return ...
}
}- For story description, use JSDoc instead of
Utils.story. Remember to unescape the grave accent ("`") character:
// Before
export const Foo = () => ...
Utils.story(Foo, { desc: `
Hello \`world\`
` });
// After
/**
* Hello `world`
*/
export const Foo: StoryObj = { render }- When writing descriptions, manually break lines at sentences or clauses, not at arbitrary fixed column like 80 or 100:
// Before
`
This is a sentence. This is
another sentence, with 2 clauses.
`
// After
/**
* This is a sentence.
* This is another sentence,
* with 2 clauses.
*/- In meta, use
docsMetaParametersinstead ofUtils.page.component:
// Before
const meta = {}
Utils.page.component(meta, {
shots
})
// After
const meta = {
parameters: docsMetaParameters({
gallery
})
}- In meta, use
docsMetaArgTypesinstead ofUtils.arg:
// Before
const meta = {
argTypes: {
size: Utils.arg(Button.sizes, "Visual"),
disabled: Utils.arg("boolean", "Functional"),
id: Utils.arg(null, "Functional"),
}
}
// After
const meta = {
argTypes: docsMetaArgTypes({
Visual: {
size: Button.sizes,
},
Functional: {
disabled: "boolean",
id: false
},
})
}- For primary story, provide the component type
instead of defining the props interface again:
// Before
interface Props { }
export const Primary = (props: Props) => { }
// After
export const Primary: StoryObj<typeof Button> = {
render: (props) => { }
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels