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

Minimum display of a component: required props #21

Open
EdmundsEcho opened this issue Mar 23, 2021 · 3 comments
Open

Minimum display of a component: required props #21

EdmundsEcho opened this issue Mar 23, 2021 · 3 comments

Comments

@EdmundsEcho
Copy link

When I don't first remember how to instantiate a component, I have to look up the component to find the PropTypes property. The cosmos display just shows a blank screen.

Is there a way to display what the prop-types are/require? This would improve the workflow, and allow for more aggressive fixture making - the minute something goes wrong, instead of having to look at the console (sloooowww), I can just verify the work against the what is already presented by cosmos.

@ovidiuch
Copy link
Member

This would be nice to have, indeed. This is something we've considered since as long as 2016 I believe. I think in time people migrated to using TypeScript or Flow for static typing instead of PropTypes (runtime validation) so interest slowly declined.

@EdmundsEcho
Copy link
Author

Got it. Where would I look in the code base to assess feasibility? Low priority but if low hanging fruit I’d be happy to contribute.

@ovidiuch
Copy link
Member

ovidiuch commented Apr 4, 2021

Got it. Where would I look in the code base to assess feasibility? Low priority but if low hanging fruit I’d be happy to contribute.

I think the main part is figuring out how to extract the prop types from your component, which is decoupled from Cosmos. I think there are some existing projects for this but I can't recall what they are. I'd say find a solution that you're happy with for extracting the prop types into a simple data format first (like a JSON description that can be turned into a table view).

On the Cosmos side, the Playground UI is composed of many plugins. One example is the Props panel. The way plugin slots are composed is not documented, but I think that can be overlooked for now as 99% of the code is just React components composing each other.

If you're interested I would be up for a brief live conversation to hash out a potential plan and share more info about 1) what you're envision and 2) how to approach it. You can find me on Slack.

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

No branches or pull requests

2 participants