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

Feat: Component Metadata #435

Merged
merged 1 commit into from
May 11, 2017
Merged

Feat: Component Metadata #435

merged 1 commit into from
May 11, 2017

Conversation

dotcs
Copy link
Contributor

@dotcs dotcs commented May 10, 2017

Metadata

This PR allows to add metadata to components.

Each component, e.g. Button, can have an additional file named componentName + '.json', e.g. Button.json, which defines an object that includes metadata for the component.

Metadata can be fully controlled by the users with two constrains:

  1. JSON root must be a object
  2. Metadata key tags is reserved for the tag-system described below

Metadata of the component is read by processComponent and passed to all renderer components, such that users can re-use their own metadata definitions in custom implementations of the renderer components. This gives the users a large flexibility in order to categorise or further describe components.

Tag system (won't be implemented)

This PR also implements a tag system. The tags-keyword in the metadata of a component must be an array of strings. Each tag describes the component and can be used when filtering components.

Say we have the following metadata information for Button:

Button.json

{
  "tags": ["atom", "interactive"]
}

The list of tags is rendered for each component by the ReactComponentRenderer.

Also the implementation for filtering components has been adjusted to take care of the tag information provided in the metadata. Filtering for atom yields Button as a result because it has been tagged as such.

TODO

  • Implement metadata parsing
  • Provide list and list-item renderer for tag list and use them in ReactComponentRenderer
  • Provide styling for list and list-item renderer
  • Add tests for tag support
  • Add tests for some custom metadata properties
  • Add documentation for metadata

@sapegin
Copy link
Member

sapegin commented May 10, 2017

Thanks for the pull request @dotcs! I like the idea of metadata but I think tag rendering and filtering should be a plugin, so I invite you to discuss possible plugin API for Styleguidist: #354.

Another idea that could use similar API: #421.

@dotcs
Copy link
Contributor Author

dotcs commented May 10, 2017

@sapegin So should I throw away render + filter and keep the metadata parser step or would you say everything including metadata should plugins?
Since a plugin system is planned I would be fine with both ways, so it's up to you.

@sapegin
Copy link
Member

sapegin commented May 10, 2017

I’d keep the metadata reader without special treatment for tags.

And any input on plugins API is very much appreciated ;-) It’s still planned because nobody really knows what to do ;-)

@sapegin
Copy link
Member

sapegin commented May 11, 2017

Should I merge it or you’re planning to do something else in this PR?

@dotcs
Copy link
Contributor Author

dotcs commented May 11, 2017

I'd like to add some tests for some filled metadata object if possible. I haven't had enough time to do this yet. I'll let you know when I'm done.

@sapegin
Copy link
Member

sapegin commented May 11, 2017

Sounds good ;-)

@dotcs dotcs changed the title (WIP) Feat: Component Metadata Feat: Component Metadata May 11, 2017
@dotcs
Copy link
Contributor Author

dotcs commented May 11, 2017

@sapegin Done. Should we add further documentation of this feature? Currently it's only documented via the customised sample application (and by the unit tests). Should we add further documentation for users? Maybe you can add documentation because you know best where to put it. Besides that the PR is ready to merge. :)

@sapegin
Copy link
Member

sapegin commented May 11, 2017

Thanks, I’ll add some docs later ;-)

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