UNPKG

4.45 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _clsx = _interopRequireDefault(require("clsx"));
21
22var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
23
24var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
25
26var styles = function styles(theme) {
27 return {
28 /* Styles applied to the root element. */
29 root: {
30 userSelect: 'none',
31 fontSize: theme.typography.pxToRem(24),
32 width: '1em',
33 height: '1em',
34 // Chrome fix for https://bugs.chromium.org/p/chromium/issues/detail?id=820541
35 // To remove at some point.
36 overflow: 'hidden',
37 flexShrink: 0
38 },
39
40 /* Styles applied to the root element if `color="primary"`. */
41 colorPrimary: {
42 color: theme.palette.primary.main
43 },
44
45 /* Styles applied to the root element if `color="secondary"`. */
46 colorSecondary: {
47 color: theme.palette.secondary.main
48 },
49
50 /* Styles applied to the root element if `color="action"`. */
51 colorAction: {
52 color: theme.palette.action.active
53 },
54
55 /* Styles applied to the root element if `color="error"`. */
56 colorError: {
57 color: theme.palette.error.main
58 },
59
60 /* Styles applied to the root element if `color="disabled"`. */
61 colorDisabled: {
62 color: theme.palette.action.disabled
63 },
64
65 /* Styles applied to the root element if `fontSize="inherit"`. */
66 fontSizeInherit: {
67 fontSize: 'inherit'
68 },
69
70 /* Styles applied to the root element if `fontSize="small"`. */
71 fontSizeSmall: {
72 fontSize: theme.typography.pxToRem(20)
73 },
74
75 /* Styles applied to the root element if `fontSize="large"`. */
76 fontSizeLarge: {
77 fontSize: theme.typography.pxToRem(36)
78 }
79 };
80};
81
82exports.styles = styles;
83var Icon = /*#__PURE__*/React.forwardRef(function Icon(props, ref) {
84 var classes = props.classes,
85 className = props.className,
86 _props$color = props.color,
87 color = _props$color === void 0 ? 'inherit' : _props$color,
88 _props$component = props.component,
89 Component = _props$component === void 0 ? 'span' : _props$component,
90 _props$fontSize = props.fontSize,
91 fontSize = _props$fontSize === void 0 ? 'default' : _props$fontSize,
92 other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "color", "component", "fontSize"]);
93 return /*#__PURE__*/React.createElement(Component, (0, _extends2.default)({
94 className: (0, _clsx.default)('material-icons', classes.root, className, color !== 'inherit' && classes["color".concat((0, _capitalize.default)(color))], fontSize !== 'default' && classes["fontSize".concat((0, _capitalize.default)(fontSize))]),
95 "aria-hidden": true,
96 ref: ref
97 }, other));
98});
99process.env.NODE_ENV !== "production" ? Icon.propTypes = {
100 /**
101 * The name of the icon font ligature.
102 */
103 children: _propTypes.default.node,
104
105 /**
106 * Override or extend the styles applied to the component.
107 * See [CSS API](#css) below for more details.
108 */
109 classes: _propTypes.default.object.isRequired,
110
111 /**
112 * @ignore
113 */
114 className: _propTypes.default.string,
115
116 /**
117 * The color of the component. It supports those theme colors that make sense for this component.
118 */
119 color: _propTypes.default.oneOf(['inherit', 'primary', 'secondary', 'action', 'error', 'disabled']),
120
121 /**
122 * The component used for the root node.
123 * Either a string to use a HTML element or a component.
124 */
125 component: _propTypes.default
126 /* @typescript-to-proptypes-ignore */
127 .elementType,
128
129 /**
130 * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.
131 */
132 fontSize: _propTypes.default.oneOf(['inherit', 'default', 'small', 'large'])
133} : void 0;
134Icon.muiName = 'Icon';
135
136var _default = (0, _withStyles.default)(styles, {
137 name: 'MuiIcon'
138})(Icon);
139
140exports.default = _default;
\No newline at end of file