UNPKG

6.24 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = exports.styles = void 0;
9
10var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
12var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
14var _react = _interopRequireDefault(require("react"));
15
16var _propTypes = _interopRequireDefault(require("prop-types"));
17
18var _clsx = _interopRequireDefault(require("clsx"));
19
20var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
21
22var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
23
24var styles = function styles(theme) {
25 return {
26 /* Styles applied to the root element. */
27 root: {
28 userSelect: 'none',
29 width: '1em',
30 height: '1em',
31 display: 'inline-block',
32 fill: 'currentColor',
33 flexShrink: 0,
34 fontSize: theme.typography.pxToRem(24),
35 transition: theme.transitions.create('fill', {
36 duration: theme.transitions.duration.shorter
37 })
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(35)
78 }
79 };
80};
81
82exports.styles = styles;
83
84var SvgIcon = _react.default.forwardRef(function SvgIcon(props, ref) {
85 var children = props.children,
86 classes = props.classes,
87 className = props.className,
88 _props$color = props.color,
89 color = _props$color === void 0 ? 'inherit' : _props$color,
90 _props$component = props.component,
91 Component = _props$component === void 0 ? 'svg' : _props$component,
92 _props$fontSize = props.fontSize,
93 fontSize = _props$fontSize === void 0 ? 'default' : _props$fontSize,
94 htmlColor = props.htmlColor,
95 titleAccess = props.titleAccess,
96 _props$viewBox = props.viewBox,
97 viewBox = _props$viewBox === void 0 ? '0 0 24 24' : _props$viewBox,
98 other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "color", "component", "fontSize", "htmlColor", "titleAccess", "viewBox"]);
99 return _react.default.createElement(Component, (0, _extends2.default)({
100 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))]),
101 focusable: "false",
102 viewBox: viewBox,
103 color: htmlColor,
104 "aria-hidden": titleAccess ? 'false' : 'true',
105 role: titleAccess ? 'img' : 'presentation',
106 ref: ref
107 }, other), children, titleAccess ? _react.default.createElement("title", null, titleAccess) : null);
108});
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 DOM element or a component.
141 */
142 component: _propTypes.default.elementType,
143
144 /**
145 * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.
146 */
147 fontSize: _propTypes.default.oneOf(['default', 'inherit', 'large', 'small']),
148
149 /**
150 * Applies a color attribute to the SVG element.
151 */
152 htmlColor: _propTypes.default.string,
153
154 /**
155 * The shape-rendering attribute. The behavior of the different options is described on the
156 * [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering).
157 * If you are having issues with blurry icons you should investigate this property.
158 */
159 shapeRendering: _propTypes.default.string,
160
161 /**
162 * Provides a human-readable title for the element that contains it.
163 * https://www.w3.org/TR/SVG-access/#Equivalent
164 */
165 titleAccess: _propTypes.default.string,
166
167 /**
168 * Allows you to redefine what the coordinates without units mean inside an SVG element.
169 * For example, if the SVG element is 500 (width) by 200 (height),
170 * and you pass viewBox="0 0 50 20",
171 * this means that the coordinates inside the SVG will go from the top left corner (0,0)
172 * to bottom right (50,20) and each unit will be worth 10px.
173 */
174 viewBox: _propTypes.default.string
175} : void 0;
176SvgIcon.muiName = 'SvgIcon';
177
178var _default = (0, _withStyles.default)(styles, {
179 name: 'MuiSvgIcon'
180})(SvgIcon);
181
182exports.default = _default;
\No newline at end of file