Skip to content

Commit 03868e8

Browse files
author
Dominic Coelho
committed
hide initial changes
1 parent 2ec9bf7 commit 03868e8

File tree

154 files changed

+16901
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+16901
-0
lines changed

es/actions/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createAction } from 'redux-actions';
2+
export var addFragment = createAction('ADD_FRAGMENT');
3+
export var updateFragment = createAction('UPDATE_FRAGMENT');
4+
export var updateRoute = createAction('UPDATE_ROUTE');
5+
export var setGlobalStyle = createAction('SET_GLOBAL_STYLE');

es/components/anim.js

+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2+
3+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
4+
5+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6+
7+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8+
9+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10+
11+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12+
13+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14+
15+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16+
17+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18+
19+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20+
21+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22+
23+
/* eslint-disable react/no-did-mount-set-state */
24+
import React, { Component } from 'react';
25+
import PropTypes from 'prop-types';
26+
import findKey from 'lodash/findKey';
27+
import { connect } from 'react-redux';
28+
import { findDOMNode } from 'react-dom';
29+
import { VictoryAnimation } from 'victory-core';
30+
import { victoryEases } from '../utils/types';
31+
32+
var Anim =
33+
/*#__PURE__*/
34+
function (_Component) {
35+
_inherits(Anim, _Component);
36+
37+
function Anim() {
38+
var _getPrototypeOf2;
39+
40+
var _this;
41+
42+
_classCallCheck(this, Anim);
43+
44+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
45+
args[_key] = arguments[_key];
46+
}
47+
48+
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Anim)).call.apply(_getPrototypeOf2, [this].concat(args)));
49+
50+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
51+
activeAnimation: -1
52+
});
53+
54+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "disableAnimation", function () {
55+
if (_this.state.activeAnimation !== _this.props.toStyle.length - 1) {
56+
_this.setState({
57+
activeAnimation: _this.props.toStyle.length - 1
58+
});
59+
}
60+
61+
return;
62+
});
63+
64+
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "updateAnimation", function (nextAnimation) {
65+
if (_this.state.activeAnimation !== nextAnimation) {
66+
_this.setState({
67+
activeAnimation: nextAnimation
68+
});
69+
}
70+
71+
return;
72+
});
73+
74+
return _this;
75+
}
76+
77+
_createClass(Anim, [{
78+
key: "componentDidMount",
79+
value: function componentDidMount() {
80+
var shouldDisableAnimation = this.props.route.params.indexOf('export') !== -1 || this.props.route.params.indexOf('overview') !== -1 || this.props.route.params.indexOf('notes') !== -1;
81+
82+
if (shouldDisableAnimation) {
83+
this.setState({
84+
activeAnimation: this.props.toStyle.length - 1
85+
});
86+
return;
87+
}
88+
89+
var order = this.props.order;
90+
var node = findDOMNode(this.fragmentRef);
91+
92+
if (!node.dataset) {
93+
node.dataset = {};
94+
}
95+
96+
node.dataset.order = order;
97+
node.dataset.animCount = this.props.toStyle.length;
98+
}
99+
}, {
100+
key: "componentDidUpdate",
101+
value: function componentDidUpdate(prevProps, prevState) {
102+
var shouldDisableAnimation = this.props.route.params.indexOf('export') !== -1 || this.props.route.params.indexOf('overview') !== -1 || this.props.route.params.indexOf('notes') !== -1;
103+
104+
if (shouldDisableAnimation) {
105+
this.disableAnimation();
106+
}
107+
108+
var animationStatus = this.getAnimationStatus();
109+
110+
if (animationStatus) {
111+
var nextAnimation = animationStatus.every(function (a) {
112+
return a === true;
113+
}) ? animationStatus.length - 1 : animationStatus.indexOf(false) - 1;
114+
115+
if (prevState.activeAnimation !== nextAnimation) {
116+
var state = this.props.fragment;
117+
var slide = prevProps.route.slide;
118+
this.context.stepCounter.setFragments(state.fragments[slide], slide);
119+
120+
if (prevProps.onAnim) {
121+
var forward = prevState.activeAnimation < nextAnimation;
122+
prevProps.onAnim(forward, nextAnimation);
123+
}
124+
125+
this.updateAnimation(nextAnimation);
126+
}
127+
}
128+
}
129+
}, {
130+
key: "getAnimationStatus",
131+
value: function getAnimationStatus() {
132+
var state = this.props.fragment;
133+
var slide = this.props.route.slide;
134+
var fragment = findDOMNode(this.fragmentRef);
135+
var key = findKey(state.fragments[slide], {
136+
id: "".concat(this.context.slideHash, "-").concat(parseInt(fragment.dataset.fid, 10))
137+
});
138+
139+
if (slide in state.fragments && state.fragments[slide].hasOwnProperty(key)) {
140+
return state.fragments[slide][key].animations;
141+
}
142+
143+
return null;
144+
}
145+
}, {
146+
key: "render",
147+
value: function render() {
148+
var _this2 = this;
149+
150+
var _this$props = this.props,
151+
children = _this$props.children,
152+
fromStyle = _this$props.fromStyle,
153+
toStyle = _this$props.toStyle,
154+
transitionDuration = _this$props.transitionDuration,
155+
easing = _this$props.easing,
156+
style = _this$props.style;
157+
var child = React.Children.only(children);
158+
var tweenData = this.state.activeAnimation === -1 ? fromStyle : toStyle[this.state.activeAnimation];
159+
return React.createElement(VictoryAnimation, {
160+
data: tweenData,
161+
duration: transitionDuration,
162+
easing: easing
163+
}, function (tweenStyle) {
164+
return React.cloneElement(child, {
165+
className: "fragment ".concat(child.props.className).trim(),
166+
style: _objectSpread({}, child.props.style, style, tweenStyle),
167+
ref: function ref(f) {
168+
_this2.fragmentRef = f;
169+
}
170+
});
171+
});
172+
}
173+
}]);
174+
175+
return Anim;
176+
}(Component);
177+
178+
Anim.defaultProps = {
179+
order: 0
180+
};
181+
Anim.propTypes = {
182+
children: PropTypes.node,
183+
easing: PropTypes.oneOf(victoryEases).isRequired,
184+
fragment: PropTypes.object,
185+
fromStyle: PropTypes.object.isRequired,
186+
onAnim: PropTypes.func,
187+
order: PropTypes.number,
188+
route: PropTypes.object,
189+
style: PropTypes.object,
190+
toStyle: PropTypes.arrayOf(PropTypes.object).isRequired,
191+
transitionDuration: PropTypes.number.isRequired
192+
};
193+
Anim.contextTypes = {
194+
export: PropTypes.bool,
195+
overview: PropTypes.bool,
196+
slide: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
197+
slideHash: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
198+
stepCounter: PropTypes.shape({
199+
setFragments: PropTypes.func
200+
})
201+
};
202+
export default connect(function (state) {
203+
return state;
204+
})(Anim);

es/components/appear.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2+
3+
function _extends() { _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; }; return _extends.apply(this, arguments); }
4+
5+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6+
7+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8+
9+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10+
11+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
12+
13+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14+
15+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16+
17+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
18+
19+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20+
21+
import React, { Component } from 'react';
22+
import PropTypes from 'prop-types';
23+
import Anim from './anim';
24+
import { victoryEases } from '../utils/types';
25+
26+
var Appear =
27+
/*#__PURE__*/
28+
function (_Component) {
29+
_inherits(Appear, _Component);
30+
31+
function Appear() {
32+
_classCallCheck(this, Appear);
33+
34+
return _possibleConstructorReturn(this, _getPrototypeOf(Appear).apply(this, arguments));
35+
}
36+
37+
_createClass(Appear, [{
38+
key: "render",
39+
value: function render() {
40+
var _this$props = this.props,
41+
transitionDuration = _this$props.transitionDuration,
42+
startValue = _this$props.startValue,
43+
endValue = _this$props.endValue,
44+
easing = _this$props.easing,
45+
style = _this$props.style;
46+
return React.createElement(Anim, _extends({}, this.props, {
47+
transitionDuration: transitionDuration,
48+
fromStyle: startValue,
49+
toStyle: [endValue],
50+
easing: easing,
51+
style: style
52+
}), this.props.children);
53+
}
54+
}]);
55+
56+
return Appear;
57+
}(Component);
58+
59+
Appear.defaultProps = {
60+
transitionDuration: 300,
61+
startValue: {
62+
opacity: 0,
63+
pointerEvents: 'none'
64+
},
65+
endValue: {
66+
opacity: 1,
67+
pointerEvents: 'auto'
68+
},
69+
easing: 'quadInOut'
70+
};
71+
Appear.propTypes = {
72+
children: PropTypes.node,
73+
easing: PropTypes.oneOf(victoryEases),
74+
endValue: PropTypes.object,
75+
fragment: PropTypes.object,
76+
order: PropTypes.number,
77+
startValue: PropTypes.object,
78+
style: PropTypes.object,
79+
transitionDuration: PropTypes.number
80+
};
81+
export default Appear;

es/components/autoplay-controls.js

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2+
3+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4+
5+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6+
7+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8+
9+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10+
11+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12+
13+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14+
15+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
16+
17+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18+
19+
import React, { Component } from 'react';
20+
import PropTypes from 'prop-types';
21+
import styled from 'react-emotion';
22+
var AutoplayButton =
23+
/*#__PURE__*/
24+
styled("button", {
25+
target: "ez7thfw0"
26+
})(function (_ref) {
27+
var styles = _ref.styles;
28+
return [{
29+
opacity: 0,
30+
cursor: 'pointer',
31+
transition: '300ms opacity ease',
32+
':hover': {
33+
opacity: 1
34+
}
35+
}, styles.context];
36+
});
37+
38+
var AutoplayControls =
39+
/*#__PURE__*/
40+
function (_Component) {
41+
_inherits(AutoplayControls, _Component);
42+
43+
function AutoplayControls() {
44+
_classCallCheck(this, AutoplayControls);
45+
46+
return _possibleConstructorReturn(this, _getPrototypeOf(AutoplayControls).apply(this, arguments));
47+
}
48+
49+
_createClass(AutoplayControls, [{
50+
key: "render",
51+
value: function render() {
52+
var pauseBtn = React.createElement(AutoplayButton, {
53+
type: "button",
54+
key: "pause",
55+
onClick: this.props.onPause,
56+
styles: {
57+
context: this.context.styles.autoplay.pause
58+
}
59+
}, React.createElement("svg", {
60+
style: this.context.styles.autoplay.pauseIcon,
61+
xmlns: "http://www.w3.org/2000/svg",
62+
width: "30px",
63+
height: "30px",
64+
viewBox: "0 0 30 30"
65+
}, React.createElement("path", {
66+
d: "M23.5,4V26h-6V4ZM6.5,26h6V4h-6Z"
67+
})));
68+
var playBtn = React.createElement(AutoplayButton, {
69+
type: "button",
70+
key: "play",
71+
onClick: this.props.onPlay,
72+
styles: {
73+
context: this.context.styles.autoplay.play
74+
}
75+
}, React.createElement("svg", {
76+
style: this.context.styles.autoplay.playIcon,
77+
xmlns: "http://www.w3.org/2000/svg",
78+
width: "30px",
79+
height: "30px",
80+
viewBox: "0 0 30 30"
81+
}, React.createElement("path", {
82+
d: "M26,15,6,25V5Z"
83+
})));
84+
return this.props.autoplaying ? pauseBtn : playBtn;
85+
}
86+
}]);
87+
88+
return AutoplayControls;
89+
}(Component);
90+
91+
export { AutoplayControls as default };
92+
AutoplayControls.propTypes = {
93+
autoplaying: PropTypes.bool,
94+
onPause: PropTypes.func,
95+
onPlay: PropTypes.func
96+
};
97+
AutoplayControls.contextTypes = {
98+
styles: PropTypes.object
99+
};

0 commit comments

Comments
 (0)