Skip to content

Instantly share code, notes, and snippets.

@torryt
Created May 19, 2017 07:19
Show Gist options
  • Save torryt/6ef6e85e4f5b404d0c5ceca62afdb00e to your computer and use it in GitHub Desktop.
Save torryt/6ef6e85e4f5b404d0c5ceca62afdb00e to your computer and use it in GitHub Desktop.
getExplanationSection() {
const explanation = this.props.explanation;
if (explanation !== undefined) {
return (
<div onClick={() => this.setState({ expanded: !this.state.expanded })}>
<section className={'nokkeltall-explanation'}>
{explanation}
</section>
</div>
);
}
}
render() {
const { value, title, subtitle } = this.props;
const expanded = this.state.expanded;
return (
<article className='nokkeltall'>
<section className='nokkeltall-content'>
<div className='nokkeltall-number'>{nokkeltallValueFormat(value)}</div>
<h3 className='nokkeltall-subtitle'>{subtitle}</h3>
<h2 className='nokkeltall-title'>{title}</h2>
</section>
{this.getExplanationSection()}
<button className='nokkeltall-expand-icon'>
{expanded
? <i className='icon-up-open-big'></i>
: <i className='icon-down-open-big'></i>
}
</button>
</article>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment