|
- '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 _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
-
- var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
-
- var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
-
- var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
-
- var _createClass2 = require('babel-runtime/helpers/createClass');
-
- var _createClass3 = _interopRequireDefault(_createClass2);
-
- var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
-
- var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
-
- var _inherits2 = require('babel-runtime/helpers/inherits');
-
- var _inherits3 = _interopRequireDefault(_inherits2);
-
- var _simpleAssign = require('simple-assign');
-
- var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
-
- var _react = require('react');
-
- var _react2 = _interopRequireDefault(_react);
-
- var _propTypes = require('prop-types');
-
- var _propTypes2 = _interopRequireDefault(_propTypes);
-
- var _transitions = require('../styles/transitions');
-
- var _transitions2 = _interopRequireDefault(_transitions);
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- var SvgIcon = function (_Component) {
- (0, _inherits3.default)(SvgIcon, _Component);
-
- function SvgIcon() {
- var _ref;
-
- var _temp, _this, _ret;
-
- (0, _classCallCheck3.default)(this, SvgIcon);
-
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
-
- return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = SvgIcon.__proto__ || (0, _getPrototypeOf2.default)(SvgIcon)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
- hovered: false
- }, _this.handleMouseLeave = function (event) {
- _this.setState({ hovered: false });
- _this.props.onMouseLeave(event);
- }, _this.handleMouseEnter = function (event) {
- _this.setState({ hovered: true });
- _this.props.onMouseEnter(event);
- }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
- }
-
- (0, _createClass3.default)(SvgIcon, [{
- key: 'render',
- value: function render() {
- var _props = this.props,
- children = _props.children,
- color = _props.color,
- hoverColor = _props.hoverColor,
- onMouseEnter = _props.onMouseEnter,
- onMouseLeave = _props.onMouseLeave,
- style = _props.style,
- viewBox = _props.viewBox,
- other = (0, _objectWithoutProperties3.default)(_props, ['children', 'color', 'hoverColor', 'onMouseEnter', 'onMouseLeave', 'style', 'viewBox']);
- var _context$muiTheme = this.context.muiTheme,
- svgIcon = _context$muiTheme.svgIcon,
- prepareStyles = _context$muiTheme.prepareStyles;
-
-
- var offColor = color ? color : 'currentColor';
- var onColor = hoverColor ? hoverColor : offColor;
-
- var mergedStyles = (0, _simpleAssign2.default)({
- display: 'inline-block',
- color: svgIcon.color,
- fill: this.state.hovered ? onColor : offColor,
- height: 24,
- width: 24,
- userSelect: 'none',
- transition: _transitions2.default.easeOut()
- }, style);
-
- return _react2.default.createElement(
- 'svg',
- (0, _extends3.default)({}, other, {
- onMouseEnter: this.handleMouseEnter,
- onMouseLeave: this.handleMouseLeave,
- style: prepareStyles(mergedStyles),
- viewBox: viewBox
- }),
- children
- );
- }
- }]);
- return SvgIcon;
- }(_react.Component);
-
- SvgIcon.muiName = 'SvgIcon';
- SvgIcon.defaultProps = {
- onMouseEnter: function onMouseEnter() {},
- onMouseLeave: function onMouseLeave() {},
- viewBox: '0 0 24 24'
- };
- SvgIcon.contextTypes = {
- muiTheme: _propTypes2.default.object.isRequired
- };
- SvgIcon.propTypes = process.env.NODE_ENV !== "production" ? {
- /**
- * Elements passed into the SVG Icon.
- */
- children: _propTypes2.default.node,
- /**
- * This is the fill color of the svg icon.
- * If not specified, this component will default
- * to muiTheme.palette.textColor.
- */
- color: _propTypes2.default.string,
- /**
- * This is the icon color when the mouse hovers over the icon.
- */
- hoverColor: _propTypes2.default.string,
- /** @ignore */
- onMouseEnter: _propTypes2.default.func,
- /** @ignore */
- onMouseLeave: _propTypes2.default.func,
- /**
- * Override the inline-styles of the root element.
- */
- style: _propTypes2.default.object,
- /**
- * Allows you to redefine what the coordinates
- * without units mean inside an svg element. For example,
- * if the SVG element is 500 (width) by 200 (height), and you
- * pass viewBox="0 0 50 20", this means that the coordinates inside
- * the svg will go from the top left corner (0,0) to bottom right (50,20)
- * and each unit will be worth 10px.
- */
- viewBox: _propTypes2.default.string
- } : {};
- exports.default = SvgIcon;
|