Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -1,17 +1,23 @@
import * as React from 'react';
import { StandardProps } from '..';
import { StandardProps, PropTypes } from '..';
export interface SvgIconProps extends StandardProps<
React.SVGProps<SVGSVGElement>,
SvgIconClassKey
> {
export interface SvgIconProps
extends StandardProps<React.SVGProps<SVGSVGElement>, SvgIconClassKey, 'fontSize'> {
color?: PropTypes.Color | 'action' | 'disabled' | 'error';
fontSize?: boolean;
nativeColor?: string;
titleAccess?: string;
viewBox?: string;
}
export type SvgIconClassKey =
| 'root'
;
| 'colorSecondary'
| 'colorAction'
| 'colorDisabled'
| 'colorError'
| 'colorPrimary'
| 'fontSize';
declare const SvgIcon: React.ComponentType<SvgIconProps>;

View File

@@ -5,24 +5,26 @@ Object.defineProperty(exports, "__esModule", {
});
exports.styles = undefined;
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _ref;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
@@ -31,9 +33,9 @@ var _withStyles = require('../styles/withStyles');
var _withStyles2 = _interopRequireDefault(_withStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _helpers = require('../utils/helpers');
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var styles = exports.styles = function styles(theme) {
return {
@@ -47,58 +49,52 @@ var styles = exports.styles = function styles(theme) {
transition: theme.transitions.create('fill', {
duration: theme.transitions.duration.shorter
})
},
colorPrimary: {
color: theme.palette.primary.main
},
colorSecondary: {
color: theme.palette.secondary.main
},
colorAction: {
color: theme.palette.action.active
},
colorDisabled: {
color: theme.palette.action.disabled
},
colorError: {
color: theme.palette.error.main
},
fontSize: {
width: '1em',
height: '1em'
}
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* Elements passed into the SVG Icon.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node.isRequired ? babelPluginFlowReactPropTypes_proptype_Node.isRequired : babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node).isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* Provides a human-readable title for the element that contains it.
* https://www.w3.org/TR/SVG-access/#Equivalent
*/
titleAccess: require('prop-types').string,
/**
* Allows you to redefine what the coordinates without units mean inside an svg element.
* For example, if the SVG element is 500 (width) by 200 (height),
* and you pass viewBox="0 0 50 20",
* this means that the coordinates inside the svg will go from the top left corner (0,0)
* to bottom right (50,20) and each unit will be worth 10px.
*/
viewBox: require('prop-types').string
};
function SvgIcon(props) {
var _classNames;
var children = props.children,
classes = props.classes,
className = props.className,
classNameProp = props.className,
color = props.color,
fontSize = props.fontSize,
nativeColor = props.nativeColor,
titleAccess = props.titleAccess,
viewBox = props.viewBox,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'titleAccess', 'viewBox']);
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'color', 'fontSize', 'nativeColor', 'titleAccess', 'viewBox']);
var className = (0, _classnames2.default)(classes.root, (_classNames = {}, (0, _defineProperty3.default)(_classNames, classes['color' + (0, _helpers.capitalize)(color)], color !== 'inherit'), (0, _defineProperty3.default)(_classNames, classes.fontSize, fontSize), _classNames), classNameProp);
return _react2.default.createElement(
'svg',
(0, _extends3.default)({
className: (0, _classnames2.default)(classes.root, className),
className: className,
focusable: 'false',
viewBox: viewBox,
color: nativeColor,
'aria-hidden': titleAccess ? 'false' : 'true'
}, other),
titleAccess ? _react2.default.createElement(
@@ -110,11 +106,50 @@ function SvgIcon(props) {
);
}
SvgIcon.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node.isRequired ? babelPluginFlowReactPropTypes_proptype_Node.isRequired : babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node).isRequired
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'titleAccess', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'viewBox', require('prop-types').string), _ref) : {};
SvgIcon.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* Node passed into the SVG element.
*/
children: _propTypes2.default.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* @ignore
*/
className: _propTypes2.default.string,
/**
* The color of the component. It supports those theme colors that make sense for this component.
* You can use the `nativeColor` property to apply a color attribute to the SVG element.
*/
color: _propTypes2.default.oneOf(['action', 'disabled', 'error', 'inherit', 'primary', 'secondary']),
/**
* If `true`, the icon size will be determined by the font-size.
*/
fontSize: _propTypes2.default.bool,
/**
* Applies a color attribute to the SVG element.
*/
nativeColor: _propTypes2.default.string,
/**
* Provides a human-readable title for the element that contains it.
* https://www.w3.org/TR/SVG-access/#Equivalent
*/
titleAccess: _propTypes2.default.string,
/**
* Allows you to redefine what the coordinates without units mean inside an SVG element.
* For example, if the SVG element is 500 (width) by 200 (height),
* and you pass viewBox="0 0 50 20",
* this means that the coordinates inside the SVG will go from the top left corner (0,0)
* to bottom right (50,20) and each unit will be worth 10px.
*/
viewBox: _propTypes2.default.string
} : {};
SvgIcon.defaultProps = {
color: 'inherit',
fontSize: false,
viewBox: '0 0 24 24'
};

View File

@@ -1,11 +1,10 @@
// @flow
import React from 'react';
import type { Node } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { capitalize } from '../utils/helpers';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
display: 'inline-block',
fill: 'currentColor',
@@ -17,48 +16,55 @@ export const styles = (theme: Object) => ({
duration: theme.transitions.duration.shorter,
}),
},
colorPrimary: {
color: theme.palette.primary.main,
},
colorSecondary: {
color: theme.palette.secondary.main,
},
colorAction: {
color: theme.palette.action.active,
},
colorDisabled: {
color: theme.palette.action.disabled,
},
colorError: {
color: theme.palette.error.main,
},
fontSize: {
width: '1em',
height: '1em',
},
});
type ProvidedProps = {
classes: Object,
};
function SvgIcon(props) {
const {
children,
classes,
className: classNameProp,
color,
fontSize,
nativeColor,
titleAccess,
viewBox,
...other
} = props;
export type Props = {
/**
* Elements passed into the SVG Icon.
*/
children: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* Provides a human-readable title for the element that contains it.
* https://www.w3.org/TR/SVG-access/#Equivalent
*/
titleAccess?: string,
/**
* Allows you to redefine what the coordinates without units mean inside an svg element.
* For example, if the SVG element is 500 (width) by 200 (height),
* and you pass viewBox="0 0 50 20",
* this means that the coordinates inside the svg will go from the top left corner (0,0)
* to bottom right (50,20) and each unit will be worth 10px.
*/
viewBox?: string,
};
function SvgIcon(props: ProvidedProps & Props) {
const { children, classes, className, titleAccess, viewBox, ...other } = props;
const className = classNames(
classes.root,
{
[classes[`color${capitalize(color)}`]]: color !== 'inherit',
[classes.fontSize]: fontSize,
},
classNameProp,
);
return (
<svg
className={classNames(classes.root, className)}
className={className}
focusable="false"
viewBox={viewBox}
color={nativeColor}
aria-hidden={titleAccess ? 'false' : 'true'}
{...other}
>
@@ -68,7 +74,50 @@ function SvgIcon(props: ProvidedProps & Props) {
);
}
SvgIcon.propTypes = {
/**
* Node passed into the SVG element.
*/
children: PropTypes.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The color of the component. It supports those theme colors that make sense for this component.
* You can use the `nativeColor` property to apply a color attribute to the SVG element.
*/
color: PropTypes.oneOf(['action', 'disabled', 'error', 'inherit', 'primary', 'secondary']),
/**
* If `true`, the icon size will be determined by the font-size.
*/
fontSize: PropTypes.bool,
/**
* Applies a color attribute to the SVG element.
*/
nativeColor: PropTypes.string,
/**
* Provides a human-readable title for the element that contains it.
* https://www.w3.org/TR/SVG-access/#Equivalent
*/
titleAccess: PropTypes.string,
/**
* Allows you to redefine what the coordinates without units mean inside an SVG element.
* For example, if the SVG element is 500 (width) by 200 (height),
* and you pass viewBox="0 0 50 20",
* this means that the coordinates inside the SVG will go from the top left corner (0,0)
* to bottom right (50,20) and each unit will be worth 10px.
*/
viewBox: PropTypes.string,
};
SvgIcon.defaultProps = {
color: 'inherit',
fontSize: false,
viewBox: '0 0 24 24',
};

View File

@@ -1,3 +1 @@
// @flow
export { default } from './SvgIcon';