2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
2016-11-04 20:00:56 +01:00
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
const TabBar = (props) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { tabs = [], onSelect, isActive } = props;
|
2016-11-04 20:00:56 +01:00
|
|
|
|
2019-12-06 16:40:07 +01:00
|
|
|
return (
|
|
|
|
<div className="tab-bar">
|
|
|
|
{tabs.map(({ key, content, description }) => (
|
2020-11-05 19:05:41 +01:00
|
|
|
<button
|
2019-12-06 16:40:07 +01:00
|
|
|
key={key}
|
|
|
|
className={classnames('tab-bar__tab pointer', {
|
|
|
|
'tab-bar__tab--active': isActive(key, content),
|
|
|
|
})}
|
|
|
|
onClick={() => onSelect(key)}
|
|
|
|
>
|
|
|
|
<div className="tab-bar__tab__content">
|
|
|
|
<div className="tab-bar__tab__content__title">{content}</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="tab-bar__tab__content__description">
|
|
|
|
{description}
|
|
|
|
</div>
|
2019-03-25 17:13:23 +01:00
|
|
|
</div>
|
2019-12-06 16:40:07 +01:00
|
|
|
<div className="tab-bar__tab__caret" />
|
2020-11-05 19:05:41 +01:00
|
|
|
</button>
|
2019-12-06 16:40:07 +01:00
|
|
|
))}
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
};
|
2017-06-14 02:47:56 +02:00
|
|
|
|
2017-11-02 03:30:33 +01:00
|
|
|
TabBar.propTypes = {
|
2017-11-29 05:24:35 +01:00
|
|
|
isActive: PropTypes.func.isRequired,
|
2017-11-02 03:30:33 +01:00
|
|
|
tabs: PropTypes.array,
|
2017-11-29 05:24:35 +01:00
|
|
|
onSelect: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2017-11-02 03:30:33 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export default TabBar;
|