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

docs: add edit mode for stories in docs page #2043

Conversation

YossiSaadi
Copy link
Contributor

@YossiSaadi YossiSaadi commented Mar 31, 2024

https://monday.monday.com/boards/3532714909/pulses/5898424178

API:

  • parameters.docs.liveEdit structure:
liveEdit?: {
  scope?: Record<string, unknown>;
  isEnabled?: boolean;
};

scope can be any component or helper function.
so, it can be someText var that is a string
and it can be a component
whatever which is a key-value obj that you want the react-live's preview to know

The only thing needs to be done to enable LiveEdit for an existing component is simply removing the Canvas import in the MDX
If you'd like to disable for specific story (e.g. the Overview story), just set in its CSF the isEnabled: false

Mar-31-2024 20-29-08

@YossiSaadi YossiSaadi requested a review from a team as a code owner March 31, 2024 17:25
prettier fails because the parsing method at withLiveEdit is currently not generic enough
Copy link
Member

@talkor talkor 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 freaking amazing!!!! 👑 💯 💪🏼


const toggleCodeAction = useMemo(
() => ({
title: "Toggle code editor",
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: call it "Play"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just like that? Play?
It opens and shut the live editor, not sure about Play

code={code}
theme={vscodeDark}
extensions={[langs.tsx()]}
style={{ fontSize: 13 }}
Copy link
Member

Choose a reason for hiding this comment

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

On purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I want it to look same as Source, that's why I chose this theme and font size, to mimic as best as possible

@YossiSaadi YossiSaadi merged commit 0082caf into master Apr 7, 2024
10 checks passed
@YossiSaadi YossiSaadi deleted the docs/yossi/Add-edit-mode-for-Storybooks-Docs-page-Stories-5898424178 branch April 7, 2024 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants