Removed GopherJS, basic frontend completed, need backend changes for

torrent storage
This commit is contained in:
2017-11-30 18:12:11 -05:00
parent 67fdef16b1
commit e98ad2cc88
69321 changed files with 5498914 additions and 337 deletions

View File

@@ -0,0 +1,24 @@
import * as React from 'react';
import { StandardProps, Replace } from '..';
export interface ButtonBaseProps extends StandardProps<
Replace<React.AnchorHTMLAttributes<HTMLAnchorElement>, React.ButtonHTMLAttributes<HTMLButtonElement>>,
ButtonBaseClassKey
> {
centerRipple?: boolean;
component?: React.ReactType;
disableRipple?: boolean;
focusRipple?: boolean;
keyboardFocusedClassName?: string;
onKeyboardFocus?: React.FocusEventHandler<any>;
rootRef?: React.Ref<any>;
}
export type ButtonBaseClassKey =
| 'root'
| 'disabled'
;
declare const ButtonBase: React.ComponentType<ButtonBaseProps>;
export default ButtonBase;

View File

@@ -0,0 +1,239 @@
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 { findDOMNode } from 'react-dom';
import classNames from 'classnames';
import keycode from 'keycode';
import withStyles from '../styles/withStyles';
import { listenForFocusKeys, detectKeyboardFocus, focusKeyPressed } from '../utils/keyboardFocus';
import TouchRipple from './TouchRipple';
import createRippleHandler from './createRippleHandler';
export const styles = theme => ({
root: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
position: 'relative',
// Remove grey highlight
WebkitTapHighlightColor: theme.palette.common.transparent,
backgroundColor: 'transparent', // Reset default value
outline: 'none',
border: 0,
borderRadius: 0,
cursor: 'pointer',
userSelect: 'none',
appearance: 'none',
textDecoration: 'none',
// So we take precedent over the style of a native <a /> element.
color: 'inherit',
'&::-moz-focus-inner': {
borderStyle: 'none' // Remove Firefox dotted outline.
}
},
disabled: {
pointerEvents: 'none', // Disable link interactions
cursor: 'default'
}
});
class ButtonBase extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
keyboardFocused: false
}, this.onKeyboardFocusHandler = event => {
this.keyDown = false;
this.setState({ keyboardFocused: true });
if (this.props.onKeyboardFocus) {
this.props.onKeyboardFocus(event);
}
}, this.ripple = null, this.keyDown = false, this.button = null, this.keyboardFocusTimeout = null, this.keyboardFocusCheckTime = 30, this.keyboardFocusMaxCheckTimes = 5, this.handleKeyDown = event => {
const { component, focusRipple, onKeyDown, onClick } = this.props;
const key = keycode(event);
// Check if key is already down to avoid repeats being counted as multiple activations
if (focusRipple && !this.keyDown && this.state.keyboardFocused && key === 'space') {
this.keyDown = true;
event.persist();
this.ripple.stop(event, () => {
this.ripple.start(event);
});
}
if (onKeyDown) {
onKeyDown(event);
}
// Keyboard accessibility for non interactive elements
if (event.target === this.button && onClick && component && component !== 'a' && component !== 'button' && (key === 'space' || key === 'enter')) {
event.preventDefault();
onClick(event);
}
}, this.handleKeyUp = event => {
if (this.props.focusRipple && keycode(event) === 'space' && this.state.keyboardFocused) {
this.keyDown = false;
event.persist();
this.ripple.stop(event, () => this.ripple.pulsate(event));
}
if (this.props.onKeyUp) {
this.props.onKeyUp(event);
}
}, this.handleMouseDown = createRippleHandler(this, 'MouseDown', 'start', () => {
clearTimeout(this.keyboardFocusTimeout);
focusKeyPressed(false);
if (this.state.keyboardFocused) {
this.setState({ keyboardFocused: false });
}
}), this.handleMouseUp = createRippleHandler(this, 'MouseUp', 'stop'), this.handleMouseLeave = createRippleHandler(this, 'MouseLeave', 'stop', event => {
if (this.state.keyboardFocused) {
event.preventDefault();
}
}), this.handleTouchStart = createRippleHandler(this, 'TouchStart', 'start'), this.handleTouchEnd = createRippleHandler(this, 'TouchEnd', 'stop'), this.handleTouchMove = createRippleHandler(this, 'TouchEnd', 'stop'), this.handleBlur = createRippleHandler(this, 'Blur', 'stop', () => {
clearTimeout(this.keyboardFocusTimeout);
focusKeyPressed(false);
this.setState({ keyboardFocused: false });
}), this.handleFocus = event => {
if (this.props.disabled) {
return;
}
// Fix for https://github.com/facebook/react/issues/7769
if (!this.button) {
this.button = event.currentTarget;
}
event.persist();
const keyboardFocusCallback = this.onKeyboardFocusHandler.bind(this, event);
detectKeyboardFocus(this, this.button, keyboardFocusCallback);
if (this.props.onFocus) {
this.props.onFocus(event);
}
}, _temp;
}
componentDidMount() {
this.button = findDOMNode(this);
listenForFocusKeys();
}
componentWillUpdate(nextProps, nextState) {
if (this.props.focusRipple && nextState.keyboardFocused && !this.state.keyboardFocused && !this.props.disableRipple) {
this.ripple.pulsate();
}
}
componentWillUnmount() {
this.button = null;
clearTimeout(this.keyboardFocusTimeout);
} // Used to help track keyboard activation keyDown
renderRipple() {
if (!this.props.disableRipple && !this.props.disabled) {
return React.createElement(TouchRipple, {
innerRef: node => {
this.ripple = node;
},
center: this.props.centerRipple
});
}
return null;
}
render() {
const _props = this.props,
{
centerRipple,
children,
classes,
className: classNameProp,
component,
disabled,
disableRipple,
focusRipple,
keyboardFocusedClassName,
onBlur,
onFocus,
onKeyboardFocus,
onKeyDown,
onKeyUp,
onMouseDown,
onMouseLeave,
onMouseUp,
onTouchEnd,
onTouchMove,
onTouchStart,
rootRef,
tabIndex,
type
} = _props,
other = _objectWithoutProperties(_props, ['centerRipple', 'children', 'classes', 'className', 'component', 'disabled', 'disableRipple', 'focusRipple', 'keyboardFocusedClassName', 'onBlur', 'onFocus', 'onKeyboardFocus', 'onKeyDown', 'onKeyUp', 'onMouseDown', 'onMouseLeave', 'onMouseUp', 'onTouchEnd', 'onTouchMove', 'onTouchStart', 'rootRef', 'tabIndex', 'type']);
const className = classNames(classes.root, {
[classes.disabled]: disabled,
[keyboardFocusedClassName || '']: this.state.keyboardFocused
}, classNameProp);
const buttonProps = {};
let ComponentProp = component;
if (!ComponentProp) {
if (other.href) {
ComponentProp = 'a';
} else {
ComponentProp = 'button';
}
}
if (ComponentProp === 'button') {
buttonProps.type = type || 'button';
}
if (ComponentProp !== 'a') {
buttonProps.role = buttonProps.role || 'button';
buttonProps.disabled = disabled;
}
return React.createElement(
ComponentProp,
_extends({
onBlur: this.handleBlur,
onFocus: this.handleFocus,
onKeyDown: this.handleKeyDown,
onKeyUp: this.handleKeyUp,
onMouseDown: this.handleMouseDown,
onMouseLeave: this.handleMouseLeave,
onMouseUp: this.handleMouseUp,
onTouchEnd: this.handleTouchEnd,
onTouchMove: this.handleTouchMove,
onTouchStart: this.handleTouchStart,
tabIndex: disabled ? -1 : tabIndex,
className: className
}, buttonProps, other, {
ref: rootRef
}),
children,
this.renderRipple()
);
}
}
ButtonBase.defaultProps = {
centerRipple: false,
focusRipple: false,
disableRipple: false,
tabIndex: 0,
type: 'button'
};
export default withStyles(styles, { name: 'MuiButtonBase' })(ButtonBase);

View File

@@ -0,0 +1,79 @@
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 Transition from 'react-transition-group/Transition';
/**
* @ignore - internal component.
*/
class Ripple extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
rippleVisible: false,
rippleLeaving: false
}, this.getRippleStyles = props => {
const { rippleSize, rippleX, rippleY } = props;
return {
width: rippleSize,
height: rippleSize,
top: -(rippleSize / 2) + rippleY,
left: -(rippleSize / 2) + rippleX
};
}, this.handleEnter = () => {
this.setState({
rippleVisible: true
});
}, this.handleExit = () => {
this.setState({
rippleLeaving: true
});
}, _temp;
}
render() {
const _props = this.props,
{
classes,
className: classNameProp,
pulsate,
rippleX,
rippleY,
rippleSize
} = _props,
other = _objectWithoutProperties(_props, ['classes', 'className', 'pulsate', 'rippleX', 'rippleY', 'rippleSize']);
const { rippleVisible, rippleLeaving } = this.state;
const className = classNames(classes.wrapper, {
[classes.wrapperLeaving]: rippleLeaving,
[classes.wrapperPulsating]: pulsate
}, classNameProp);
const rippleClassName = classNames(classes.ripple, {
[classes.rippleVisible]: rippleVisible,
[classes.rippleFast]: pulsate
});
return React.createElement(
Transition,
_extends({ onEnter: this.handleEnter, onExit: this.handleExit }, other),
React.createElement(
'span',
{ className: className },
React.createElement('span', { className: rippleClassName, style: this.getRippleStyles(this.props) })
)
);
}
}
Ripple.defaultProps = {
pulsate: false
};
export default Ripple;

View File

@@ -0,0 +1,260 @@
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 ReactDOM from 'react-dom';
import TransitionGroup from 'react-transition-group/TransitionGroup';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import Ripple from './Ripple';
const DURATION = 550;
export const DELAY_RIPPLE = 80;
export const styles = theme => ({
root: {
display: 'block',
position: 'absolute',
overflow: 'hidden',
borderRadius: 'inherit',
width: '100%',
height: '100%',
left: 0,
top: 0,
pointerEvents: 'none',
zIndex: 0
},
wrapper: {
opacity: 1
},
wrapperLeaving: {
opacity: 0,
animation: `mui-ripple-exit ${DURATION}ms ${theme.transitions.easing.easeInOut}`
},
wrapperPulsating: {
position: 'absolute',
left: 0,
top: 0,
display: 'block',
width: '100%',
height: '100%',
animation: `mui-ripple-pulsate 1500ms ${theme.transitions.easing.easeInOut} 200ms infinite`,
rippleVisible: {
opacity: 0.2
}
},
'@keyframes mui-ripple-enter': {
'0%': {
transform: 'scale(0)'
},
'100%': {
transform: 'scale(1)'
}
},
'@keyframes mui-ripple-exit': {
'0%': {
opacity: 1
},
'100%': {
opacity: 0
}
},
'@keyframes mui-ripple-pulsate': {
'0%': {
transform: 'scale(1)'
},
'50%': {
transform: 'scale(0.9)'
},
'100%': {
transform: 'scale(1)'
}
},
ripple: {
width: 50,
height: 50,
left: 0,
top: 0,
opacity: 0,
position: 'absolute',
borderRadius: '50%',
background: 'currentColor'
},
rippleVisible: {
opacity: 0.3,
transform: 'scale(1)',
animation: `mui-ripple-enter ${DURATION}ms ${theme.transitions.easing.easeInOut}`
},
rippleFast: {
animationDuration: '200ms'
}
});
/**
* @ignore - internal component.
*/
class TouchRipple extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = {
nextKey: 0,
ripples: []
}, this.ignoringMouseDown = false, this.startTimer = null, this.startTimerCommit = null, this.pulsate = () => {
this.start({}, { pulsate: true });
}, this.start = (event = {}, options = {}, cb) => {
const {
pulsate = false,
center = this.props.center || options.pulsate,
fakeElement = false // For test purposes
} = options;
if (event.type === 'mousedown' && this.ignoringMouseDown) {
this.ignoringMouseDown = false;
return;
}
if (event.type === 'touchstart') {
this.ignoringMouseDown = true;
}
const element = fakeElement ? null : ReactDOM.findDOMNode(this);
const rect = element ? // $FlowFixMe
element.getBoundingClientRect() : {
width: 0,
height: 0,
left: 0,
top: 0
};
// Get the size of the ripple
let rippleX;
let rippleY;
let rippleSize;
if (center || event.clientX === 0 && event.clientY === 0 || !event.clientX && !event.touches) {
rippleX = Math.round(rect.width / 2);
rippleY = Math.round(rect.height / 2);
} else {
const clientX = event.clientX ? event.clientX : event.touches[0].clientX;
const clientY = event.clientY ? event.clientY : event.touches[0].clientY;
rippleX = Math.round(clientX - rect.left);
rippleY = Math.round(clientY - rect.top);
}
if (center) {
rippleSize = Math.sqrt((2 * Math.pow(rect.width, 2) + Math.pow(rect.height, 2)) / 3);
// For some reason the animation is broken on Mobile Chrome if the size if even.
if (rippleSize % 2 === 0) {
rippleSize += 1;
}
} else {
const sizeX = Math.max(
// $FlowFixMe
Math.abs((element ? element.clientWidth : 0) - rippleX), rippleX) * 2 + 2;
const sizeY = Math.max(
// $FlowFixMe
Math.abs((element ? element.clientHeight : 0) - rippleY), rippleY) * 2 + 2;
rippleSize = Math.sqrt(Math.pow(sizeX, 2) + Math.pow(sizeY, 2));
}
// Touche devices
if (event.touches) {
// Prepare the ripple effect.
this.startTimerCommit = () => {
this.startCommit({ pulsate, rippleX, rippleY, rippleSize, cb });
};
// Deplay the execution of the ripple effect.
this.startTimer = setTimeout(() => {
this.startTimerCommit();
this.startTimerCommit = null;
}, DELAY_RIPPLE); // We have to make a tradeoff with this value.
} else {
this.startCommit({ pulsate, rippleX, rippleY, rippleSize, cb });
}
}, this.startCommit = params => {
const { pulsate, rippleX, rippleY, rippleSize, cb } = params;
let ripples = this.state.ripples;
// Add a ripple to the ripples array
ripples = [...ripples, React.createElement(Ripple, {
key: this.state.nextKey,
classes: this.props.classes,
timeout: {
exit: DURATION,
enter: DURATION
},
pulsate: pulsate,
rippleX: rippleX,
rippleY: rippleY,
rippleSize: rippleSize
})];
this.setState({
nextKey: this.state.nextKey + 1,
ripples
}, cb);
}, this.stop = (event, cb) => {
clearTimeout(this.startTimer);
const { ripples } = this.state;
// The touch interaction occures to quickly.
// We still want to show ripple effect.
if (event.type === 'touchend' && this.startTimerCommit) {
event.persist();
this.startTimerCommit();
this.startTimerCommit = null;
this.startTimer = setTimeout(() => {
this.stop(event, cb);
}, 0);
return;
}
this.startTimerCommit = null;
if (ripples && ripples.length) {
this.setState({
ripples: ripples.slice(1)
}, cb);
}
}, _temp;
}
componentWillUnmount() {
clearTimeout(this.startTimer);
}
// Used to filter out mouse emulated events on mobile.
// We use a timer in order to only show the ripples for touch "click" like events.
// We don't want to display the ripple for touch scroll events.
// This is the hook called once the previous timeout is ready.
render() {
const _props = this.props,
{ center, classes, className } = _props,
other = _objectWithoutProperties(_props, ['center', 'classes', 'className']);
return React.createElement(
TransitionGroup,
_extends({
component: 'span',
enter: true,
exit: true,
className: classNames(classes.root, className)
}, other),
this.state.ripples
);
}
}
TouchRipple.defaultProps = {
center: false
};
export default withStyles(styles, { flip: false, name: 'MuiTouchRipple' })(TouchRipple);

View File

@@ -0,0 +1,23 @@
function createRippleHandler(instance, eventName, action, cb) {
return function handleEvent(event) {
if (cb) {
cb.call(instance, event);
}
if (event.defaultPrevented) {
return false;
}
if (instance.ripple) {
instance.ripple[action](event);
}
if (instance.props && typeof instance.props[`on${eventName}`] === 'function') {
instance.props[`on${eventName}`](event);
}
return true;
};
}
export default createRippleHandler;

View File

@@ -0,0 +1,2 @@
export { default } from './ButtonBase';
export * from './ButtonBase';

View File

@@ -0,0 +1 @@
export { default } from './ButtonBase';