2016-05-28 18:00:42 +03:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-05-15 14:23:55 +03:00
|
|
|
import classnames from 'classnames';
|
2016-05-15 14:36:13 +03:00
|
|
|
import { themr } from 'react-css-themr';
|
2016-05-28 18:00:42 +03:00
|
|
|
import { APP_BAR } from '../identifiers.js';
|
2016-08-29 08:33:45 +03:00
|
|
|
import FontIcon from '../font_icon/FontIcon.js';
|
2015-10-28 03:49:22 +03:00
|
|
|
|
2016-08-29 08:33:45 +03:00
|
|
|
const AppBar = ({ theme, title, ...props }) => {
|
2016-05-15 14:23:55 +03:00
|
|
|
const className = classnames(theme.appBar, {
|
|
|
|
[theme.fixed]: props.fixed,
|
|
|
|
[theme.flat]: props.flat
|
2015-11-25 22:30:28 +03:00
|
|
|
}, props.className);
|
2016-08-29 08:33:45 +03:00
|
|
|
const { leftIcon, onLeftIconClick, rightIcon, onRightIconClick } = props;
|
2015-10-28 03:49:22 +03:00
|
|
|
|
|
|
|
return (
|
2015-10-30 17:38:15 +03:00
|
|
|
<header className={className} data-react-toolbox='app-bar'>
|
2016-08-29 08:33:45 +03:00
|
|
|
{leftIcon ? <FontIcon
|
|
|
|
className={classnames(theme.leftIcon)}
|
|
|
|
value={leftIcon}
|
|
|
|
onClick={onLeftIconClick}/> : null
|
|
|
|
}
|
|
|
|
{title ? <h1 className={classnames(theme.title)}>{title}</h1> : null}
|
2015-10-28 03:49:22 +03:00
|
|
|
{props.children}
|
2016-08-29 08:33:45 +03:00
|
|
|
{rightIcon ? <FontIcon
|
|
|
|
className={classnames(theme.rightIcon)}
|
|
|
|
value={rightIcon}
|
|
|
|
onClick={onRightIconClick}/> : null
|
|
|
|
}
|
2015-10-28 03:49:22 +03:00
|
|
|
</header>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
AppBar.propTypes = {
|
2016-05-28 18:00:42 +03:00
|
|
|
children: PropTypes.node,
|
|
|
|
className: PropTypes.string,
|
|
|
|
fixed: PropTypes.bool,
|
|
|
|
flat: PropTypes.bool,
|
2016-08-29 08:33:45 +03:00
|
|
|
leftIcon: PropTypes.oneOfType(
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.element
|
|
|
|
),
|
|
|
|
onLeftIconClick: PropTypes.func,
|
|
|
|
onRightIconClick: PropTypes.func,
|
|
|
|
rightIcon: PropTypes.oneOfType(
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.element
|
|
|
|
),
|
2016-05-28 18:00:42 +03:00
|
|
|
theme: PropTypes.shape({
|
|
|
|
appBar: PropTypes.string,
|
2016-08-29 08:33:45 +03:00
|
|
|
leftIcon: PropTypes.string,
|
|
|
|
rightIcon: PropTypes.string,
|
2016-05-28 18:00:42 +03:00
|
|
|
fixed: PropTypes.string,
|
2016-08-29 08:33:45 +03:00
|
|
|
flat: PropTypes.string,
|
|
|
|
title: PropTypes.string
|
|
|
|
}),
|
|
|
|
title: PropTypes.string
|
2015-10-28 03:49:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
AppBar.defaultProps = {
|
2015-10-28 13:23:45 +03:00
|
|
|
className: '',
|
|
|
|
fixed: false,
|
|
|
|
flat: false
|
2015-10-28 03:49:22 +03:00
|
|
|
};
|
|
|
|
|
2016-05-28 18:00:42 +03:00
|
|
|
export default themr(APP_BAR)(AppBar);
|
|
|
|
export { AppBar };
|