2020-06-16 20:38:43 +00:00
|
|
|
import React from 'react';
|
|
|
|
import styled from 'styled-components';
|
2020-06-30 22:11:48 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2020-06-16 20:38:43 +00:00
|
|
|
import { prop, remSize } from '../../theme';
|
|
|
|
|
2020-07-03 18:22:20 +00:00
|
|
|
const background = transparent => prop(transparent ? 'backgroundColor' : 'MobilePanel.default.background');
|
2020-06-16 20:38:43 +00:00
|
|
|
const textColor = prop('primaryTextColor');
|
|
|
|
|
2020-06-30 22:11:48 +00:00
|
|
|
|
|
|
|
const HeaderDiv = styled.div`
|
2020-06-16 20:38:43 +00:00
|
|
|
position: fixed;
|
|
|
|
width: 100%;
|
2020-07-03 18:22:20 +00:00
|
|
|
background: ${props => background(props.transparent === true)};
|
2020-06-16 20:38:43 +00:00
|
|
|
color: ${textColor};
|
|
|
|
padding: ${remSize(12)};
|
2020-06-29 22:54:48 +00:00
|
|
|
padding-left: ${remSize(16)};
|
|
|
|
padding-right: ${remSize(16)};
|
2020-06-16 20:38:43 +00:00
|
|
|
z-index: 1;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
flex: 1;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
2020-06-29 22:54:48 +00:00
|
|
|
|
|
|
|
svg {
|
2020-06-30 22:11:48 +00:00
|
|
|
max-height: ${remSize(32)};
|
|
|
|
padding: ${remSize(4)}
|
2020-06-29 22:54:48 +00:00
|
|
|
}
|
2020-06-16 20:38:43 +00:00
|
|
|
`;
|
|
|
|
|
2020-06-30 22:11:48 +00:00
|
|
|
const IconContainer = styled.div`
|
|
|
|
margin-left: ${props => (props.leftButton ? remSize(32) : remSize(4))};
|
2020-07-29 20:52:57 +00:00
|
|
|
list-style: none;
|
2020-06-30 22:11:48 +00:00
|
|
|
display: flex;
|
2020-07-29 20:52:57 +00:00
|
|
|
flex-direction: horizontal;
|
2020-06-30 22:11:48 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
const TitleContainer = styled.div`
|
|
|
|
margin-left: ${remSize(4)};
|
|
|
|
margin-right: auto;
|
|
|
|
|
|
|
|
${props => props.padded && `h2{
|
|
|
|
padding-top: ${remSize(10)};
|
|
|
|
padding-bottom: ${remSize(10)};
|
|
|
|
}`}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Header = ({
|
|
|
|
title, subtitle, leftButton, children, transparent
|
|
|
|
}) => (
|
|
|
|
<HeaderDiv transparent={transparent}>
|
|
|
|
{leftButton}
|
|
|
|
<TitleContainer padded={subtitle === null}>
|
|
|
|
{title && <h2>{title}</h2>}
|
|
|
|
{subtitle && <h3>{subtitle}</h3>}
|
|
|
|
</TitleContainer>
|
|
|
|
<IconContainer>
|
|
|
|
{children}
|
|
|
|
</IconContainer>
|
|
|
|
</HeaderDiv>
|
|
|
|
);
|
|
|
|
|
|
|
|
Header.propTypes = {
|
|
|
|
title: PropTypes.string,
|
|
|
|
subtitle: PropTypes.string,
|
|
|
|
leftButton: PropTypes.element,
|
2020-07-01 20:36:25 +00:00
|
|
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]),
|
2020-06-30 22:11:48 +00:00
|
|
|
transparent: PropTypes.bool
|
|
|
|
};
|
|
|
|
|
|
|
|
Header.defaultProps = {
|
|
|
|
title: null,
|
|
|
|
subtitle: null,
|
|
|
|
leftButton: null,
|
|
|
|
children: [],
|
|
|
|
transparent: false
|
|
|
|
};
|
|
|
|
|
2020-06-16 20:38:43 +00:00
|
|
|
export default Header;
|