badguardhome/client/src/components/ui/Tab.js

44 lines
1010 B
JavaScript
Raw Normal View History

2019-01-18 17:17:48 +00:00
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
class Tab extends Component {
handleClick = () => {
this.props.onClick(this.props.label);
}
render() {
const {
activeTab,
label,
title,
2019-01-18 17:17:48 +00:00
} = this.props;
const tabClass = classnames({
tab__control: true,
'tab__control--active': activeTab === label,
});
return (
<div
className={tabClass}
onClick={this.handleClick}
>
2019-01-22 14:17:33 +00:00
<svg className="tab__icon">
2019-01-18 17:17:48 +00:00
<use xlinkHref={`#${label.toLowerCase()}`} />
</svg>
{title || label}
2019-01-18 17:17:48 +00:00
</div>
);
}
}
Tab.propTypes = {
activeTab: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
title: PropTypes.string,
2019-01-18 17:17:48 +00:00
};
export default Tab;