Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,20 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface GridListProps extends StandardProps<
React.HTMLAttributes<HTMLUListElement>,
GridListClassKey
> {
cellHeight?: number | 'auto';
cols?: number;
component?: React.ReactType;
spacing?: number;
}
export type GridListClassKey =
| 'root'
;
declare const GridList: React.ComponentType<GridListProps>;
export default GridList;

View File

@@ -0,0 +1,64 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
// weak
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = {
root: {
display: 'flex',
flexWrap: 'wrap',
overflowY: 'auto',
listStyle: 'none',
padding: 0,
WebkitOverflowScrolling: 'touch' // Add iOS momentum scrolling.
}
};
function GridList(props) {
const {
cols,
spacing,
cellHeight,
children,
classes,
className: classNameProp,
component: ComponentProp,
style
} = props,
other = _objectWithoutProperties(props, ['cols', 'spacing', 'cellHeight', 'children', 'classes', 'className', 'component', 'style']);
return React.createElement(
ComponentProp,
_extends({
className: classNames(classes.root, classNameProp),
style: _extends({ margin: -spacing / 2 }, style)
}, other),
React.Children.map(children, currentChild => {
const childCols = currentChild.props.cols || 1;
const childRows = currentChild.props.rows || 1;
return React.cloneElement(currentChild, {
style: _extends({
width: `${100 / cols * childCols}%`,
height: cellHeight === 'auto' ? 'auto' : cellHeight * childRows + spacing,
padding: spacing / 2
}, currentChild.props.style)
});
})
);
}
GridList.defaultProps = {
cols: 2,
spacing: 4,
cellHeight: 180,
component: 'ul'
};
export default withStyles(styles, { name: 'MuiGridList' })(GridList);

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface GridListTileProps extends StandardProps<
React.HTMLAttributes<HTMLLIElement>,
GridListTileClassKey
> {
cols?: number;
component?: React.ReactType;
rows?: number;
}
export type GridListTileClassKey =
| 'root'
| 'tile'
| 'imgFullHeight'
| 'imgFullWidth'
;
declare const GridListTile: React.ComponentType<GridListTileProps>;
export default GridListTile;

View File

@@ -0,0 +1,134 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
// weak
import React from 'react';
import classNames from 'classnames';
import EventListener from 'react-event-listener';
import debounce from 'lodash/debounce';
import withStyles from '../styles/withStyles';
export const styles = {
root: {
boxSizing: 'border-box',
flexShrink: 0
},
tile: {
position: 'relative',
display: 'block', // In case it's not renderd with a div.
height: '100%',
overflow: 'hidden'
},
imgFullHeight: {
height: '100%',
transform: 'translateX(-50%)',
position: 'relative',
left: '50%'
},
imgFullWidth: {
width: '100%',
position: 'relative',
transform: 'translateY(-50%)',
top: '50%'
}
};
class GridListTile extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.imgElement = null, this.handleResize = debounce(() => {
this.fit();
}, 166), this.fit = () => {
const imgElement = this.imgElement;
if (!imgElement) {
return;
}
if (!imgElement.complete) {
return;
}
if (imgElement.width / imgElement.height > imgElement.parentNode.offsetWidth / imgElement.parentNode.offsetHeight) {
imgElement.classList.remove(this.props.classes.imgFullWidth);
imgElement.classList.add(this.props.classes.imgFullHeight);
} else {
imgElement.classList.remove(this.props.classes.imgFullHeight);
imgElement.classList.add(this.props.classes.imgFullWidth);
}
imgElement.removeEventListener('load', this.fit);
}, _temp;
}
componentDidMount() {
this.ensureImageCover();
}
componentDidUpdate() {
this.ensureImageCover();
}
componentWillUnmount() {
this.handleResize.cancel();
}
ensureImageCover() {
if (!this.imgElement) {
return;
}
if (this.imgElement.complete) {
this.fit();
} else {
this.imgElement.addEventListener('load', this.fit);
}
}
render() {
const _props = this.props,
{
children,
classes,
className,
cols,
// $FlowFixMe - no idea why it cannot find component on intersection
component: ComponentProp,
rows
} = _props,
other = _objectWithoutProperties(_props, ['children', 'classes', 'className', 'cols', 'component', 'rows']);
return React.createElement(
ComponentProp,
_extends({ className: classNames(classes.root, className) }, other),
React.createElement(EventListener, { target: 'window', onResize: this.handleResize }),
React.createElement(
'div',
{ className: classes.tile },
React.Children.map(children, child => {
if (child.type === 'img') {
return React.cloneElement(child, {
key: 'img',
ref: node => {
this.imgElement = node;
}
});
}
return child;
})
)
);
}
}
GridListTile.defaultProps = {
cols: 1,
rows: 1,
component: 'li'
};
export default withStyles(styles, { name: 'MuiGridListTile' })(GridListTile);

View File

@@ -0,0 +1,29 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface GridListTileBarProps extends StandardProps<{}, GridListTileBarClassKey>
{
actionIcon?: React.ReactNode;
actionPosition?: 'left' | 'right';
subtitle?: React.ReactNode;
title?: React.ReactNode;
titlePosition?: 'top' | 'bottom';
}
export type GridListTileBarClassKey =
| 'root'
| 'rootBottom'
| 'rootTop'
| 'rootWithSubtitle'
| 'titleWrap'
| 'titleWrapActionLeft'
| 'titleWrapActionRight'
| 'title'
| 'subtitle'
| 'actionIconPositionLeft'
| 'childImg'
;
declare const GridListTileBar: React.ComponentType<GridListTileBarProps>;
export default GridListTileBar;

View File

@@ -0,0 +1,125 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
// weak
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = theme => ({
root: {
position: 'absolute',
left: 0,
right: 0,
height: 48,
background: 'rgba(0, 0, 0, 0.4)',
display: 'flex',
alignItems: 'center',
fontFamily: theme.typography.fontFamily
},
rootBottom: {
bottom: 0
},
rootTop: {
top: 0
},
rootWithSubtitle: {
height: 68
},
titleWrap: {
flexGrow: 1,
marginLeft: theme.mixins.gutters({}).paddingLeft,
marginRight: theme.mixins.gutters({}).paddingRight,
color: 'white',
overflow: 'hidden'
},
titleWrapActionLeft: {
marginLeft: 0
},
titleWrapActionRight: {
marginRight: 0
},
title: {
fontSize: theme.typography.pxToRem(16),
lineHeight: '24px',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap'
},
subtitle: {
fontSize: theme.typography.pxToRem(12),
lineHeight: 1,
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap'
},
actionIconPositionLeft: {
order: -1
},
childImg: {
height: '100%',
transform: 'translateX(-50%)',
position: 'relative',
left: '50%'
}
});
function GridListTileBar(props) {
const {
actionIcon,
actionPosition,
classes,
className: classNameProp,
subtitle,
title,
titlePosition
} = props,
other = _objectWithoutProperties(props, ['actionIcon', 'actionPosition', 'classes', 'className', 'subtitle', 'title', 'titlePosition']);
const actionPos = actionIcon && actionPosition;
const className = classNames(classes.root, {
[classes.rootBottom]: titlePosition === 'bottom',
[classes.rootTop]: titlePosition === 'top',
[classes.rootWithSubtitle]: subtitle
}, classNameProp);
// Remove the margin between the title / subtitle wrapper, and the Action Icon
const titleWrapClassName = classNames(classes.titleWrap, {
[classes.titleWrapActionLeft]: actionPos === 'left',
[classes.titleWrapActionRight]: actionPos === 'right'
});
return React.createElement(
'div',
_extends({ className: className }, other),
React.createElement(
'div',
{ className: titleWrapClassName },
React.createElement(
'div',
{ className: classes.title },
title
),
subtitle ? React.createElement(
'div',
{ className: classes.subtitle },
subtitle
) : null
),
actionIcon ? React.createElement(
'div',
{ className: classNames({ [classes.actionIconPositionLeft]: actionPos === 'left' }) },
actionIcon
) : null
);
}
GridListTileBar.defaultProps = {
actionPosition: 'right',
titlePosition: 'bottom'
};
export default withStyles(styles, { name: 'MuiGridListTileBar' })(GridListTileBar);

View File

@@ -0,0 +1,8 @@
export { default } from './GridList';
export * from './GridList';
export { default as GridList } from './GridList';
export * from './GridList';
export { default as GridListTile } from './GridListTile';
export * from './GridListTile';
export { default as GridListTileBar } from './GridListTileBar';
export * from './GridListTileBar';

View File

@@ -0,0 +1,4 @@
export { default } from './GridList';
export { default as GridList } from './GridList';
export { default as GridListTile } from './GridListTile';
export { default as GridListTileBar } from './GridListTileBar';