Last active
June 4, 2018 03:27
-
-
Save esr360/1e7c717fe25e9ab1ae37aa49cb96ad26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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