Skip to content
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 4 commits into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions code/addons/docs/template/stories/docspage/basic.stories.ts
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 code/addons/docs/template/stories/docspage/description.stories.ts
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',
},
},
Comment on lines +11 to +15
Copy link
Member

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?

Copy link
Member Author

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.

chromatic: { disable: true },
},
};

export const Basic = {};

export const CustomDescription = {
parameters: {
docs: {
description: {
story: '**Story** description',
},
},
},
};
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 code/addons/docs/template/stories/docspage/overflow.stories.ts
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 code/addons/docs/template/stories/docspage/override.stories.ts
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 code/addons/docs/template/stories/docspage/source.stories.ts
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);`;
},
},
},
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading