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,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';