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

fix: add prefix to packages story titles #252

Merged
merged 2 commits into from
Oct 24, 2024
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
2 changes: 0 additions & 2 deletions apps/docsite/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"options": {
"port": 4400,
"configDir": "apps/docsite/.storybook",
"docs": true,
"docsMode": true
},
"configurations": {
Expand All @@ -28,7 +27,6 @@
"options": {
"outputDir": "dist/storybook/docsite",
"configDir": "apps/docsite/.storybook",
"docs": true,
"docsMode": true
},
"configurations": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: make stories title consistent with other packages",
"packageName": "@fluentui-contrib/react-keytips",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Meta } from '@storybook/react';
import type { Meta } from '@storybook/react';
import { <%= componentName %> } from '<%= npmScope %>/<%= name %>';
export { Default } from './Default.stories';

const meta: Meta<typeof <%= componentName %>> = {
const meta = {
title: 'Packages/<%= name %>/<%= componentName %>',
component: <%= componentName %>,
};
} satisfies Meta<typeof <%= componentName %>>;
Copy link
Contributor

@mainframev mainframev Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not completely within PR scope, but If this is becoming a standard for this repo, maybe it's worth to quickly align meta types in all packages? Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's standard set by official storybook docs, maybe they have it as a rule within their plugin ( https://github.com/storybookjs/eslint-plugin-storybook - they dont 🥹 )

  • please open issue on core repo to implement this enforcement within workspace eslint-rules, once done we can fast-forward to future eslint-plugin-react-components and use it here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


export default meta;
31 changes: 25 additions & 6 deletions packages/nx-plugin/src/generators/component/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('component generator', () => {
let tree: Tree;
const options: ComponentGeneratorSchema = {
name: 'hello-world',
componentName: 'foo',
componentName: 'Foo',
};

beforeEach(async () => {
Expand All @@ -30,23 +30,42 @@ describe('component generator', () => {

expect(
tree.children(
joinPathFragments(config.sourceRoot as string, 'components/foo')
joinPathFragments(config.sourceRoot as string, 'components/Foo')
)
).toMatchInlineSnapshot(`
[
"foo.styles.ts",
"foo.test.tsx",
"foo.tsx",
"Foo.styles.ts",
"Foo.test.tsx",
"Foo.tsx",
"index.ts",
]
`);

expect(tree.children(joinPathFragments(config.root, 'stories/foo')))
expect(tree.children(joinPathFragments(config.root, 'stories/Foo')))
.toMatchInlineSnapshot(`
[
"Default.stories.tsx",
"index.stories.tsx",
]
`);

const story = tree.read(
joinPathFragments(config.root, 'stories/Foo/index.stories.tsx'),
'utf8'
);

expect(story).toMatchInlineSnapshot(`
"import type { Meta } from '@storybook/react';
import { Foo } from '@fluentui-contrib/hello-world';
export { Default } from './Default.stories';
const meta = {
title: 'Packages/hello-world/Foo',
component: Foo,
} satisfies Meta<typeof Foo>;
export default meta;
"
`);
});
});
2 changes: 1 addition & 1 deletion packages/react-keytips/stories/index.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export { DynamicStory as Dynamic } from './Dynamic.stories';
export { OverflowStory as Overflow } from './OverflowMenu.stories';

const meta = {
title: 'Keytips',
title: 'Packages/react-keytips',
component: Keytips,
} satisfies Meta<typeof Keytips>;

Expand Down