Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

165 linhas
5.2 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 _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  10. var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  11. var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
  12. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  13. var _createClass2 = require('babel-runtime/helpers/createClass');
  14. var _createClass3 = _interopRequireDefault(_createClass2);
  15. var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
  16. var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
  17. var _inherits2 = require('babel-runtime/helpers/inherits');
  18. var _inherits3 = _interopRequireDefault(_inherits2);
  19. var _simpleAssign = require('simple-assign');
  20. var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
  21. var _react = require('react');
  22. var _react2 = _interopRequireDefault(_react);
  23. var _propTypes = require('prop-types');
  24. var _propTypes2 = _interopRequireDefault(_propTypes);
  25. var _transitions = require('../styles/transitions');
  26. var _transitions2 = _interopRequireDefault(_transitions);
  27. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28. var SvgIcon = function (_Component) {
  29. (0, _inherits3.default)(SvgIcon, _Component);
  30. function SvgIcon() {
  31. var _ref;
  32. var _temp, _this, _ret;
  33. (0, _classCallCheck3.default)(this, SvgIcon);
  34. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  35. args[_key] = arguments[_key];
  36. }
  37. return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = SvgIcon.__proto__ || (0, _getPrototypeOf2.default)(SvgIcon)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
  38. hovered: false
  39. }, _this.handleMouseLeave = function (event) {
  40. _this.setState({ hovered: false });
  41. _this.props.onMouseLeave(event);
  42. }, _this.handleMouseEnter = function (event) {
  43. _this.setState({ hovered: true });
  44. _this.props.onMouseEnter(event);
  45. }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
  46. }
  47. (0, _createClass3.default)(SvgIcon, [{
  48. key: 'render',
  49. value: function render() {
  50. var _props = this.props,
  51. children = _props.children,
  52. color = _props.color,
  53. hoverColor = _props.hoverColor,
  54. onMouseEnter = _props.onMouseEnter,
  55. onMouseLeave = _props.onMouseLeave,
  56. style = _props.style,
  57. viewBox = _props.viewBox,
  58. other = (0, _objectWithoutProperties3.default)(_props, ['children', 'color', 'hoverColor', 'onMouseEnter', 'onMouseLeave', 'style', 'viewBox']);
  59. var _context$muiTheme = this.context.muiTheme,
  60. svgIcon = _context$muiTheme.svgIcon,
  61. prepareStyles = _context$muiTheme.prepareStyles;
  62. var offColor = color ? color : 'currentColor';
  63. var onColor = hoverColor ? hoverColor : offColor;
  64. var mergedStyles = (0, _simpleAssign2.default)({
  65. display: 'inline-block',
  66. color: svgIcon.color,
  67. fill: this.state.hovered ? onColor : offColor,
  68. height: 24,
  69. width: 24,
  70. userSelect: 'none',
  71. transition: _transitions2.default.easeOut()
  72. }, style);
  73. return _react2.default.createElement(
  74. 'svg',
  75. (0, _extends3.default)({}, other, {
  76. onMouseEnter: this.handleMouseEnter,
  77. onMouseLeave: this.handleMouseLeave,
  78. style: prepareStyles(mergedStyles),
  79. viewBox: viewBox
  80. }),
  81. children
  82. );
  83. }
  84. }]);
  85. return SvgIcon;
  86. }(_react.Component);
  87. SvgIcon.muiName = 'SvgIcon';
  88. SvgIcon.defaultProps = {
  89. onMouseEnter: function onMouseEnter() {},
  90. onMouseLeave: function onMouseLeave() {},
  91. viewBox: '0 0 24 24'
  92. };
  93. SvgIcon.contextTypes = {
  94. muiTheme: _propTypes2.default.object.isRequired
  95. };
  96. SvgIcon.propTypes = process.env.NODE_ENV !== "production" ? {
  97. /**
  98. * Elements passed into the SVG Icon.
  99. */
  100. children: _propTypes2.default.node,
  101. /**
  102. * This is the fill color of the svg icon.
  103. * If not specified, this component will default
  104. * to muiTheme.palette.textColor.
  105. */
  106. color: _propTypes2.default.string,
  107. /**
  108. * This is the icon color when the mouse hovers over the icon.
  109. */
  110. hoverColor: _propTypes2.default.string,
  111. /** @ignore */
  112. onMouseEnter: _propTypes2.default.func,
  113. /** @ignore */
  114. onMouseLeave: _propTypes2.default.func,
  115. /**
  116. * Override the inline-styles of the root element.
  117. */
  118. style: _propTypes2.default.object,
  119. /**
  120. * Allows you to redefine what the coordinates
  121. * without units mean inside an svg element. For example,
  122. * if the SVG element is 500 (width) by 200 (height), and you
  123. * pass viewBox="0 0 50 20", this means that the coordinates inside
  124. * the svg will go from the top left corner (0,0) to bottom right (50,20)
  125. * and each unit will be worth 10px.
  126. */
  127. viewBox: _propTypes2.default.string
  128. } : {};
  129. exports.default = SvgIcon;