UNPKG

6.38 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 width: '1em',
32 height: '1em',
33 display: 'inline-block',
34 fill: 'currentColor',
35 flexShrink: 0,
36 fontSize: theme.typography.pxToRem(24),
37 transition: theme.transitions.create('fill', {
38 duration: theme.transitions.duration.shorter
39 })
40 },
41
42 /* Styles applied to the root element if `color="primary"`. */
43 colorPrimary: {
44 color: theme.palette.primary.main
45 },
46
47 /* Styles applied to the root element if `color="secondary"`. */
48 colorSecondary: {
49 color: theme.palette.secondary.main
50 },
51
52 /* Styles applied to the root element if `color="action"`. */
53 colorAction: {
54 color: theme.palette.action.active
55 },
56
57 /* Styles applied to the root element if `color="error"`. */
58 colorError: {
59 color: theme.palette.error.main
60 },
61
62 /* Styles applied to the root element if `color="disabled"`. */
63 colorDisabled: {
64 color: theme.palette.action.disabled
65 },
66
67 /* Styles applied to the root element if `fontSize="inherit"`. */
68 fontSizeInherit: {
69 fontSize: 'inherit'
70 },
71
72 /* Styles applied to the root element if `fontSize="small"`. */
73 fontSizeSmall: {
74 fontSize: theme.typography.pxToRem(20)
75 },
76
77 /* Styles applied to the root element if `fontSize="large"`. */
78 fontSizeLarge: {
79 fontSize: theme.typography.pxToRem(35)
80 }
81 };
82};
83
84exports.styles = styles;
85var SvgIcon = /*#__PURE__*/React.forwardRef(function SvgIcon(props, ref) {
86 var children = props.children,
87 classes = props.classes,
88 className = props.className,
89 _props$color = props.color,
90 color = _props$color === void 0 ? 'inherit' : _props$color,
91 _props$component = props.component,
92 Component = _props$component === void 0 ? 'svg' : _props$component,
93 _props$fontSize = props.fontSize,
94 fontSize = _props$fontSize === void 0 ? 'default' : _props$fontSize,
95 htmlColor = props.htmlColor,
96 titleAccess = props.titleAccess,
97 _props$viewBox = props.viewBox,
98 viewBox = _props$viewBox === void 0 ? '0 0 24 24' : _props$viewBox,
99 other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "color", "component", "fontSize", "htmlColor", "titleAccess", "viewBox"]);
100 return /*#__PURE__*/React.createElement(Component, (0, _extends2.default)({
101 className: (0, _clsx.default)(classes.root, className, color !== 'inherit' && classes["color".concat((0, _capitalize.default)(color))], fontSize !== 'default' && classes["fontSize".concat((0, _capitalize.default)(fontSize))]),
102 focusable: "false",
103 viewBox: viewBox,
104 color: htmlColor,
105 "aria-hidden": titleAccess ? undefined : true,
106 role: titleAccess ? 'img' : undefined,
107 ref: ref
108 }, other), children, titleAccess ? /*#__PURE__*/React.createElement("title", null, titleAccess) : null);
109});
110process.env.NODE_ENV !== "production" ? SvgIcon.propTypes = {
111 // ----------------------------- Warning --------------------------------
112 // | These PropTypes are generated from the TypeScript type definitions |
113 // | To update them edit the d.ts file and run "yarn proptypes" |
114 // ----------------------------------------------------------------------
115
116 /**
117 * Node passed into the SVG element.
118 */
119 children: _propTypes.default.node,
120
121 /**
122 * Override or extend the styles applied to the component.
123 * See [CSS API](#css) below for more details.
124 */
125 classes: _propTypes.default.object,
126
127 /**
128 * @ignore
129 */
130 className: _propTypes.default.string,
131
132 /**
133 * The color of the component. It supports those theme colors that make sense for this component.
134 * You can use the `htmlColor` prop to apply a color attribute to the SVG element.
135 */
136 color: _propTypes.default.oneOf(['action', 'disabled', 'error', 'inherit', 'primary', 'secondary']),
137
138 /**
139 * The component used for the root node.
140 * Either a string to use a HTML element or a component.
141 */
142 component: _propTypes.default
143 /* @typescript-to-proptypes-ignore */
144 .elementType,
145
146 /**
147 * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.
148 */
149 fontSize: _propTypes.default.oneOf(['default', 'inherit', 'large', 'small']),
150
151 /**
152 * Applies a color attribute to the SVG element.
153 */
154 htmlColor: _propTypes.default.string,
155
156 /**
157 * The shape-rendering attribute. The behavior of the different options is described on the
158 * [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering).
159 * If you are having issues with blurry icons you should investigate this property.
160 */
161 shapeRendering: _propTypes.default.string,
162
163 /**
164 * Provides a human-readable title for the element that contains it.
165 * https://www.w3.org/TR/SVG-access/#Equivalent
166 */
167 titleAccess: _propTypes.default.string,
168
169 /**
170 * Allows you to redefine what the coordinates without units mean inside an SVG element.
171 * For example, if the SVG element is 500 (width) by 200 (height),
172 * and you pass viewBox="0 0 50 20",
173 * this means that the coordinates inside the SVG will go from the top left corner (0,0)
174 * to bottom right (50,20) and each unit will be worth 10px.
175 */
176 viewBox: _propTypes.default.string
177} : void 0;
178SvgIcon.muiName = 'SvgIcon';
179
180var _default = (0, _withStyles.default)(styles, {
181 name: 'MuiSvgIcon'
182})(SvgIcon);
183
184exports.default = _default;
\No newline at end of file