Skip to content

Instantly share code, notes, and snippets.

@SilencerWeb
Last active January 4, 2018 15:59
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 SilencerWeb/23f62b3d51c18f9731ae02f81402cc3d to your computer and use it in GitHub Desktop.
Save SilencerWeb/23f62b3d51c18f9731ae02f81402cc3d to your computer and use it in GitHub Desktop.
state = {
glossary: [
{
name: 'Altcoins',
description: 'The “alt” means “alternative” and “coins” mean other cryptocurrencies. These are, in essence, alternative to the Bitcoin, and have a lower value on the market. E.g: Ethereum, Litecoin, Dogecoin.',
isOpened: false
},
{
name: 'Altcoins',
description: 'The “alt” means “alternative” and “coins” mean other cryptocurrencies. These are, in essence, alternative to the Bitcoin, and have a lower value on the market. E.g: Ethereum, Litecoin, Dogecoin.',
isOpened: false
},
{
name: 'Altcoins',
description: 'The “alt” means “alternative” and “coins” mean other cryptocurrencies. These are, in essence, alternative to the Bitcoin, and have a lower value on the market. E.g: Ethereum, Litecoin, Dogecoin.',
isOpened: false
}
]
}
toggle (index) => {
const glossary = this.state.glossary.map((item, i) => {
return i === index ? item.isOpened : !item.isOpened
})
this.setState({glossary:glossary})
}
render() {
const Item = this.state.glossary.map((item, i) =>
<div className='glossary-item glossary-item' onClick={() => this.toggle(i)} key={i}>
<div className="glossary-item__definition">{item.name}</div>
<div className="glossary-item__description" >{item.description}</div>
</div>
)
return (
<div className="glossary">
{Item}
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment