Files
weave-scope/client/app/scripts/components/show-more.js
David Kaltschmidt eed779abfa Replaced pure-render-mixin with redux connect
* does the same shallowEqual optimization
2016-04-28 20:20:58 +02:00

34 lines
924 B
JavaScript

import React from 'react';
import { connect } from 'react-redux';
class ShowMore extends React.Component {
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>
);
}
}
export default connect()(ShowMore);