Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

97 строки
2.5 KiB

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends2 = require('babel-runtime/helpers/extends');
  6. var _extends3 = _interopRequireDefault(_extends2);
  7. var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
  8. var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
  9. var _simpleAssign = require('simple-assign');
  10. var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
  11. var _react = require('react');
  12. var _react2 = _interopRequireDefault(_react);
  13. var _propTypes = require('prop-types');
  14. var _propTypes2 = _interopRequireDefault(_propTypes);
  15. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16. function getStyles(props, context) {
  17. var bottomNavigation = context.muiTheme.bottomNavigation;
  18. var styles = {
  19. root: {
  20. position: 'relative',
  21. width: '100%',
  22. display: 'flex',
  23. justifyContent: 'center',
  24. backgroundColor: bottomNavigation.backgroundColor,
  25. height: bottomNavigation.height
  26. },
  27. item: {
  28. flex: '1'
  29. }
  30. };
  31. return styles;
  32. }
  33. var BottomNavigation = function BottomNavigation(props, context) {
  34. var children = props.children,
  35. style = props.style,
  36. selectedIndex = props.selectedIndex,
  37. other = (0, _objectWithoutProperties3.default)(props, ['children', 'style', 'selectedIndex']);
  38. var prepareStyles = context.muiTheme.prepareStyles;
  39. var styles = getStyles(props, context);
  40. var preparedChildren = _react.Children.map(children, function (child, index) {
  41. if (!child) {
  42. return null;
  43. }
  44. return (0, _react.cloneElement)(child, {
  45. style: (0, _simpleAssign2.default)({}, styles.item, child.props.style),
  46. selected: index === selectedIndex
  47. });
  48. });
  49. return _react2.default.createElement(
  50. 'div',
  51. (0, _extends3.default)({}, other, { style: prepareStyles((0, _simpleAssign2.default)({}, styles.root, style)) }),
  52. preparedChildren
  53. );
  54. };
  55. BottomNavigation.propTypes = process.env.NODE_ENV !== "production" ? {
  56. /**
  57. * The `BottomNavigationItem`s to populate the element with.
  58. */
  59. children: _propTypes2.default.node,
  60. /**
  61. * The index of the currently selected navigation item.
  62. */
  63. selectedIndex: _propTypes2.default.number,
  64. /**
  65. * @ignore
  66. * Override the inline-styles of the root element.
  67. */
  68. style: _propTypes2.default.object
  69. } : {};
  70. BottomNavigation.contextTypes = {
  71. muiTheme: _propTypes2.default.object.isRequired
  72. };
  73. exports.default = BottomNavigation;