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-19 23:16:49 +02:00
|
|
|
import { Icon, IconName, IconSize } from '../../component-library';
|
2023-05-23 20:29:00 +02:00
|
|
|
import Box from '../../ui/box';
|
|
|
|
import {
|
|
|
|
BorderRadius,
|
|
|
|
Color,
|
|
|
|
DISPLAY,
|
|
|
|
} from '../../../helpers/constants/design-system';
|
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 }) => (
|
2023-05-23 20:29:00 +02:00
|
|
|
<Box
|
|
|
|
as="button"
|
2019-12-06 16:40:07 +01:00
|
|
|
key={key}
|
2023-05-23 20:29:00 +02:00
|
|
|
paddingTop={5}
|
|
|
|
paddingBottom={5}
|
|
|
|
paddingLeft={4}
|
|
|
|
paddingRight={4}
|
2019-12-06 16:40:07 +01:00
|
|
|
className={classnames('tab-bar__tab pointer', {
|
|
|
|
'tab-bar__tab--active': isActive(key, content),
|
|
|
|
})}
|
|
|
|
onClick={() => onSelect(key)}
|
|
|
|
>
|
2023-05-23 20:29:00 +02:00
|
|
|
{isActive(key, content) && (
|
|
|
|
<Box
|
|
|
|
className="tab-bar__tab__selected-indicator"
|
|
|
|
borderRadius={BorderRadius.pill}
|
|
|
|
backgroundColor={Color.primaryDefault}
|
|
|
|
display={[DISPLAY.NONE, DISPLAY.BLOCK]}
|
|
|
|
/>
|
|
|
|
)}
|
2019-12-06 16:40:07 +01:00
|
|
|
<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
|
2023-04-19 23:16:49 +02:00
|
|
|
name={IconName.ArrowRight}
|
|
|
|
size={IconSize.Sm}
|
2023-02-16 14:26:14 +01:00
|
|
|
className="tab-bar__tab__caret"
|
|
|
|
/>
|
2023-05-23 20:29:00 +02:00
|
|
|
</Box>
|
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;
|