dispatch/client/src/js/components/TabListItem.js

44 lines
948 B
JavaScript
Raw Normal View History

2015-12-28 23:34:32 +00:00
import React, { Component } from 'react';
import pure from 'pure-render-decorator';
@pure
export default class TabListItem extends Component {
2016-01-05 18:29:22 +00:00
handleClick = () => {
const { server, target, onClick } = this.props;
onClick(server, target);
};
2016-01-05 18:29:22 +00:00
2015-12-28 23:34:32 +00:00
render() {
2016-01-05 18:29:22 +00:00
const { target, content, selected } = this.props;
2015-12-28 23:34:32 +00:00
const classes = [];
2016-01-05 18:29:22 +00:00
if (!target) {
2015-12-28 23:34:32 +00:00
classes.push('tab-server');
}
2016-01-05 18:29:22 +00:00
if (selected) {
2015-12-28 23:34:32 +00:00
classes.push('selected');
}
2016-01-13 17:53:54 +00:00
let indicator = null;
if (this.props.connected !== undefined) {
const style = {};
if (this.props.connected) {
style.background = '#6BB758';
} else {
style.background = '#F6546A';
}
2017-02-16 02:55:50 +00:00
indicator = <i className="tab-indicator" style={style} />;
2016-01-13 17:53:54 +00:00
}
2015-12-28 23:34:32 +00:00
return (
2016-01-13 17:53:54 +00:00
<p className={classes.join(' ')} onClick={this.handleClick}>
<span className="tab-content">{content}</span>
{indicator}
</p>
2015-12-28 23:34:32 +00:00
);
}
}