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
|
|
|
|
2023-04-04 18:48:04 +02:00
|
|
|
import {
|
|
|
|
Icon,
|
|
|
|
ICON_NAMES,
|
|
|
|
ICON_SIZES,
|
|
|
|
} from '../../component-library/icon/deprecated';
|
2022-03-08 22:50:35 +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">
|
2022-02-08 17:30:20 +01:00
|
|
|
{tabs.map(({ key, content, icon }) => (
|
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">
|
2022-02-08 17:30:20 +01:00
|
|
|
<div className="tab-bar__tab__content__icon">{icon}</div>
|
2022-02-09 18:49:41 +01:00
|
|
|
<div className="tab-bar__tab__content__title">{content}</div>
|
2019-03-25 17:13:23 +01:00
|
|
|
</div>
|
2023-02-16 14:26:14 +01:00
|
|
|
<Icon
|
|
|
|
name={ICON_NAMES.ARROW_RIGHT}
|
|
|
|
size={ICON_SIZES.SM}
|
|
|
|
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;
|