react-toolbox/components/app_bar/AppBar.js

66 lines
1.7 KiB
JavaScript
Raw Normal View History

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';
import FontIcon from '../font_icon/FontIcon.js';
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);
const { leftIcon, onLeftIconClick, rightIcon, onRightIconClick } = props;
return (
2015-10-30 17:38:15 +03:00
<header className={className} data-react-toolbox='app-bar'>
{leftIcon ? <FontIcon
className={classnames(theme.leftIcon)}
value={leftIcon}
onClick={onLeftIconClick}/> : null
}
{title ? <h1 className={classnames(theme.title)}>{title}</h1> : null}
{props.children}
{rightIcon ? <FontIcon
className={classnames(theme.rightIcon)}
value={rightIcon}
onClick={onRightIconClick}/> : null
}
</header>
);
};
AppBar.propTypes = {
2016-05-28 18:00:42 +03:00
children: PropTypes.node,
className: PropTypes.string,
fixed: PropTypes.bool,
flat: PropTypes.bool,
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,
leftIcon: PropTypes.string,
rightIcon: PropTypes.string,
2016-05-28 18:00:42 +03:00
fixed: PropTypes.string,
flat: PropTypes.string,
title: PropTypes.string
}),
title: PropTypes.string
};
AppBar.defaultProps = {
2015-10-28 13:23:45 +03:00
className: '',
fixed: false,
flat: false
};
2016-05-28 18:00:42 +03:00
export default themr(APP_BAR)(AppBar);
export { AppBar };