2022-05-20 01:28:58 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Styled from './styles';
|
|
|
|
import Left from './left/component';
|
|
|
|
import Right from './right/component';
|
|
|
|
|
|
|
|
const Header = ({
|
|
|
|
leftButtonProps,
|
|
|
|
rightButtonProps,
|
|
|
|
customRightButton,
|
2022-06-08 02:52:22 +08:00
|
|
|
'data-test': dataTest,
|
2022-05-20 01:28:58 +08:00
|
|
|
}) => {
|
|
|
|
const renderCloseButton = () => (
|
|
|
|
<Right {...rightButtonProps} />
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderCustomRightButton = () => (
|
|
|
|
<Styled.RightWrapper>
|
|
|
|
{customRightButton}
|
|
|
|
</Styled.RightWrapper>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2022-06-08 02:52:22 +08:00
|
|
|
<Styled.Header data-test={dataTest ? dataTest : ''}>
|
2022-10-31 22:05:09 +08:00
|
|
|
{leftButtonProps ? <Left {...leftButtonProps} /> : <div />}
|
2022-05-20 01:28:58 +08:00
|
|
|
{customRightButton
|
|
|
|
? renderCustomRightButton()
|
|
|
|
: rightButtonProps
|
|
|
|
? renderCloseButton()
|
|
|
|
: null}
|
|
|
|
</Styled.Header>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Header.propTypes = {
|
|
|
|
leftButtonProps: PropTypes.object,
|
|
|
|
rightButtonProps: PropTypes.object,
|
|
|
|
customRightButton: PropTypes.element,
|
2022-06-08 02:52:22 +08:00
|
|
|
dataTest: PropTypes.string,
|
2022-05-20 01:28:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Header;
|