Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a5f4646
Add automatic component imports
kasperpeulen Oct 31, 2025
17a3089
Add automatic component imports
kasperpeulen Oct 31, 2025
9331bf7
Improve
kasperpeulen Oct 31, 2025
2b072ba
Use the package.json belonging to the story
kasperpeulen Nov 1, 2025
835417c
Get fallback components to work
kasperpeulen Nov 1, 2025
8ba3b0b
Refactor
kasperpeulen Nov 1, 2025
8d40e43
Fix type
kasperpeulen Nov 1, 2025
ce25a2f
Fix type
kasperpeulen Nov 1, 2025
7e9a30a
Fix type
kasperpeulen Nov 1, 2025
acf5925
Fix tests
kasperpeulen Nov 1, 2025
2a05fc4
Cleanup react docgen
kasperpeulen Nov 3, 2025
3de6fad
Cleanup react docgen integration
kasperpeulen Nov 3, 2025
80b0ad2
Cleanup getComponentImports
kasperpeulen Nov 3, 2025
08bdc82
Fix
kasperpeulen Nov 3, 2025
8151722
Refactor
kasperpeulen Nov 3, 2025
50be8d7
Filter by manifest tag and include story descriptions/summaries
kasperpeulen Nov 3, 2025
70e8504
Fix auto imports
kasperpeulen Nov 3, 2025
7ab7295
Fix tests
kasperpeulen Nov 3, 2025
d9cc661
Better barrel file support
kasperpeulen Nov 3, 2025
e235682
Prettier
kasperpeulen Nov 4, 2025
3f0b505
Refactor tests
kasperpeulen Nov 4, 2025
f06a97e
Fix lint
kasperpeulen Nov 4, 2025
946327d
Fix feedback
kasperpeulen Nov 4, 2025
10ef28f
Fix feedback
kasperpeulen Nov 4, 2025
8f96d8c
Fix feedback
kasperpeulen Nov 4, 2025
41d93f3
Fix
kasperpeulen Nov 4, 2025
26bbbda
Refactor
kasperpeulen Nov 4, 2025
5e59d7a
Refactor
kasperpeulen Nov 4, 2025
f4caa77
Clean up
kasperpeulen Nov 4, 2025
2780b84
Pretty
kasperpeulen Nov 4, 2025
68d91cf
Fix title
kasperpeulen Nov 4, 2025
688057b
Feedback
kasperpeulen Nov 4, 2025
7763851
Better basedir for tsconfig resolution
kasperpeulen Nov 4, 2025
8829d71
Merge remote-tracking branch 'origin/next' into kasper/manifest-auto-…
kasperpeulen Nov 4, 2025
947c37e
Address feedback
kasperpeulen Nov 4, 2025
6f87e22
Address feedback
kasperpeulen Nov 4, 2025
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
Prev Previous commit
Next Next commit
Fix title
  • Loading branch information
kasperpeulen committed Nov 4, 2025
commit 68d91cf99bf5dfde4285dd046ce02f85687b2acc
11 changes: 7 additions & 4 deletions code/renderers/react/src/componentManifest/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const componentManifestGenerator: PresetPropertyFn<
return;
}
const componentName = csf._meta?.component;
const title = entry.title.replace(/\s+/g, '');

const id = entry.id.split('--')[0];
const importPath = entry.importPath;
Expand All @@ -67,12 +66,14 @@ export const componentManifestGenerator: PresetPropertyFn<
storyFilePath: absoluteImportPath,
});

const trimmedTitle = entry.title.replace(/\s+/g, '');

const component = components.find((it) => {
return componentName
? [it.componentName, it.localImportName, it.importName].includes(componentName)
: title.includes(it.componentName) ||
(it.localImportName && title.includes(it.localImportName)) ||
(it.importName && title.includes(it.importName));
: trimmedTitle.includes(it.componentName) ||
(it.localImportName && trimmedTitle.includes(it.localImportName)) ||
(it.importName && trimmedTitle.includes(it.importName));
});

const stories = Object.keys(csf._stories)
Expand Down Expand Up @@ -107,6 +108,8 @@ export const componentManifestGenerator: PresetPropertyFn<

const imports = getImports({ components, packageName }).join('\n').trim() || fallbackImport;

const title = entry.title.split('/').at(-1)!.replace(/\s+/g, '');

const base = {
id,
name: componentName ?? title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ test('Namespace import with member usage', () => {
"importName": "Root",
"localImportName": "Accordion",
"namespace": "Accordion",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -107,7 +106,6 @@ test('Named import used as namespace object', () => {
"importId": "@ds/accordion",
"importName": "Accordion",
"localImportName": "Accordion",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -135,7 +133,6 @@ test('Default import', () => {
"importId": "@ds/button",
"importName": "default",
"localImportName": "Button",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -163,14 +160,12 @@ test('Alias named import and meta.component inclusion', () => {
"importId": "@ds/button",
"importName": "Button",
"localImportName": "Btn",
"path": undefined,
},
{
"componentName": "Other",
"importId": "@ds/button",
"importName": "Other",
"localImportName": "Other",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -198,7 +193,6 @@ test('Strip unused specifiers from the same import statement', () => {
"importId": "@ds/button",
"importName": "Button",
"localImportName": "Btn",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -226,7 +220,6 @@ test('Meta component with member and star import', () => {
"importName": "Root",
"localImportName": "Accordion",
"namespace": "Accordion",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -254,14 +247,12 @@ test('Keeps multiple named specifiers and drops unused ones from same import', (
"importId": "@ds/button",
"importName": "Button",
"localImportName": "Button",
"path": undefined,
},
{
"componentName": "ButtonGroup",
"importId": "@ds/button",
"importName": "ButtonGroup",
"localImportName": "ButtonGroup",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -289,7 +280,6 @@ test('Mixed default + named import: keep only default when only default used', (
"importId": "@ds/button",
"importName": "default",
"localImportName": "Button",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -317,7 +307,6 @@ test('Mixed default + named import: keep only named when only named (alias) used
"importId": "@ds/button",
"importName": "Button",
"localImportName": "Btn",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -346,7 +335,6 @@ test('Per-specifier type import is dropped when mixing with value specifiers', (
"importId": "@ds/button",
"importName": "Button",
"localImportName": "Button",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -375,15 +363,13 @@ test('Namespace import used for multiple members kept once', () => {
"importName": "A",
"localImportName": "DS",
"namespace": "DS",
"path": undefined,
},
{
"componentName": "DS.B",
"importId": "@ds/ds",
"importName": "B",
"localImportName": "DS",
"namespace": "DS",
"path": undefined,
},
],
"imports": [
Expand All @@ -410,7 +396,6 @@ test('Default import kept when referenced only via meta.component', () => {
"importId": "@ds/button",
"importName": "default",
"localImportName": "Button",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -439,7 +424,6 @@ test('Side-effect-only import is ignored', () => {
"importId": "@ds/button",
"importName": "Button",
"localImportName": "Button",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -675,7 +659,6 @@ test('Keeps relative import when packageName is missing', () => {
"importId": "./components/Button",
"importName": "Button",
"localImportName": "Button",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -703,11 +686,10 @@ test('Non-relative import remains unchanged even if packageName provided', () =>
"importId": "@ds/button",
"importName": "Button",
"localImportName": "Button",
"path": undefined,
},
],
"imports": [
"import { Button } from \"@ds/button\";",
"import { Button } from "@ds/button";",
],
}
`
Expand Down Expand Up @@ -738,42 +720,36 @@ test('Merges multiple imports from the same package (defaults and named)', () =>
"importId": "@primer/react",
"importName": "Banner",
"localImportName": "Banner",
"path": undefined,
},
{
"componentName": "CopilotIcon",
"importId": "@primer/octicons-react",
"importName": "CopilotIcon",
"localImportName": "CopilotIcon",
"path": undefined,
},
{
"componentName": "Dialog",
"importId": "@primer/react",
"importName": "Dialog",
"localImportName": "Dialog",
"path": undefined,
},
{
"componentName": "Heading",
"importId": "@primer/react",
"importName": "default",
"localImportName": "Heading",
"path": undefined,
},
{
"componentName": "Link",
"importId": "@primer/react",
"importName": "default",
"localImportName": "Link",
"path": undefined,
},
{
"componentName": "Stack",
"importId": "@primer/react",
"importName": "Stack",
"localImportName": "Stack",
"path": undefined,
},
],
"imports": [
Expand Down Expand Up @@ -805,22 +781,19 @@ test('Merges namespace with default and separates named for same package', () =>
"importId": "@primer/react",
"importName": "Banner",
"localImportName": "Banner",
"path": undefined,
},
{
"componentName": "Link",
"importId": ".",
"importName": "default",
"localImportName": "Link",
"path": undefined,
},
{
"componentName": "PR.Box",
"importId": "@primer/react",
"importName": "Box",
"localImportName": "PR",
"namespace": "PR",
"path": undefined,
},
],
"imports": [
Expand All @@ -845,7 +818,6 @@ test('Component not imported returns undefined importId and importName', () => {
"components": [
{
"componentName": "Missing",
"path": undefined,
},
],
"imports": [],
Expand All @@ -866,7 +838,6 @@ test('Namespace component not imported returns undefined importId and importName
"components": [
{
"componentName": "PR.Box",
"path": undefined,
},
],
"imports": [],
Expand Down
Loading