-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addon-docs: Generic stories for DocsPage #19162
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
code/addons/docs/template/stories/docspage/basic.stories.ts
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,20 @@ | ||
import globalThis from 'global'; | ||
|
||
export default { | ||
component: globalThis.Components.Button, | ||
args: { children: 'Click Me!' }, | ||
parameters: { chromatic: { disable: true } }, | ||
}; | ||
|
||
export const Basic = { | ||
args: { children: 'Basic' }, | ||
}; | ||
|
||
export const Disabled = { | ||
args: { children: 'Disabled in DocsPage' }, | ||
parameters: { docs: { disable: true } }, | ||
}; | ||
|
||
export const Another = { | ||
args: { children: 'Another' }, | ||
}; |
30 changes: 30 additions & 0 deletions
30
code/addons/docs/template/stories/docspage/description.stories.ts
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 @@ | ||
import globalThis from 'global'; | ||
|
||
export default { | ||
component: globalThis.Components.Button, | ||
// FIXME: remove array subcomponents in 7.0? | ||
subcomponents: { | ||
Pre: globalThis.Components.Pre, | ||
}, | ||
args: { children: 'Click Me!' }, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: '**Component** description', | ||
}, | ||
}, | ||
chromatic: { disable: true }, | ||
}, | ||
}; | ||
|
||
export const Basic = {}; | ||
|
||
export const CustomDescription = { | ||
parameters: { | ||
docs: { | ||
description: { | ||
story: '**Story** description', | ||
}, | ||
}, | ||
}, | ||
}; |
17 changes: 17 additions & 0 deletions
17
code/addons/docs/template/stories/docspage/extract-description.stories.ts
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,17 @@ | ||
import globalThis from 'global'; | ||
|
||
export default { | ||
component: globalThis.Components.Button, | ||
args: { children: 'Click Me!' }, | ||
parameters: { | ||
docs: { | ||
// FIXME: this is typically provided by the renderer preset to extract | ||
// the description automatically based on docgen info. including here | ||
// for documentation purposes only. | ||
extractComponentDescription: () => 'component description', | ||
}, | ||
chromatic: { disable: true }, | ||
}, | ||
}; | ||
|
||
export const Basic = {}; |
12 changes: 12 additions & 0 deletions
12
code/addons/docs/template/stories/docspage/overflow.stories.ts
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,12 @@ | ||
import globalThis from 'global'; | ||
|
||
export default { | ||
component: globalThis.Components.Pre, | ||
args: { | ||
text: 'Demonstrates overflow', | ||
style: { width: 2000, height: 500, background: 'hotpink' }, | ||
}, | ||
parameters: { chromatic: { disable: true } }, | ||
}; | ||
|
||
export const Basic = {}; |
25 changes: 25 additions & 0 deletions
25
code/addons/docs/template/stories/docspage/override.stories.ts
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,25 @@ | ||
import globalThis from 'global'; | ||
|
||
// FIXME: do this using basic React functions for multi-framework | ||
// once sandbox linking is working | ||
// | ||
// import { createElement } from 'react'; | ||
// import { Title, Primary } from '@storybook/addon-docs'; | ||
// | ||
// const Override = () => | ||
// createElement('div', { style: { border: '10px solid green', padding: '100px' } }, [ | ||
// createElement(Title), | ||
// createElement(Primary), | ||
// ]); | ||
const Override = () => 'overridden'; | ||
|
||
export default { | ||
component: globalThis.Components.Button, | ||
args: { children: 'Click Me!' }, | ||
parameters: { | ||
chromatic: { disable: true }, | ||
docs: { page: Override }, | ||
}, | ||
}; | ||
|
||
export const Basic = {}; |
43 changes: 43 additions & 0 deletions
43
code/addons/docs/template/stories/docspage/source.stories.ts
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,43 @@ | ||
import globalThis from 'global'; | ||
|
||
export default { | ||
component: globalThis.Components.Button, | ||
args: { children: 'Click Me!' }, | ||
parameters: { chromatic: { disable: true } }, | ||
}; | ||
|
||
export const Auto = {}; | ||
|
||
export const Disabled = { | ||
parameters: { | ||
docs: { | ||
source: { code: null }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Code = { | ||
parameters: { | ||
docs: { | ||
source: { type: 'code' }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Custom = { | ||
parameters: { | ||
docs: { | ||
source: { code: 'custom source' }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Transform = { | ||
parameters: { | ||
docs: { | ||
transformSource(src: string) { | ||
return `// We transformed this!\nconst example = (\n${src}\n);`; | ||
}, | ||
}, | ||
}, | ||
}; |
144 changes: 0 additions & 144 deletions
144
code/examples/official-storybook/stories/addon-docs/addon-docs-blocks.stories.js
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
code/examples/official-storybook/stories/addon-docs/addon-docs.stories.js
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
code/examples/official-storybook/stories/addon-docs/array-subcomponents.stories.js
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
code/examples/official-storybook/stories/addon-docs/dynamic-title.stories.js
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
code/examples/official-storybook/stories/addon-docs/memo.stories.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also have examples that set this stuff via
argTypes
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tmeasday Added a placeholder, although it's not an especially useful test. We should revisit when we do the annotations server.