Files
weave-scope/client/app/scripts/components/show-more.js
2017-10-17 19:07:14 +02:00

32 lines
876 B
JavaScript

import React from 'react';
export default class ShowMore extends React.PureComponent {
constructor(props, context) {
super(props, context);
this.handleClick = this.handleClick.bind(this);
}
handleClick(ev) {
ev.preventDefault();
this.props.handleClick();
}
render() {
const {
collection, notShown, expanded, hideNumber
} = this.props;
const showLimitAction = collection && (expanded || notShown > 0);
const limitActionText = !hideNumber && !expanded && notShown > 0 ? `+${notShown}` : '';
const limitActionIcon = !expanded && notShown > 0 ? 'fa fa-caret-down' : 'fa fa-caret-up';
if (!showLimitAction) {
return <span />;
}
return (
<div className="show-more" onClick={this.handleClick}>
{limitActionText} <span className={`show-more-icon ${limitActionIcon}`} />
</div>
);
}
}