110 lines
2.9 KiB
JavaScript
110 lines
2.9 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);
|
||
|
|
|
||
|
|
var _EnhancedButton = require('../internal/EnhancedButton');
|
||
|
|
|
||
|
|
var _EnhancedButton2 = _interopRequireDefault(_EnhancedButton);
|
||
|
|
|
||
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
|
||
|
|
function getStyles(props, context) {
|
||
|
|
var selected = props.selected;
|
||
|
|
var bottomNavigation = context.muiTheme.bottomNavigation;
|
||
|
|
|
||
|
|
|
||
|
|
var color = selected ? bottomNavigation.selectedColor : bottomNavigation.unselectedColor;
|
||
|
|
|
||
|
|
var styles = {
|
||
|
|
root: {
|
||
|
|
transition: 'padding-top 0.3s',
|
||
|
|
paddingTop: selected ? 6 : 8,
|
||
|
|
paddingBottom: 10,
|
||
|
|
paddingLeft: 12,
|
||
|
|
paddingRight: 12,
|
||
|
|
minWidth: 80,
|
||
|
|
maxWidth: 168
|
||
|
|
},
|
||
|
|
label: {
|
||
|
|
fontSize: selected ? bottomNavigation.selectedFontSize : bottomNavigation.unselectedFontSize,
|
||
|
|
transition: 'color 0.3s, font-size 0.3s',
|
||
|
|
color: color
|
||
|
|
},
|
||
|
|
icon: {
|
||
|
|
display: 'block',
|
||
|
|
/**
|
||
|
|
* Used to ensure SVG icons are centered
|
||
|
|
*/
|
||
|
|
width: '100%'
|
||
|
|
},
|
||
|
|
iconColor: color
|
||
|
|
};
|
||
|
|
|
||
|
|
return styles;
|
||
|
|
}
|
||
|
|
|
||
|
|
var BottomNavigationItem = function BottomNavigationItem(props, context) {
|
||
|
|
var label = props.label,
|
||
|
|
icon = props.icon,
|
||
|
|
style = props.style,
|
||
|
|
other = (0, _objectWithoutProperties3.default)(props, ['label', 'icon', 'style']);
|
||
|
|
var prepareStyles = context.muiTheme.prepareStyles;
|
||
|
|
|
||
|
|
var styles = getStyles(props, context);
|
||
|
|
|
||
|
|
var styledIcon = (0, _react.cloneElement)(icon, {
|
||
|
|
style: (0, _simpleAssign2.default)({}, styles.icon, icon.props.style),
|
||
|
|
color: icon.props.color || styles.iconColor
|
||
|
|
});
|
||
|
|
|
||
|
|
return _react2.default.createElement(
|
||
|
|
_EnhancedButton2.default,
|
||
|
|
(0, _extends3.default)({}, other, { style: (0, _simpleAssign2.default)({}, styles.root, style) }),
|
||
|
|
styledIcon,
|
||
|
|
_react2.default.createElement(
|
||
|
|
'div',
|
||
|
|
{ style: prepareStyles(styles.label) },
|
||
|
|
label
|
||
|
|
)
|
||
|
|
);
|
||
|
|
};
|
||
|
|
|
||
|
|
process.env.NODE_ENV !== "production" ? BottomNavigationItem.propTypes = {
|
||
|
|
/**
|
||
|
|
* Set the icon representing the view for this item.
|
||
|
|
*/
|
||
|
|
icon: _react.PropTypes.node,
|
||
|
|
/**
|
||
|
|
* Set the label describing the view for this item.
|
||
|
|
*/
|
||
|
|
label: _react.PropTypes.node,
|
||
|
|
/**
|
||
|
|
* @ignore
|
||
|
|
* Override the inline-styles of the root element.
|
||
|
|
*/
|
||
|
|
style: _react.PropTypes.object
|
||
|
|
} : void 0;
|
||
|
|
|
||
|
|
BottomNavigationItem.contextTypes = {
|
||
|
|
muiTheme: _react.PropTypes.object.isRequired
|
||
|
|
};
|
||
|
|
|
||
|
|
exports.default = BottomNavigationItem;
|