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,12 +1,9 @@
// @flow
import React from 'react';
import type { Node, ElementType } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = (theme: Object) => ({
export const styles = theme => ({
root: {
color: 'inherit',
display: 'table-row',
@@ -16,70 +13,36 @@ export const styles = (theme: Object) => ({
},
verticalAlign: 'middle',
},
head: {
typeHead: {
height: 56,
},
footer: {
typeFooter: {
height: 56,
},
selected: {
backgroundColor:
theme.palette.type === 'light'
? 'rgba(0, 0, 0, 0.04)' // grey[100]
: 'rgba(255, 255, 255, 0.08)',
},
hover: {
'&:hover': {
background: theme.palette.background.contentFrame,
backgroundColor:
theme.palette.type === 'light'
? 'rgba(0, 0, 0, 0.07)' // grey[200]
: 'rgba(255, 255, 255, 0.14)',
},
},
selected: {
background: theme.palette.background.appBar,
},
});
export type Context = {
table: Object,
};
type ProvidedProps = {
classes: Object,
component: ElementType,
hover: boolean,
selected: boolean,
};
export type Props = {
/**
* Should be valid `<tr>` children such as `TableCell`.
*/
children?: Node,
/**
* 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,
/**
* If `true`, the table row will shade on hover.
*/
hover?: boolean,
/**
* If `true`, the table row will have the selected shading.
*/
selected?: boolean,
};
/**
* Will automatically set dynamic row height
* based on the material table element parent (head, body, etc).
*/
function TableRow(props: ProvidedProps & Props, context: Context) {
function TableRow(props, context) {
const {
classes,
className: classNameProp,
children,
component: Component,
hover,
selected,
@@ -90,25 +53,49 @@ function TableRow(props: ProvidedProps & Props, context: Context) {
const className = classNames(
classes.root,
{
[classes.head]: table && table.head,
[classes.footer]: table && table.footer,
[classes.typeHead]: table && table.head,
[classes.typeFooter]: table && table.footer,
[classes.hover]: table && hover,
[classes.selected]: table && selected,
},
classNameProp,
);
return (
<Component className={className} {...other}>
{children}
</Component>
);
return <Component className={className} {...other} />;
}
TableRow.propTypes = {
/**
* Should be valid `<tr>` children such as `TableCell`.
*/
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]),
/**
* If `true`, the table row will shade on hover.
*/
hover: PropTypes.bool,
/**
* If `true`, the table row will have the selected shading.
*/
selected: PropTypes.bool,
};
TableRow.defaultProps = {
component: 'tr',
hover: false,
selected: false,
component: 'tr',
};
TableRow.contextTypes = {