-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
React: Improve automatic component, automatic imports, support barrel files and enhance story filtering #32939
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
kasperpeulen
merged 36 commits into
next
from
kasper/manifest-auto-component-import-barrel
Nov 4, 2025
Merged
Changes from 22 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
a5f4646
Add automatic component imports
kasperpeulen 17a3089
Add automatic component imports
kasperpeulen 9331bf7
Improve
kasperpeulen 2b072ba
Use the package.json belonging to the story
kasperpeulen 835417c
Get fallback components to work
kasperpeulen 8ba3b0b
Refactor
kasperpeulen 8d40e43
Fix type
kasperpeulen ce25a2f
Fix type
kasperpeulen 7e9a30a
Fix type
kasperpeulen acf5925
Fix tests
kasperpeulen 2a05fc4
Cleanup react docgen
kasperpeulen 3de6fad
Cleanup react docgen integration
kasperpeulen 80b0ad2
Cleanup getComponentImports
kasperpeulen 08bdc82
Fix
kasperpeulen 8151722
Refactor
kasperpeulen 50be8d7
Filter by manifest tag and include story descriptions/summaries
kasperpeulen 70e8504
Fix auto imports
kasperpeulen 7ab7295
Fix tests
kasperpeulen d9cc661
Better barrel file support
kasperpeulen e235682
Prettier
kasperpeulen 3f0b505
Refactor tests
kasperpeulen f06a97e
Fix lint
kasperpeulen 946327d
Fix feedback
kasperpeulen 10ef28f
Fix feedback
kasperpeulen 8f96d8c
Fix feedback
kasperpeulen 41d93f3
Fix
kasperpeulen 26bbbda
Refactor
kasperpeulen 5e59d7a
Refactor
kasperpeulen f4caa77
Clean up
kasperpeulen 2780b84
Pretty
kasperpeulen 68d91cf
Fix title
kasperpeulen 688057b
Feedback
kasperpeulen 7763851
Better basedir for tsconfig resolution
kasperpeulen 8829d71
Merge remote-tracking branch 'origin/next' into kasper/manifest-auto-…
kasperpeulen 947c37e
Address feedback
kasperpeulen 6f87e22
Address feedback
kasperpeulen 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
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
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,193 @@ | ||
| import { dedent } from 'ts-dedent'; | ||
|
|
||
| export const fsMocks = { | ||
| ['./package.json']: JSON.stringify({ name: 'some-package' }), | ||
| ['./src/stories/Button.stories.ts']: dedent` | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { fn } from 'storybook/test'; | ||
| import { Button } from './Button'; | ||
|
|
||
| const meta = { | ||
| component: Button, | ||
| args: { onClick: fn() }, | ||
| } satisfies Meta<typeof Button>; | ||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Primary: Story = { args: { primary: true, label: 'Button' } }; | ||
| export const Secondary: Story = { args: { label: 'Button' } }; | ||
| export const Large: Story = { args: { size: 'large', label: 'Button' } }; | ||
| export const Small: Story = { args: { size: 'small', label: 'Button' } };`, | ||
| ['./src/stories/Button.tsx']: dedent` | ||
| import React from 'react'; | ||
| export interface ButtonProps { | ||
| /** Description of primary */ | ||
| primary?: boolean; | ||
| backgroundColor?: string; | ||
| size?: 'small' | 'medium' | 'large'; | ||
| label: string; | ||
| onClick?: () => void; | ||
| } | ||
|
|
||
| /** | ||
| * Primary UI component for user interaction | ||
| * @import import { Button } from '@design-system/components/Button'; | ||
| */ | ||
| export const Button = ({ | ||
| primary = false, | ||
| size = 'medium', | ||
| backgroundColor, | ||
| label, | ||
| ...props | ||
| }: ButtonProps) => { | ||
| const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; | ||
| return ( | ||
| <button | ||
| type="button" | ||
| className={['storybook-button', \`storybook-button--\${size}\`, mode].join(' ')} | ||
| style={{ backgroundColor }} | ||
| {...props} | ||
| > | ||
| {label} | ||
| </button> | ||
| ); | ||
| };`, | ||
| ['./src/stories/Header.stories.ts']: dedent` | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { fn } from 'storybook/test'; | ||
| import Header from './Header'; | ||
|
|
||
| /** | ||
| * Description from meta and very long. | ||
| * @summary Component summary | ||
| * @import import { Header } from '@design-system/components/Header'; | ||
| */ | ||
| const meta = { | ||
| component: Header, | ||
| args: { | ||
| onLogin: fn(), | ||
| onLogout: fn(), | ||
| onCreateAccount: fn(), | ||
| } | ||
| } satisfies Meta<typeof Header>; | ||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
| export const LoggedIn: Story = { args: { user: { name: 'Jane Doe' } } }; | ||
| export const LoggedOut: Story = {}; | ||
| `, | ||
| ['./src/stories/Header.tsx']: dedent` | ||
| import { Button } from './Button'; | ||
|
|
||
| export interface HeaderProps { | ||
| user?: User; | ||
| onLogin?: () => void; | ||
| onLogout?: () => void; | ||
| onCreateAccount?: () => void; | ||
| } | ||
|
|
||
| /** | ||
| * @import import { Header } from '@design-system/components/Header'; | ||
| */ | ||
| export default ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => ( | ||
| <header> | ||
| <div className="storybook-header"> | ||
| <div> | ||
| {user ? ( | ||
| <> | ||
| <span className="welcome"> | ||
| Welcome, <b>{user.name}</b>! | ||
| </span> | ||
| <Button size="small" onClick={onLogout} label="Log out" /> | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <Button size="small" onClick={onLogin} label="Log in" /> | ||
| <Button primary size="small" onClick={onCreateAccount} label="Sign up" /> | ||
| </> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </header> | ||
| );`, | ||
| }; | ||
|
|
||
| export const indexJson = { | ||
| v: 5, | ||
| entries: { | ||
| 'example-button--primary': { | ||
| type: 'story', | ||
| subtype: 'story', | ||
| id: 'example-button--primary', | ||
| name: 'Primary', | ||
| title: 'Example/Button', | ||
| importPath: './src/stories/Button.stories.ts', | ||
| componentPath: './src/stories/Button.tsx', | ||
| tags: ['dev', 'test', 'vitest', 'autodocs'], | ||
| exportName: 'Primary', | ||
| }, | ||
| 'example-button--secondary': { | ||
| type: 'story', | ||
| subtype: 'story', | ||
| id: 'example-button--secondary', | ||
| name: 'Secondary', | ||
| title: 'Example/Button', | ||
| importPath: './src/stories/Button.stories.ts', | ||
| componentPath: './src/stories/Button.tsx', | ||
| tags: ['dev', 'test', 'vitest', 'autodocs'], | ||
| exportName: 'Secondary', | ||
| }, | ||
| 'example-button--large': { | ||
| type: 'story', | ||
| subtype: 'story', | ||
| id: 'example-button--large', | ||
| name: 'Large', | ||
| title: 'Example/Button', | ||
| importPath: './src/stories/Button.stories.ts', | ||
| componentPath: './src/stories/Button.tsx', | ||
| tags: ['dev', 'test', 'vitest', 'autodocs'], | ||
| exportName: 'Large', | ||
| }, | ||
| 'example-button--small': { | ||
| type: 'story', | ||
| subtype: 'story', | ||
| id: 'example-button--small', | ||
| name: 'Small', | ||
| title: 'Example/Button', | ||
| importPath: './src/stories/Button.stories.ts', | ||
| componentPath: './src/stories/Button.tsx', | ||
| tags: ['dev', 'test', 'vitest', 'autodocs'], | ||
| exportName: 'Small', | ||
| }, | ||
| 'example-header--docs': { | ||
| id: 'example-header--docs', | ||
| title: 'Example/Header', | ||
| name: 'Docs', | ||
| importPath: './src/stories/Header.stories.ts', | ||
| type: 'docs', | ||
| tags: ['dev', 'test', 'vitest', 'autodocs'], | ||
| storiesImports: [], | ||
| }, | ||
| 'example-header--logged-in': { | ||
| type: 'story', | ||
| subtype: 'story', | ||
| id: 'example-header--logged-in', | ||
| name: 'Logged In', | ||
| title: 'Example/Header', | ||
| importPath: './src/stories/Header.stories.ts', | ||
| componentPath: './src/stories/Header.tsx', | ||
| tags: ['dev', 'test', 'vitest', 'autodocs'], | ||
| exportName: 'LoggedIn', | ||
| }, | ||
| 'example-header--logged-out': { | ||
| type: 'story', | ||
| subtype: 'story', | ||
| id: 'example-header--logged-out', | ||
| name: 'Logged Out', | ||
| title: 'Example/Header', | ||
| importPath: './src/stories/Header.stories.ts', | ||
| componentPath: './src/stories/Header.tsx', | ||
| tags: ['dev', 'test', 'vitest', 'autodocs'], | ||
| exportName: 'LoggedOut', | ||
| }, | ||
| }, | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.