Last active
January 17, 2019 02:13
-
-
Save mattdaisley/ff2cbb7c1fb78ce4eb9e84a7bccc9be7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { Component } from 'react'; | |
import ExpansionPanelDetails from 'ui/core/ExpansionPanel/ExpansionPanelDetails/ExpansionPanelDetails'; | |
import ExpansionPanelSummary from 'ui/core/ExpansionPanel/ExpansionPanelSummary/ExpansionPanelSummary'; | |
import ExpansionPanel from 'ui/core/ExpansionPanel/ExpansionPanel'; | |
export default class ControlledExpansionPanel extends Component { | |
state = { | |
expanded: null, | |
}; | |
handleChange = (panel: string) => (expanded: boolean) => { | |
this.setState({ | |
expanded: expanded ? panel : false, | |
}); | |
}; | |
render() { | |
const { expanded } = this.state; | |
return ( | |
<React.Fragment> | |
<ExpansionPanel open={expanded === 'panel1'} onChange={this.handleChange('panel1')}> | |
<ExpansionPanelSummary>Expansion Panel 1</ExpansionPanelSummary> | |
<ExpansionPanelDetails> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, | |
sit amet blandit leo lobortis eget. | |
</ExpansionPanelDetails> | |
</ExpansionPanel> | |
<ExpansionPanel open={expanded === 'panel2'} onChange={this.handleChange('panel2')}> | |
<ExpansionPanelSummary>Expansion Panel 2</ExpansionPanelSummary> | |
<ExpansionPanelDetails> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, | |
sit amet blandit leo lobortis eget. | |
</ExpansionPanelDetails> | |
</ExpansionPanel> | |
</React.Fragment> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment