2020-06-11 09:07:46 +00:00
|
|
|
import React from 'react';
|
2019-01-18 17:17:48 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import classnames from 'classnames';
|
2020-06-11 09:07:46 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2019-01-18 17:17:48 +00:00
|
|
|
|
2020-06-11 09:07:46 +00:00
|
|
|
const Tab = ({
|
|
|
|
|
activeTabLabel, label, title, onClick,
|
|
|
|
|
}) => {
|
|
|
|
|
const [t] = useTranslation();
|
|
|
|
|
const handleClick = () => onClick(label);
|
2019-01-18 17:17:48 +00:00
|
|
|
|
2020-06-11 09:07:46 +00:00
|
|
|
const tabClass = classnames({
|
|
|
|
|
tab__control: true,
|
|
|
|
|
'tab__control--active': activeTabLabel === label,
|
|
|
|
|
});
|
2019-01-18 17:17:48 +00:00
|
|
|
|
2020-06-11 09:07:46 +00:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={tabClass}
|
|
|
|
|
onClick={handleClick}
|
|
|
|
|
>
|
|
|
|
|
<svg className="tab__icon">
|
|
|
|
|
<use xlinkHref={`#${label.toLowerCase()}`} />
|
|
|
|
|
</svg>
|
|
|
|
|
{t(title || label)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
2019-01-18 17:17:48 +00:00
|
|
|
|
|
|
|
|
Tab.propTypes = {
|
2020-06-11 09:07:46 +00:00
|
|
|
activeTabLabel: PropTypes.string.isRequired,
|
2019-01-18 17:17:48 +00:00
|
|
|
label: PropTypes.string.isRequired,
|
|
|
|
|
onClick: PropTypes.func.isRequired,
|
2019-07-02 12:45:39 +00:00
|
|
|
title: PropTypes.string,
|
2019-01-18 17:17:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Tab;
|