UNPKG

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