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,14 +1,11 @@
// @flow
import React from 'react';
import type { ElementType } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import warning from 'warning';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => {
export const styles = theme => {
const shadows = {};
theme.shadows.forEach((shadow, index) => {
shadows[`shadow${index}`] = {
boxShadow: shadow,
@@ -26,43 +23,11 @@ export const styles = (theme: Object) => {
};
};
type ProvidedProps = {
classes: Object,
component: ElementType,
elevation: number,
square: boolean,
};
export type Props = {
/**
* Useful to extend the style applied to components.
*/
classes?: Object,
/**
* @ignore
*/
className?: string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component?: ElementType,
/**
* Shadow depth, corresponds to `dp` in the spec.
* It's accepting values between 0 and 24 inclusive.
*/
elevation?: number,
/**
* If `true`, rounded corners are disabled.
*/
square?: boolean,
};
function Paper(props: ProvidedProps & Props) {
function Paper(props) {
const {
classes,
className: classNameProp,
component: ComponentProp,
component: Component,
square,
elevation,
...other
@@ -75,16 +40,45 @@ function Paper(props: ProvidedProps & Props) {
const className = classNames(
classes.root,
classes[`shadow${elevation >= 0 ? elevation : 0}`],
classes[`shadow${elevation}`],
{
[classes.rounded]: !square,
},
classNameProp,
);
return <ComponentProp className={className} {...other} />;
return <Component className={className} {...other} />;
}
Paper.propTypes = {
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* Shadow depth, corresponds to `dp` in the spec.
* It's accepting values between 0 and 24 inclusive.
*/
elevation: PropTypes.number,
/**
* If `true`, rounded corners are disabled.
*/
square: PropTypes.bool,
};
Paper.defaultProps = {
component: 'div',
elevation: 2,