-
Notifications
You must be signed in to change notification settings - Fork 198
Implement custom docs template #8937
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2a92dd2
RG-2669 implement Import block for storybook documentation
lampmaster 1f2fdab
RG-2669 implement custom docs template
lampmaster bc0621c
RG-2669 add slug for the import block in storybook docs
lampmaster 51a0794
RG-2669 automatically generates import block for all components
lampmaster 75bc467
RG-2669 move getSlugFromPath to the utils file
lampmaster 62de61e
RG-2669 fixed path preview.ts => preview.tsx
lampmaster 81c0aa7
RG-2669 import set manually in docs
lampmaster 5574b64
RG-2669 add mdx support
lampmaster 517d65f
RG-2669 add alias custom-docs for the custom storybook documentation …
lampmaster b289ab2
RG-2669 implement mdx and stories templates
lampmaster 9ee0796
RG-2669 update CONTRIBUTING.md - description for story creation
lampmaster 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
This file contains hidden or 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 @@ | ||
import {Source, useOf} from '@storybook/addon-docs/blocks'; | ||
|
||
interface DocsParameters { | ||
importSubpath?: string; | ||
exportName?: string; | ||
} | ||
|
||
interface PreparedMeta { | ||
parameters?: {docs?: DocsParameters}; | ||
} | ||
|
||
export const Import = () => { | ||
const {preparedMeta} = useOf('meta', ['meta']) as {preparedMeta: PreparedMeta}; | ||
const exportName = preparedMeta.parameters?.docs?.exportName; | ||
const importSubpath = preparedMeta.parameters?.docs?.importSubpath; | ||
|
||
if (!exportName || !importSubpath) { | ||
return null; | ||
} | ||
|
||
const builtPath = `import ${exportName} from '@jetbrains/ring-ui-built/${importSubpath}';`; | ||
const sourcePath = `import ${exportName} from '@jetbrains/ring-ui/${importSubpath}';`; | ||
|
||
return ( | ||
<> | ||
<h3>{'Import'}</h3> | ||
|
||
<p>{'Quick start (ready-to-use ES modules):'}</p> | ||
<Source language='tsx' code={builtPath} /> | ||
|
||
<p>{'Build from sources (webpack):'}</p> | ||
<Source language='tsx' code={sourcePath} /> | ||
</> | ||
); | ||
}; |
This file contains hidden or 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 {Controls, Primary, Title} from '@storybook/addon-docs/blocks'; | ||
|
||
import {Import} from './blocks/Import'; | ||
|
||
export const CustomDocs = () => ( | ||
<> | ||
<Title /> | ||
<Primary /> | ||
<Import /> | ||
<Controls /> | ||
</> | ||
); |
This file contains hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
{/* Base MDX template for component documentation */} | ||
|
||
import { Meta, Title, Primary, Controls } from '@storybook/addon-docs/blocks'; | ||
import { Import } from '@custom-docs/blocks/Import'; | ||
|
||
import * as TemplateStories from './template.stories'; | ||
|
||
<Meta of={TemplateStories} /> | ||
|
||
{/* Component name */} | ||
<Title /> | ||
|
||
{/* Component description (optional for now) */} | ||
<p>Write your component description here.</p> | ||
|
||
{/* Main example */} | ||
<Primary /> | ||
|
||
{/* Import section */} | ||
<Import /> | ||
|
||
{/* Props table */} | ||
<Controls /> |
This file contains hidden or 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,46 @@ | ||
// This is a template Storybook configuration. | ||
|
||
import {type Meta, type StoryObj} from '@storybook/react-webpack5'; | ||
|
||
// Replace with your component import | ||
import Button, {type ButtonProps} from '../../src/button/button'; | ||
|
||
// Example Storybook metadata | ||
const meta: Meta<typeof Button> = { | ||
title: 'Entity/Template', // example: Components/Button | ||
component: Button, | ||
|
||
parameters: { | ||
// Docs parameters for the custom Import block | ||
docs: { | ||
importSubpath: 'components/template/template', // update to match your folder structure | ||
exportName: 'Template', // name of the exported component | ||
}, | ||
}, | ||
|
||
// Prop controls and descriptions for the Docs panel | ||
argTypes: { | ||
disabled: { | ||
control: 'boolean', | ||
description: 'Disables the button when true', | ||
}, | ||
onClick: { | ||
action: 'clicked', | ||
description: 'Callback fired when the button is clicked', | ||
}, | ||
}, | ||
|
||
// Default args for the basic story | ||
args: { | ||
children: 'Click me', | ||
disabled: false, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Button>; | ||
|
||
// Add your stories here | ||
export const Basic: Story = { | ||
render: (args: ButtonProps) => <Button {...args} />, | ||
}; |
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.