89 lines
2.4 KiB
JavaScript
89 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
|
|
var _extends3 = _interopRequireDefault(_extends2);
|
|
|
|
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
|
|
|
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
|
|
|
var _simpleAssign = require('simple-assign');
|
|
|
|
var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
|
|
|
|
var _react = require('react');
|
|
|
|
var _react2 = _interopRequireDefault(_react);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function getStyles(props, context) {
|
|
var bottomNavigation = context.muiTheme.bottomNavigation;
|
|
|
|
|
|
var styles = {
|
|
root: {
|
|
position: 'relative',
|
|
width: '100%',
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
backgroundColor: bottomNavigation.backgroundColor,
|
|
height: bottomNavigation.height
|
|
},
|
|
item: {
|
|
flex: '1'
|
|
}
|
|
};
|
|
|
|
return styles;
|
|
}
|
|
|
|
var BottomNavigation = function BottomNavigation(props, context) {
|
|
var children = props.children,
|
|
style = props.style,
|
|
selectedIndex = props.selectedIndex,
|
|
other = (0, _objectWithoutProperties3.default)(props, ['children', 'style', 'selectedIndex']);
|
|
var prepareStyles = context.muiTheme.prepareStyles;
|
|
|
|
var styles = getStyles(props, context);
|
|
|
|
var preparedChildren = _react.Children.map(children, function (child, index) {
|
|
return (0, _react.cloneElement)(child, {
|
|
style: (0, _simpleAssign2.default)({}, styles.item, child.props.style),
|
|
selected: index === selectedIndex
|
|
});
|
|
});
|
|
|
|
return _react2.default.createElement(
|
|
'div',
|
|
(0, _extends3.default)({}, other, { style: prepareStyles((0, _simpleAssign2.default)({}, styles.root, style)) }),
|
|
preparedChildren
|
|
);
|
|
};
|
|
|
|
process.env.NODE_ENV !== "production" ? BottomNavigation.propTypes = {
|
|
/**
|
|
* The `BottomNavigationItem`s to populate the element with.
|
|
*/
|
|
children: _react.PropTypes.node,
|
|
/**
|
|
* The index of the currently selected navigation item.
|
|
*/
|
|
selectedIndex: _react.PropTypes.number,
|
|
/**
|
|
* @ignore
|
|
* Override the inline-styles of the root element.
|
|
*/
|
|
style: _react.PropTypes.object
|
|
} : void 0;
|
|
|
|
BottomNavigation.contextTypes = {
|
|
muiTheme: _react.PropTypes.object.isRequired
|
|
};
|
|
|
|
exports.default = BottomNavigation; |