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

Source addon should behave more like the Controls addon #12822

Open
StJohn3D opened this issue Oct 19, 2020 · 6 comments
Open

Source addon should behave more like the Controls addon #12822

StJohn3D opened this issue Oct 19, 2020 · 6 comments

Comments

@StJohn3D
Copy link

Is your feature request related to a problem? Please describe
I love how I can add the 'controls' addon and edit controls for each story 💯
I also love how this seamlessly integrates with the 'docs' addon and when visiting the Docs page I see my changes reflected in the preview there as well 💯
The frustration happens when I want to see the generated code. Adding the 'storysource' addon does not have the same behavior as the 'controls' addon. With 'storysource' all I see is something like this:

(args) => <MyComponent {...args} />

Which isn't at all helpful. So as a consumer if I want to dynamically fiddle with controls and then see the generated code - I have to first edit controls for the story from the Controls tab in the addons panel in the Canvas page. Then know to go to the Docs page, possibly scroll to find the same story, and then expand the code preview. 😞

Describe the solution you'd like
I'd like it if the 'storysource' addon had more intuitive behavior by functioning like the controls addon. Where when added a Source or Code tab would appear in the addons panel. And that tab would essentially have the same generated output you see in the Docs page when clicking "Show Code".
It should also pull from the same story params so that when needed I can override the code output via

storyname.parameters = {
  docs: {
    source: {
      code: `some custom code output here`
    }
  }
}

Describe alternatives you've considered
I'm aware that with custom page templates I could manually set each story block with an 'ArgsTable' block. This would allow both editing toggles and seeing the generated code for each story from the 'Docs' page. However this would needlessly bloat the Docs page - especially for components with a lot of controls. Not to mention the amount of automation I'd be losing by giving up the 'Stories' block which is really convenient.

Are you able to assist to bring the feature to reality?
Possibly in the future but not at this time...

Additional context
The Source/Code block circled in red should be what the storysource addon displays
image

instead of this
image

@grimly
Copy link

grimly commented Nov 4, 2020

I would myself love the ability to generate the source code also from args. One would then be able to play with the ArgTable then copy the component he just created.

@shilman
Copy link
Member

shilman commented Nov 4, 2020

@grimly that's already working in addon-docs

@grimly
Copy link

grimly commented Nov 4, 2020

@shilman the mdxSource property of Canvas is a simple string, it cannot be changed depending on the args.

Maybe this feature request is not about what I need after all.

@shilman
Copy link
Member

shilman commented Nov 4, 2020

@grimly you can see it in action here #11332

it's improved quite a bit since the initial PR

@stale
Copy link

stale bot commented Dec 25, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Dec 25, 2020
@StJohn3D
Copy link
Author

No stale bot, this one is pinned :)

@stale stale bot removed the inactive label Dec 25, 2020
@shilman shilman removed the PN label Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants