Skip to content

Instantly share code, notes, and snippets.

@esr360
Last active June 4, 2018 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esr360/1e7c717fe25e9ab1ae37aa49cb96ad26 to your computer and use it in GitHub Desktop.
Save esr360/1e7c717fe25e9ab1ae37aa49cb96ad26 to your computer and use it in GitHub Desktop.
Accordion.defaultProps = {
name: 'accordion'
};
class Accordion extends React.Component {
toggle(event) {
const panel = event.target.closest.component('panel');
const operator = panel.modifier('active') ? 'unset' : 'set';
panel.modifier('active', operator);
}
render() {
return (
<Module {...this.props}>
{this.props.panels.map(({ title, content }, index) => (
<Component name='panel' key={index}>
<Component name='title' onClick={this.toggle}>{title}</Component>
<Component name='content'>{content}</Component>
</Component>
))}
</Module>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment