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: Canvas stories #19804

Merged
merged 12 commits into from
Nov 16, 2022
Merged

Blocks: Canvas stories #19804

merged 12 commits into from
Nov 16, 2022

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Nov 11, 2022

This PR adds stories for the Canvas block, both for current features and deprecated features.

Most notably, Having non-story elements/components within a Canvas as well as having multiple stories is being soft-deprecated. This means that we won't be documenting it officially (so in this PR the stories for those use cases are internal, and not in the public Blocks SB), but because we haven't quite figured out the migration path off of this yet* we aren't showing any deprecation warnings yet. This was discussed with @shilman, but I'm open to any input.

* the migration path is likely the variants feature, which won't land for a while.

@JReinhold JReinhold self-assigned this Nov 11, 2022
@JReinhold JReinhold added documentation maintenance User-facing maintenance tasks labels Nov 11, 2022
};

// TODO: what is the purpose of mdxSource exactly?
export const WithMdxSource: Story = {
Copy link
Contributor Author

@JReinhold JReinhold Nov 11, 2022

Choose a reason for hiding this comment

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

The mdxSource prop should be deprecated (and moved to internal stories) and renamed to something that falls in line with the naming in parameters, so source or code. I haven't quite figured out what the difference between the two yet.

any thoughts @tmeasday @shilman ?

withSource?: SourceState;
mdxSource?: string;
};

const getPreviewProps = (
const usePreviewProps = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turned out this was actually a hook, just not named as such (which surfaced errors)

withSource?: SourceState;
mdxSource?: string;
};

const getPreviewProps = (
const usePreviewProps = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The diff for this function may seem like a lot, but it maintains the exact same functionality and logic, it's just a refactoring. The refactoring was sparked by the need for useSourceProps hook to be called unconditionally, and so in an attempt to figure the whole thing out I simplified the logic paths.

@@ -89,7 +89,7 @@ const getSnippet = (snippet: string, story?: Store_Story<any>): string => {
type SourceStateProps = { state: SourceState };
type PureSourceProps = ComponentProps<typeof PureSource>;

export const getSourceProps = (
export const useSourceProps = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also a hook, actually.

@JReinhold JReinhold marked this pull request as ready for review November 11, 2022 12:43
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.

This is great, love the tests.

@JReinhold JReinhold merged commit 33d17b2 into next Nov 16, 2022
@JReinhold JReinhold deleted the jeppe/sb-898-blocks-canvas branch November 16, 2022 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants