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

Supports for tags in <Meta/> #134

Merged
merged 3 commits into from
Sep 16, 2023
Merged

Conversation

j3rem1e
Copy link
Contributor

@j3rem1e j3rem1e commented Aug 30, 2023

Storybook v7 supports tag on the meta property. However, tags should be set on the story indexer to be seen by the autodocs feature. The only tag used today by storybook is autodocsAFAIK.

This PR add supports for tags and an alias to a 'autodocs' property. Tags can only be specified as a static property, because it should be build by parsing the AST.

Examples:

<Meta title="XX" autodocs/>
<Meta title="XX" tags="autodocs"/>
<Meta title="XX" tags={['autodocs', 'a', 'b']}/>

@j3rem1e j3rem1e added enhancement New feature or request patch Increment the patch version when merged labels Aug 30, 2023
@benmccann
Copy link
Contributor

Cool! Just FYI, @JReinhold had another idea regarding Meta as well: #135

@j3rem1e
Copy link
Contributor Author

j3rem1e commented Sep 13, 2023

@JReinhold are you Ok with theses changes ? thanks !

@benmccann benmccann linked an issue Sep 14, 2023 that may be closed by this pull request
Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

Awesome! This is exciting!

src/index.d.ts Outdated Show resolved Hide resolved
src/index.d.ts Outdated Show resolved Hide resolved
src/parser/collect-stories.ts Outdated Show resolved Hide resolved
@benmccann
Copy link
Contributor

@j3rem1e just a quick heads up that there's a merge conflict

@j3rem1e
Copy link
Contributor Author

j3rem1e commented Sep 14, 2023

It should be good now. And I included your changes

@j3rem1e j3rem1e merged commit 6fba9d8 into storybookjs:main Sep 16, 2023
1 check passed
@shilman
Copy link
Member

shilman commented Sep 16, 2023

🚀 PR was released in v4.0.7 🚀

@shilman shilman added the released This issue/pull request has been released. label Sep 16, 2023
@shilman
Copy link
Member

shilman commented Sep 16, 2023

🚀 PR was released in v4.0.7 🚀

1 similar comment
@shilman
Copy link
Member

shilman commented Sep 16, 2023

🚀 PR was released in v4.0.7 🚀

@nickgroenewegen
Copy link

I'm not sure if this is the correct place to mention this but since this PR was released only a few days ago i am hoping this would get noticed.

Using the express meta as JS results in a error: 'TypeError: Cannot read properties of undefined (reading 'DefaultExample')'

Eg:

<script content="module">
	import { Story } from '@storybook/addon-svelte-csf';
	import Example from './example.svelte'

	export const meta = {
		title: 'Components/Example',
		component: Example
	}
</script>

<Story name="Default example">
	<Example />
</Story>

When using the depreated <Meta /> everything works as expected. Eg:

<script content="module">
	import { Story, Meta } from '@storybook/addon-svelte-csf';
	import Example from './example.svelte'
</script>

<Meta component={Example} title="Components/Example" />

<Story name="Default example">
	<Example />
</Story>

This happens right after a clean install of a sveltekit app. A repository that showcases this can be found here

I'm not sure if this is a mismatch in configuration or a possible bug?

@j3rem1e
Copy link
Contributor Author

j3rem1e commented Sep 19, 2023

Thanks for reporting it. I'll check that.

@j3rem1e
Copy link
Contributor Author

j3rem1e commented Sep 19, 2023

@nickgroenewegen

It's a typo on the documentation. It's not <script content="module">. but <script context="module">.

@nickgroenewegen
Copy link

@j3rem1e Ah yes. I literally took over what was on the documentation and did not notice it :), thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request patch Increment the patch version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Express meta as JS [Bug] Can't set tags on <Meta> component to enable fine-grained autodocs
4 participants