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

Added information about the Accordion to the README of components #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,42 @@ function header = (props) => {
);
}
```
# Accordion

### Props


| Name |Type | Default | Description |
| ------------- |:-------------:| --- | ---- |
| border|`bool`| false | Border of the Accordion |
| children | `Reactnode` | |Children to render inside Accordion|
| open|`bool`| false | Determines if the accordion is currently open or closed |
| title |`string`| | Title of the Accordion |

```
<div className={`accordion ${this.props.border ? 'border' : ''}`}>
Copy link
Collaborator

@jomadoye jomadoye Apr 10, 2019

Choose a reason for hiding this comment

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

Thanks for this PR @paulvazbad.
I believe adding the full HTML of the component to the documentation would make the readME too bulky and tough to read.
Good code should be self-documenting so we can skip this part.

We should focus on documenting the props the components use, which is what you have done.
Thanks.

cc @rhenshaw56 what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I agree @jomadoye ... I think having sample HTML of how to use the component could be helpful, but it looks like this an example of the code generated by the component?

Are there any best practices for React component comments... I see a generation tool that appears to be popular:

https://github.com/styleguidist/react-styleguidist

For what it's worth, here's the format I came up with for the one component I actually documented:

https://github.com/openmrs/openmrs-react-components/blob/master/src/components/list/List.jsx#L7

I'm not necessarily married to that format (or any other), but would be great to pick a format and standardize on it.

<div
className="header"
onClick={() => {
this.setState(() => ({ isVisible: !this.state.isVisible }));
}}
role="button"
tabIndex={0}
>
<a>
<span>
<img
className={`${this.state.isVisible ? 'rotate90' : ''}`}
height="12px"
src={Arrow}
width="12px"
/>
</span>&nbsp;&nbsp;
{this.props.title}
</a>
</div>
<div className={`content ${!this.state.isVisible ? 'close' : 'open'}`}>
{this.props.children}
</div>
</div>
```