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,22 +1,20 @@
import * as React from 'react';
import { StandardProps, PropTypes } from '..';
export interface IconProps extends StandardProps<
React.HTMLAttributes<HTMLSpanElement>,
IconClassKey
> {
color?: PropTypes.Color | 'action' | 'contrast' | 'disabled' | 'error';
export interface IconProps
extends StandardProps<React.HTMLAttributes<HTMLSpanElement>, IconClassKey> {
color?: PropTypes.Color | 'action' | 'disabled' | 'error';
fontSize?: boolean;
}
export type IconClassKey =
| 'root'
| 'colorAccent'
| 'colorSecondary'
| 'colorAction'
| 'colorContrast'
| 'colorDisabled'
| 'colorError'
| 'colorPrimary'
;
| 'fontSize';
declare const Icon: React.ComponentType<IconProps>;

View File

@@ -17,12 +17,14 @@ var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProp
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);
@@ -35,68 +37,45 @@ var _helpers = require('../utils/helpers');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Node = require('react').babelPluginFlowReactPropTypes_proptype_Node || require('prop-types').any;
var styles = exports.styles = function styles(theme) {
return {
root: {
userSelect: 'none'
},
colorAccent: {
color: theme.palette.secondary.A200
colorPrimary: {
color: theme.palette.primary.main
},
colorSecondary: {
color: theme.palette.secondary.main
},
colorAction: {
color: theme.palette.action.active
},
colorContrast: {
color: theme.palette.getContrastText(theme.palette.primary[500])
},
colorDisabled: {
color: theme.palette.action.disabled
},
colorError: {
color: theme.palette.error[500]
color: theme.palette.error.main
},
colorPrimary: {
color: theme.palette.primary[500]
fontSize: {
width: '1em',
height: '1em'
}
};
};
var babelPluginFlowReactPropTypes_proptype_Color = require('prop-types').oneOf(['inherit', 'accent', 'action', 'contrast', 'disabled', 'error', 'primary']);
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* The name of the icon font ligature.
*/
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node),
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* @ignore
*/
className: require('prop-types').string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color: require('prop-types').oneOf(['inherit', 'accent', 'action', 'contrast', 'disabled', 'error', 'primary'])
};
function Icon(props) {
var _classNames;
var children = props.children,
classes = props.classes,
classNameProp = props.className,
color = props.color,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'color']);
fontSize = props.fontSize,
other = (0, _objectWithoutProperties3.default)(props, ['children', 'classes', 'className', 'color', 'fontSize']);
var className = (0, _classnames2.default)('material-icons', classes.root, (0, _defineProperty3.default)({}, classes['color' + (0, _helpers.capitalizeFirstLetter)(color)], color !== 'inherit'), classNameProp);
var className = (0, _classnames2.default)('material-icons', 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(
'span',
@@ -105,13 +84,32 @@ function Icon(props) {
);
}
Icon.propTypes = process.env.NODE_ENV !== "production" ? (_ref = {
classes: require('prop-types').object.isRequired,
color: require('prop-types').oneOf(['inherit', 'accent', 'action', 'contrast', 'disabled', 'error', 'primary']).isRequired,
children: typeof babelPluginFlowReactPropTypes_proptype_Node === 'function' ? babelPluginFlowReactPropTypes_proptype_Node : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Node)
}, (0, _defineProperty3.default)(_ref, 'classes', require('prop-types').object), (0, _defineProperty3.default)(_ref, 'className', require('prop-types').string), (0, _defineProperty3.default)(_ref, 'color', require('prop-types').oneOf(['inherit', 'accent', 'action', 'contrast', 'disabled', 'error', 'primary'])), _ref) : {};
Icon.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The name of the icon font ligature.
*/
children: _propTypes2.default.node,
/**
* 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.
*/
color: _propTypes2.default.oneOf(['inherit', 'secondary', 'action', 'disabled', 'error', 'primary']),
/**
* If `true`, the icon size will be determined by the font-size.
*/
fontSize: _propTypes2.default.bool
} : {};
Icon.defaultProps = {
color: 'inherit'
color: 'inherit',
fontSize: false
};
Icon.muiName = 'Icon';

View File

@@ -1,69 +1,43 @@
// @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 { capitalizeFirstLetter } from '../utils/helpers';
import { capitalize } from '../utils/helpers';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
userSelect: 'none',
},
colorAccent: {
color: theme.palette.secondary.A200,
colorPrimary: {
color: theme.palette.primary.main,
},
colorSecondary: {
color: theme.palette.secondary.main,
},
colorAction: {
color: theme.palette.action.active,
},
colorContrast: {
color: theme.palette.getContrastText(theme.palette.primary[500]),
},
colorDisabled: {
color: theme.palette.action.disabled,
},
colorError: {
color: theme.palette.error[500],
color: theme.palette.error.main,
},
colorPrimary: {
color: theme.palette.primary[500],
fontSize: {
width: '1em',
height: '1em',
},
});
export type Color = 'inherit' | 'accent' | 'action' | 'contrast' | 'disabled' | 'error' | 'primary';
type ProvidedProps = {
classes: Object,
color: Color,
};
export type Props = {
/**
* The name of the icon font ligature.
*/
children?: Node,
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The color of the component. It's using the theme palette when that makes sense.
*/
color?: Color,
};
function Icon(props: ProvidedProps & Props) {
const { children, classes, className: classNameProp, color, ...other } = props;
function Icon(props) {
const { children, classes, className: classNameProp, color, fontSize, ...other } = props;
const className = classNames(
'material-icons',
classes.root,
{
[classes[`color${capitalizeFirstLetter(color)}`]]: color !== 'inherit',
[classes[`color${capitalize(color)}`]]: color !== 'inherit',
[classes.fontSize]: fontSize,
},
classNameProp,
);
@@ -75,8 +49,32 @@ function Icon(props: ProvidedProps & Props) {
);
}
Icon.propTypes = {
/**
* The name of the icon font ligature.
*/
children: PropTypes.node,
/**
* 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.
*/
color: PropTypes.oneOf(['inherit', 'secondary', 'action', 'disabled', 'error', 'primary']),
/**
* If `true`, the icon size will be determined by the font-size.
*/
fontSize: PropTypes.bool,
};
Icon.defaultProps = {
color: 'inherit',
fontSize: false,
};
Icon.muiName = 'Icon';

View File

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