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

Blocks: new Description API, introduce useOf #20563

Merged
merged 27 commits into from
Jan 11, 2023

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Jan 10, 2023

#19964

This PR changes the Description block to work fully with the of API. It also introduces the useOf hook which is also meant as a public API.

  • Description block now accepts an of prop that is a reference to either a meta (default) export, a story export, or the whole CSF file (ie. import * as SomeStories from 'some.stories.tsx).
  • If Description is rendered without an of prop, it will look for a description on meta/component in attached mode and throw in unattached mode.
  • useOf returns a combination of the result of DocsContext.resolveModuleExport and DocsContext.store.projectAnnotations.

The docs for this are in progress, but if anyone wants to try this out immediately, the drafts can be read on this Notion page.

(reminding myself to remove this link when the docs are published, as this link will get stale)

Stories are a bit messy because we need different CSF files for testing different meta description setups, but I've tried to group it as best as possible.

To do

  • Primary story in autodocs?

@JReinhold JReinhold self-assigned this Jan 10, 2023
@JReinhold JReinhold added the maintenance User-facing maintenance tasks label Jan 10, 2023
@JReinhold
Copy link
Contributor Author

JReinhold commented Jan 10, 2023

@tmeasday note that the stories that rely on the comment on meta are actually wrong, because we aren't actually extracting meta comments right now. so they currently fall back to the component's description. But I want to do that in a follow up PR.

@JReinhold JReinhold marked this pull request as ready for review January 10, 2023 23:27
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Looks great. A couple final details to iron out.

code/ui/blocks/src/blocks/Description.tsx Outdated Show resolved Hide resolved
code/ui/blocks/src/blocks/Description.tsx Outdated Show resolved Hide resolved
code/ui/blocks/src/blocks/useOf.ts Show resolved Hide resolved
code/ui/blocks/src/blocks/Description.tsx Outdated Show resolved Hide resolved
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

LGTM, one very minor naming query

code/ui/blocks/src/blocks/Description.tsx Outdated Show resolved Hide resolved
@JReinhold JReinhold merged commit f7826d5 into next Jan 11, 2023
@JReinhold JReinhold deleted the block-description-improvements branch January 11, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants