playball 2.2.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +2 -2
- package/README.md +18 -4
- package/demo.cast +95 -0
- package/demo.gif +0 -0
- package/dist/components/AllPlays.js +94 -93
- package/dist/components/App.js +45 -117
- package/dist/components/AtBat.js +44 -43
- package/dist/components/Bases.js +17 -26
- package/dist/components/Count.js +15 -26
- package/dist/components/FinishedGame.js +51 -66
- package/dist/components/Game.js +51 -114
- package/dist/components/GameList.js +161 -134
- package/dist/components/Grid.js +115 -0
- package/dist/components/HelpBar.js +13 -6
- package/dist/components/InningDisplay.js +26 -0
- package/dist/components/LineScore.js +32 -90
- package/dist/components/LiveGame.js +24 -19
- package/dist/components/LoadingSpinner.js +34 -125
- package/dist/components/Matchup.js +38 -59
- package/dist/components/PreviewGame.js +34 -52
- package/dist/components/Standings.js +91 -0
- package/dist/features/games.js +135 -0
- package/dist/features/keys.js +63 -0
- package/dist/features/schedule.js +58 -0
- package/dist/features/standings.js +57 -0
- package/dist/hooks/useKey.js +23 -0
- package/dist/logger.js +8 -10
- package/dist/main.js +13 -23
- package/dist/screen.js +22 -0
- package/dist/store/index.js +21 -7
- package/dist/style/index.js +3 -3
- package/package.json +44 -26
- package/src/components/AllPlays.jsx +95 -63
- package/src/components/App.jsx +38 -66
- package/src/components/AtBat.jsx +34 -36
- package/src/components/Bases.jsx +8 -13
- package/src/components/Count.jsx +10 -15
- package/src/components/FinishedGame.jsx +29 -40
- package/src/components/Game.jsx +48 -65
- package/src/components/GameList.jsx +128 -82
- package/src/components/Grid.jsx +91 -0
- package/src/components/HelpBar.jsx +14 -9
- package/src/components/InningDisplay.jsx +19 -0
- package/src/components/LineScore.jsx +27 -33
- package/src/components/LiveGame.jsx +7 -3
- package/src/components/LoadingSpinner.jsx +26 -60
- package/src/components/Matchup.jsx +26 -39
- package/src/components/PreviewGame.jsx +22 -33
- package/src/components/Standings.jsx +78 -0
- package/src/features/games.js +165 -0
- package/src/features/keys.js +38 -0
- package/src/features/schedule.js +59 -0
- package/src/features/standings.js +60 -0
- package/src/hooks/useKey.js +13 -0
- package/src/main.js +7 -14
- package/src/screen.js +14 -0
- package/src/store/index.js +16 -7
- package/src/style/index.js +1 -1
- package/dist/actions/game.js +0 -36
- package/dist/actions/schedule.js +0 -31
- package/dist/actions/types.js +0 -16
- package/dist/reducers/game.js +0 -70
- package/dist/reducers/index.js +0 -21
- package/dist/reducers/schedule.js +0 -35
- package/dist/selectors/game.js +0 -82
- package/dist/selectors/schedule.js +0 -25
- package/src/actions/game.js +0 -25
- package/src/actions/schedule.js +0 -19
- package/src/actions/types.js +0 -5
- package/src/reducers/game.js +0 -56
- package/src/reducers/index.js +0 -9
- package/src/reducers/schedule.js +0 -28
- package/src/selectors/game.js +0 -93
- package/src/selectors/schedule.js +0 -18
|
@@ -3,42 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _games = require("../features/games");
|
|
15
15
|
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : {
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
|
-
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); } }
|
|
23
|
-
|
|
24
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
25
|
-
|
|
26
|
-
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); }
|
|
27
|
-
|
|
28
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
-
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
31
|
-
|
|
32
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
-
|
|
34
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
-
|
|
36
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
-
|
|
38
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
-
|
|
40
|
-
var getRuns = function getRuns(inning, homeAway, isFinal) {
|
|
41
|
-
var runs = inning.getIn([homeAway, 'runs']);
|
|
18
|
+
const getRuns = (inning, homeAway, isFinal) => {
|
|
19
|
+
const runs = inning[homeAway].runs;
|
|
42
20
|
|
|
43
21
|
if (runs !== undefined) {
|
|
44
22
|
return runs;
|
|
@@ -47,72 +25,36 @@ var getRuns = function getRuns(inning, homeAway, isFinal) {
|
|
|
47
25
|
return isFinal ? 'X' : '';
|
|
48
26
|
};
|
|
49
27
|
|
|
50
|
-
|
|
51
|
-
return linescore.get('innings').map(function (inning) {
|
|
52
|
-
return getRuns(inning, homeAway, _final);
|
|
53
|
-
}).map(function (r) {
|
|
54
|
-
return r.toString().padStart(2);
|
|
55
|
-
}).join(' ').padEnd(totalInnings * 3) + '{bold}' + linescore.getIn(['teams', homeAway, 'runs']).toString().padStart(3) + '{/bold}' + linescore.getIn(['teams', homeAway, 'hits']).toString().padStart(3) + linescore.getIn(['teams', homeAway, 'errors']).toString().padStart(3);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
var LineScore = /*#__PURE__*/function (_React$Component) {
|
|
59
|
-
_inherits(LineScore, _React$Component);
|
|
60
|
-
|
|
61
|
-
var _super = _createSuper(LineScore);
|
|
28
|
+
const getTeamLine = (linescore, totalInnings, homeAway, final) => linescore.innings.map(inning => getRuns(inning, homeAway, final)).map(r => r.toString().padStart(2)).join(' ').padEnd(totalInnings * 3) + '{bold}' + linescore.teams[homeAway].runs.toString().padStart(3) + '{/bold}' + linescore.teams[homeAway].hits.toString().padStart(3) + linescore.teams[homeAway].errors.toString().padStart(3);
|
|
62
29
|
|
|
63
|
-
|
|
64
|
-
|
|
30
|
+
function LineScore({
|
|
31
|
+
align,
|
|
32
|
+
final
|
|
33
|
+
}) {
|
|
34
|
+
const linescore = (0, _alternateRenderers.useSelector)(_games.selectLineScore);
|
|
35
|
+
const teams = (0, _alternateRenderers.useSelector)(_games.selectTeams);
|
|
36
|
+
const currentInning = linescore.currentInning;
|
|
65
37
|
|
|
66
|
-
|
|
38
|
+
if (!currentInning) {
|
|
39
|
+
return '';
|
|
67
40
|
}
|
|
68
41
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
var totalInnings = Math.max(currentInning, 9);
|
|
84
|
-
var home = teams.getIn(['home', 'abbreviation']);
|
|
85
|
-
var away = teams.getIn(['away', 'abbreviation']);
|
|
86
|
-
var teamNameLength = 3;
|
|
87
|
-
var str = ''.padEnd(teamNameLength) + Array.from(Array(totalInnings).keys()).map(function (i) {
|
|
88
|
-
return (i + 1).toString().padStart(2);
|
|
89
|
-
}).join(' ') + ' {bold}R{/bold} H E\n' + away.padEnd(teamNameLength) + getTeamLine(linescore, totalInnings, 'away', _final2) + '\n' + home.padEnd(teamNameLength) + getTeamLine(linescore, totalInnings, 'home', _final2);
|
|
90
|
-
return /*#__PURE__*/_react["default"].createElement("box", {
|
|
91
|
-
align: align,
|
|
92
|
-
content: str,
|
|
93
|
-
tags: true,
|
|
94
|
-
wrap: false
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}]);
|
|
98
|
-
|
|
99
|
-
return LineScore;
|
|
100
|
-
}(_react["default"].Component);
|
|
42
|
+
const totalInnings = Math.max(currentInning, 9);
|
|
43
|
+
const home = teams.home.abbreviation;
|
|
44
|
+
const away = teams.away.abbreviation;
|
|
45
|
+
const teamNameLength = 3;
|
|
46
|
+
let str = ''.padEnd(teamNameLength) + Array.from(Array(totalInnings).keys()).map(i => (i + 1).toString().padStart(2)).join(' ') + ' {bold}R{/bold} H E\n' + away.padEnd(teamNameLength) + getTeamLine(linescore, totalInnings, 'away', final) + '\n' + home.padEnd(teamNameLength) + getTeamLine(linescore, totalInnings, 'home', final);
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement("box", {
|
|
48
|
+
align: align,
|
|
49
|
+
content: str,
|
|
50
|
+
tags: true,
|
|
51
|
+
wrap: false
|
|
52
|
+
});
|
|
53
|
+
}
|
|
101
54
|
|
|
102
55
|
LineScore.propTypes = {
|
|
103
|
-
align: _propTypes
|
|
104
|
-
|
|
105
|
-
linescore: _propTypes["default"].object,
|
|
106
|
-
teams: _propTypes["default"].object
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
var mapStateToProps = function mapStateToProps(state) {
|
|
110
|
-
return {
|
|
111
|
-
linescore: (0, _game.selectLineScore)(state),
|
|
112
|
-
teams: (0, _game.selectTeams)(state)
|
|
113
|
-
};
|
|
56
|
+
align: _propTypes.default.oneOf(['left', 'center', 'right']),
|
|
57
|
+
final: _propTypes.default.bool
|
|
114
58
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
exports["default"] = _default;
|
|
59
|
+
var _default = LineScore;
|
|
60
|
+
exports.default = _default;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -19,47 +19,52 @@ var _AtBat = _interopRequireDefault(require("./AtBat"));
|
|
|
19
19
|
|
|
20
20
|
var _AllPlays = _interopRequireDefault(require("./AllPlays"));
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
var _InningDisplay = _interopRequireDefault(require("./InningDisplay"));
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
function LiveGame() {
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement("element", null, /*#__PURE__*/_react.default.createElement("element", {
|
|
26
28
|
top: 0,
|
|
27
29
|
left: 1,
|
|
28
30
|
width: "100%-1",
|
|
29
31
|
height: 3
|
|
30
|
-
}, /*#__PURE__*/_react
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement("element", {
|
|
33
|
+
left: 0,
|
|
34
|
+
width: 2
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_InningDisplay.default, null)), /*#__PURE__*/_react.default.createElement("element", {
|
|
36
|
+
left: 5,
|
|
37
|
+
width: "25%-5"
|
|
38
|
+
}, /*#__PURE__*/_react.default.createElement(_Count.default, null)), /*#__PURE__*/_react.default.createElement("element", {
|
|
33
39
|
left: "25%+1",
|
|
34
40
|
width: "25%"
|
|
35
|
-
}, /*#__PURE__*/_react
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_Bases.default, null)), /*#__PURE__*/_react.default.createElement("element", {
|
|
36
42
|
left: "50%+2",
|
|
37
43
|
width: "50%-2"
|
|
38
|
-
}, /*#__PURE__*/_react
|
|
44
|
+
}, /*#__PURE__*/_react.default.createElement(_LineScore.default, null))), /*#__PURE__*/_react.default.createElement("line", {
|
|
39
45
|
orientation: "horizontal",
|
|
40
46
|
type: "line",
|
|
41
47
|
top: 3,
|
|
42
48
|
width: "100%"
|
|
43
|
-
}), /*#__PURE__*/_react
|
|
49
|
+
}), /*#__PURE__*/_react.default.createElement("element", {
|
|
44
50
|
top: 4,
|
|
45
51
|
left: 1
|
|
46
|
-
}, /*#__PURE__*/_react
|
|
52
|
+
}, /*#__PURE__*/_react.default.createElement("element", {
|
|
47
53
|
width: "50%-1"
|
|
48
|
-
}, /*#__PURE__*/_react
|
|
54
|
+
}, /*#__PURE__*/_react.default.createElement("element", {
|
|
49
55
|
top: 0,
|
|
50
56
|
height: 2
|
|
51
|
-
}, /*#__PURE__*/_react
|
|
57
|
+
}, /*#__PURE__*/_react.default.createElement(_Matchup.default, null)), /*#__PURE__*/_react.default.createElement("element", {
|
|
52
58
|
top: 3
|
|
53
|
-
}, /*#__PURE__*/_react
|
|
59
|
+
}, /*#__PURE__*/_react.default.createElement(_AtBat.default, null))), /*#__PURE__*/_react.default.createElement("line", {
|
|
54
60
|
orientation: "vertical",
|
|
55
61
|
type: "line",
|
|
56
62
|
left: "50%"
|
|
57
|
-
}), /*#__PURE__*/_react
|
|
63
|
+
}), /*#__PURE__*/_react.default.createElement("element", {
|
|
58
64
|
left: "50%+2",
|
|
59
65
|
width: "50%-2"
|
|
60
|
-
}, /*#__PURE__*/_react
|
|
61
|
-
}
|
|
66
|
+
}, /*#__PURE__*/_react.default.createElement(_AllPlays.default, null))));
|
|
67
|
+
}
|
|
62
68
|
|
|
63
|
-
exports.LiveGame = LiveGame;
|
|
64
69
|
var _default = LiveGame;
|
|
65
|
-
exports
|
|
70
|
+
exports.default = _default;
|
|
@@ -3,144 +3,53 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _schedule = require("../features/schedule");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _games = require("../features/games");
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
21
21
|
|
|
22
|
-
function
|
|
22
|
+
function LoadingSpinner() {
|
|
23
|
+
const [frame, setFrame] = (0, _react.useState)(0);
|
|
24
|
+
const [animating, setAnimating] = (0, _react.useState)(false);
|
|
25
|
+
const timerRef = (0, _react.useRef)(null);
|
|
26
|
+
const scheduleLoading = (0, _alternateRenderers.useSelector)(_schedule.selectLoading);
|
|
27
|
+
const gameLoading = (0, _alternateRenderers.useSelector)(_games.selectLoading);
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
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); }
|
|
29
|
-
|
|
30
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
-
|
|
32
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
-
|
|
34
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
35
|
-
|
|
36
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
-
|
|
38
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
-
|
|
40
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
-
|
|
42
|
-
var frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
43
|
-
|
|
44
|
-
var LoadingSpinner = /*#__PURE__*/function (_React$Component) {
|
|
45
|
-
_inherits(LoadingSpinner, _React$Component);
|
|
46
|
-
|
|
47
|
-
var _super = _createSuper(LoadingSpinner);
|
|
48
|
-
|
|
49
|
-
function LoadingSpinner(props) {
|
|
50
|
-
var _this;
|
|
51
|
-
|
|
52
|
-
_classCallCheck(this, LoadingSpinner);
|
|
53
|
-
|
|
54
|
-
_this = _super.call(this, props);
|
|
55
|
-
_this.state = {
|
|
56
|
-
frame: 0,
|
|
57
|
-
animating: false
|
|
58
|
-
};
|
|
59
|
-
return _this;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
_createClass(LoadingSpinner, [{
|
|
63
|
-
key: "componentDidMount",
|
|
64
|
-
value: function componentDidMount() {
|
|
65
|
-
this.doUpdate();
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "componentDidUpdate",
|
|
69
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
70
|
-
var _this$props = this.props,
|
|
71
|
-
gameLoading = _this$props.gameLoading,
|
|
72
|
-
scheduleLoading = _this$props.scheduleLoading;
|
|
73
|
-
var frame = this.state.frame;
|
|
29
|
+
const increment = () => {
|
|
30
|
+
setFrame(prevFrame => (prevFrame + 1) % frames.length);
|
|
31
|
+
};
|
|
74
32
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
key: "increment",
|
|
81
|
-
value: function increment() {
|
|
82
|
-
this.setState(function (state) {
|
|
83
|
-
return {
|
|
84
|
-
frame: (state.frame + 1) % frames.length
|
|
85
|
-
};
|
|
86
|
-
});
|
|
33
|
+
const doUpdate = () => {
|
|
34
|
+
if (!animating && (gameLoading || scheduleLoading)) {
|
|
35
|
+
setAnimating(true);
|
|
36
|
+
increment();
|
|
37
|
+
timerRef.current = setInterval(increment, 50);
|
|
87
38
|
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "doUpdate",
|
|
90
|
-
value: function doUpdate() {
|
|
91
|
-
var _this2 = this;
|
|
92
39
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var _this$state = this.state,
|
|
97
|
-
animating = _this$state.animating,
|
|
98
|
-
frame = _this$state.frame;
|
|
99
|
-
|
|
100
|
-
if (!animating && (gameLoading || scheduleLoading)) {
|
|
101
|
-
this.setState({
|
|
102
|
-
animating: true
|
|
103
|
-
});
|
|
104
|
-
this.increment();
|
|
105
|
-
this.timer = setInterval(function () {
|
|
106
|
-
return _this2.increment();
|
|
107
|
-
}, 50);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!gameLoading && !scheduleLoading && frame === 0) {
|
|
111
|
-
this.setState({
|
|
112
|
-
animating: false
|
|
113
|
-
});
|
|
114
|
-
clearInterval(this.timer);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "render",
|
|
119
|
-
value: function render() {
|
|
120
|
-
var _this$state2 = this.state,
|
|
121
|
-
animating = _this$state2.animating,
|
|
122
|
-
frame = _this$state2.frame;
|
|
123
|
-
return /*#__PURE__*/_react["default"].createElement("box", {
|
|
124
|
-
content: animating ? frames[frame] : ' '
|
|
125
|
-
});
|
|
40
|
+
if (!gameLoading && !scheduleLoading && frame === 0) {
|
|
41
|
+
setAnimating(false);
|
|
42
|
+
clearInterval(timerRef.current);
|
|
126
43
|
}
|
|
127
|
-
}]);
|
|
128
|
-
|
|
129
|
-
return LoadingSpinner;
|
|
130
|
-
}(_react["default"].Component);
|
|
131
|
-
|
|
132
|
-
LoadingSpinner.propTypes = {
|
|
133
|
-
gameLoading: _propTypes["default"].bool,
|
|
134
|
-
scheduleLoading: _propTypes["default"].bool
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
var mapStateToProps = function mapStateToProps(state) {
|
|
138
|
-
return {
|
|
139
|
-
gameLoading: (0, _game.selectLoading)(state),
|
|
140
|
-
scheduleLoading: (0, _schedule.selectLoading)(state)
|
|
141
44
|
};
|
|
142
|
-
};
|
|
143
45
|
|
|
144
|
-
|
|
46
|
+
(0, _react.useEffect)(() => {
|
|
47
|
+
doUpdate();
|
|
48
|
+
}, [gameLoading, scheduleLoading, frame]);
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement("box", {
|
|
50
|
+
content: animating ? frames[frame] : ' '
|
|
51
|
+
});
|
|
52
|
+
}
|
|
145
53
|
|
|
146
|
-
|
|
54
|
+
var _default = LoadingSpinner;
|
|
55
|
+
exports.default = _default;
|
|
@@ -3,77 +3,56 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _alternateRenderers = require("react-redux/lib/alternate-renderers");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _games = require("../features/games");
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const getPlayerStats = (boxscore, teams, id) => {
|
|
17
|
+
const key = 'ID' + id;
|
|
18
|
+
const homePlayers = boxscore.home.players;
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
var key = 'ID' + id;
|
|
20
|
-
var homePlayers = boxscore.getIn(['home', 'players']);
|
|
21
|
-
|
|
22
|
-
if (homePlayers.has(key)) {
|
|
20
|
+
if (homePlayers[key]) {
|
|
23
21
|
return {
|
|
24
|
-
team: teams.
|
|
25
|
-
player: homePlayers
|
|
22
|
+
team: teams.home,
|
|
23
|
+
player: homePlayers[key]
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
return {
|
|
30
|
-
team: teams.
|
|
31
|
-
player: boxscore.
|
|
28
|
+
team: teams.away,
|
|
29
|
+
player: boxscore.away.players[key]
|
|
32
30
|
};
|
|
33
31
|
};
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
Matchup.propTypes = {
|
|
64
|
-
boxscore: _propTypes["default"].object,
|
|
65
|
-
currentPlay: _propTypes["default"].object,
|
|
66
|
-
teams: _propTypes["default"].object
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var mapStateToProps = function mapStateToProps(state) {
|
|
70
|
-
return {
|
|
71
|
-
boxscore: (0, _game.selectBoxscore)(state),
|
|
72
|
-
currentPlay: (0, _game.selectCurrentPlay)(state),
|
|
73
|
-
teams: (0, _game.selectTeams)(state)
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var _default = (0, _reactRedux.connect)(mapStateToProps)(Matchup);
|
|
78
|
-
|
|
79
|
-
exports["default"] = _default;
|
|
33
|
+
function Matchup() {
|
|
34
|
+
var _currentPlay$matchup, _currentPlay$matchup$, _currentPlay$matchup2, _currentPlay$matchup3;
|
|
35
|
+
|
|
36
|
+
const boxscore = (0, _alternateRenderers.useSelector)(_games.selectBoxscore);
|
|
37
|
+
const currentPlay = (0, _alternateRenderers.useSelector)(_games.selectCurrentPlay);
|
|
38
|
+
const teams = (0, _alternateRenderers.useSelector)(_games.selectTeams);
|
|
39
|
+
const pitcherId = (_currentPlay$matchup = currentPlay.matchup) === null || _currentPlay$matchup === void 0 ? void 0 : (_currentPlay$matchup$ = _currentPlay$matchup.pitcher) === null || _currentPlay$matchup$ === void 0 ? void 0 : _currentPlay$matchup$.id;
|
|
40
|
+
const batterId = (_currentPlay$matchup2 = currentPlay.matchup) === null || _currentPlay$matchup2 === void 0 ? void 0 : (_currentPlay$matchup3 = _currentPlay$matchup2.batter) === null || _currentPlay$matchup3 === void 0 ? void 0 : _currentPlay$matchup3.id;
|
|
41
|
+
const {
|
|
42
|
+
team: pitchTeam,
|
|
43
|
+
player: pitcher
|
|
44
|
+
} = getPlayerStats(boxscore, teams, pitcherId);
|
|
45
|
+
const {
|
|
46
|
+
team: batTeam,
|
|
47
|
+
player: batter
|
|
48
|
+
} = getPlayerStats(boxscore, teams, batterId);
|
|
49
|
+
const display = `${pitchTeam.abbreviation} Pitching: ` + `{bold}${pitcher.person.fullName}{/bold} ${pitcher.stats.pitching.inningsPitched} IP, ${pitcher.stats.pitching.pitchesThrown || 0} P, ${pitcher.seasonStats.pitching.era} ERA\n` + `${batTeam.abbreviation} At Bat: ` + `{bold}${batter.person.fullName}{/bold} ${batter.stats.batting.hits}-${batter.stats.batting.atBats}, ${batter.seasonStats.batting.avg} AVG, ${batter.seasonStats.batting.homeRuns} HR`;
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement("box", {
|
|
51
|
+
tags: true,
|
|
52
|
+
content: display,
|
|
53
|
+
wrap: false
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var _default = Matchup;
|
|
58
|
+
exports.default = _default;
|