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,21 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface BottomNavigationProps extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
BottomNavigationClassKey,
'onChange'
> {
children: React.ReactNode;
onChange?: (event: React.ChangeEvent<{}>, value: any) => void;
showLabels?: boolean;
value?: any;
}
export type BottomNavigationClassKey =
| 'root'
;
declare const BottomNavigation: React.ComponentType<BottomNavigationProps>;
export default BottomNavigation;

View File

@@ -0,0 +1,55 @@
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: {
display: 'flex',
justifyContent: 'center',
height: 56,
backgroundColor: theme.palette.background.paper
}
});
function BottomNavigation(props) {
const {
children: childrenProp,
classes,
className: classNameProp,
onChange,
showLabels,
value
} = props,
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'onChange', 'showLabels', 'value']);
const className = classNames(classes.root, classNameProp);
const children = React.Children.map(childrenProp, (child, childIndex) => {
const childValue = child.props.value || childIndex;
return React.cloneElement(child, {
selected: childValue === value,
showLabel: child.props.showLabel !== undefined ? child.props.showLabel : showLabels,
value: childValue,
onChange
});
});
return React.createElement(
'div',
_extends({ className: className }, other),
children
);
}
BottomNavigation.defaultProps = {
showLabels: false
};
export default withStyles(styles, { name: 'MuiBottomNavigation' })(BottomNavigation);

View File

@@ -0,0 +1,32 @@
import * as React from 'react';
import { StandardProps } from '..';
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase';
export interface BottomNavigationButtonProps extends StandardProps<
ButtonBaseProps,
BottomNavigationButtonClassKey,
'onChange'
> {
icon?: string | React.ReactElement<any>;
label?: React.ReactNode;
onChange?: (event: React.ChangeEvent<{}>, value: any) => void;
onClick?: React.ReactEventHandler<any>;
selected?: boolean;
showLabel?: boolean;
value?: any;
}
export type BottomNavigationButtonClassKey =
| ButtonBaseClassKey
| 'selected'
| 'selectedIconOnly'
| 'wrapper'
| 'label'
| 'selectedLabel'
| 'hiddenLabel'
| 'icon'
;
declare const BottomNavigationButton: React.ComponentType<BottomNavigationButtonProps>;
export default BottomNavigationButton;

View File

@@ -0,0 +1,136 @@
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; }
// @inheritedComponent ButtonBase
import React from 'react';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import ButtonBase from '../ButtonBase';
import Icon from '../Icon';
export const styles = theme => ({
root: {
transition: theme.transitions.create(['color', 'padding-top'], {
duration: theme.transitions.duration.short
}),
paddingTop: 8,
paddingBottom: 10,
paddingLeft: 12,
paddingRight: 12,
minWidth: 80,
maxWidth: 168,
color: theme.palette.text.secondary,
flex: '1'
},
selected: {
paddingTop: 6,
color: theme.palette.primary[500]
},
selectedIconOnly: {
paddingTop: theme.spacing.unit * 2
},
wrapper: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
flexDirection: 'column'
},
label: {
fontFamily: theme.typography.fontFamily,
fontSize: theme.typography.pxToRem(theme.typography.fontSize - 2),
opacity: 1,
transition: 'font-size 0.2s, opacity 0.2s',
transitionDelay: '0.1s'
},
selectedLabel: {
fontSize: theme.typography.pxToRem(theme.typography.fontSize)
},
hiddenLabel: {
opacity: 0,
transitionDelay: '0s'
},
icon: {
display: 'block',
margin: 'auto'
}
});
class BottomNavigationButton extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.handleChange = event => {
const { onChange, value, onClick } = this.props;
if (onChange) {
onChange(event, value);
}
if (onClick) {
onClick(event);
}
}, _temp;
}
render() {
const _props = this.props,
{
label,
icon: iconProp,
selected,
classes,
className: classNameProp,
showLabel: showLabelProp,
onChange,
value
} = _props,
other = _objectWithoutProperties(_props, ['label', 'icon', 'selected', 'classes', 'className', 'showLabel', 'onChange', 'value']);
const className = classNames(classes.root, {
[classes.selected]: selected,
[classes.selectedIconOnly]: !showLabelProp && !selected
}, classNameProp);
let icon = null;
if (iconProp) {
if (React.isValidElement(iconProp) && typeof iconProp !== 'string') {
icon = React.cloneElement(iconProp, {
className: classNames(classes.icon, iconProp.props.className)
});
} else {
icon = React.createElement(
Icon,
null,
iconProp
);
}
}
const labelClassName = classNames(classes.label, {
[classes.selectedLabel]: selected,
[classes.hiddenLabel]: !showLabelProp && !selected
});
return React.createElement(
ButtonBase,
_extends({ className: className, focusRipple: true }, other, { onClick: this.handleChange }),
React.createElement(
'span',
{ className: classes.wrapper },
icon,
React.createElement(
'span',
{ className: labelClassName },
label
)
)
);
}
}
export default withStyles(styles, { name: 'MuiBottomNavigationButton' })(BottomNavigationButton);

View File

@@ -0,0 +1,4 @@
export { default } from './BottomNavigation';
export * from './BottomNavigation';
export { default as BottomNavigationButton } from './BottomNavigationButton';
export * from './BottomNavigationButton';

View File

@@ -0,0 +1,2 @@
export { default } from './BottomNavigation';
export { default as BottomNavigationButton } from './BottomNavigationButton';