playball 2.2.2 → 3.1.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.
Files changed (71) hide show
  1. package/.eslintrc.json +2 -2
  2. package/README.md +80 -4
  3. package/bin/playball.js +1 -1
  4. package/demo.cast +95 -0
  5. package/demo.gif +0 -0
  6. package/package.json +50 -28
  7. package/src/cli.js +46 -0
  8. package/src/components/AllPlays.jsx +97 -64
  9. package/src/components/App.jsx +40 -68
  10. package/src/components/AtBat.jsx +34 -36
  11. package/src/components/Bases.jsx +9 -13
  12. package/src/components/Count.jsx +11 -15
  13. package/src/components/FinishedGame.jsx +30 -41
  14. package/src/components/Game.jsx +54 -71
  15. package/src/components/GameList.jsx +129 -82
  16. package/src/components/Grid.jsx +91 -0
  17. package/src/components/HelpBar.jsx +15 -10
  18. package/src/components/InningDisplay.jsx +19 -0
  19. package/src/components/LineScore.jsx +27 -33
  20. package/src/components/LiveGame.jsx +13 -9
  21. package/src/components/LoadingSpinner.jsx +26 -60
  22. package/src/components/Matchup.jsx +26 -39
  23. package/src/components/PreviewGame.jsx +22 -37
  24. package/src/components/Standings.jsx +81 -0
  25. package/src/config.js +167 -0
  26. package/src/features/games.js +166 -0
  27. package/src/features/keys.js +39 -0
  28. package/src/features/schedule.js +60 -0
  29. package/src/features/standings.js +61 -0
  30. package/src/hooks/useKey.js +13 -0
  31. package/src/logger.js +4 -1
  32. package/src/main.js +20 -23
  33. package/src/package.js +7 -0
  34. package/src/screen.js +22 -0
  35. package/src/store/index.js +17 -7
  36. package/src/style/index.js +1 -1
  37. package/src/utils.js +10 -0
  38. package/dist/actions/game.js +0 -36
  39. package/dist/actions/schedule.js +0 -33
  40. package/dist/actions/types.js +0 -16
  41. package/dist/components/AllPlays.js +0 -132
  42. package/dist/components/App.js +0 -140
  43. package/dist/components/AtBat.js +0 -66
  44. package/dist/components/Bases.js +0 -47
  45. package/dist/components/Count.js +0 -47
  46. package/dist/components/FinishedGame.js +0 -139
  47. package/dist/components/Game.js +0 -145
  48. package/dist/components/GameList.js +0 -196
  49. package/dist/components/HelpBar.js +0 -23
  50. package/dist/components/LineScore.js +0 -118
  51. package/dist/components/LiveGame.js +0 -65
  52. package/dist/components/LoadingSpinner.js +0 -146
  53. package/dist/components/Matchup.js +0 -79
  54. package/dist/components/PreviewGame.js +0 -97
  55. package/dist/logger.js +0 -24
  56. package/dist/main.js +0 -38
  57. package/dist/reducers/game.js +0 -70
  58. package/dist/reducers/index.js +0 -21
  59. package/dist/reducers/schedule.js +0 -35
  60. package/dist/selectors/game.js +0 -82
  61. package/dist/selectors/schedule.js +0 -25
  62. package/dist/store/index.js +0 -18
  63. package/dist/style/index.js +0 -22
  64. package/src/actions/game.js +0 -25
  65. package/src/actions/schedule.js +0 -21
  66. package/src/actions/types.js +0 -5
  67. package/src/reducers/game.js +0 -56
  68. package/src/reducers/index.js +0 -9
  69. package/src/reducers/schedule.js +0 -28
  70. package/src/selectors/game.js +0 -93
  71. package/src/selectors/schedule.js +0 -18
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _reactRedux = require("react-redux");
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- var _game = require("../selectors/game");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
- var formatBase = function formatBase(offense, base) {
19
- return offense.has(base) ? '{yellow-fg}◆{/yellow-fg}' : '◇';
20
- };
21
-
22
- var Bases = function Bases(_ref) {
23
- var align = _ref.align,
24
- game = _ref.game;
25
- var offense = game.getIn(['liveData', 'linescore', 'offense']);
26
- var content = " ".concat(formatBase(offense, 'second'), "\n") + "".concat(formatBase(offense, 'third'), " ").concat(formatBase(offense, 'first'));
27
- return /*#__PURE__*/_react["default"].createElement("box", {
28
- align: align,
29
- content: content,
30
- tags: true
31
- });
32
- };
33
-
34
- Bases.propTypes = {
35
- align: _propTypes["default"].string,
36
- game: _propTypes["default"].object
37
- };
38
-
39
- var mapStateToProps = function mapStateToProps(state) {
40
- return {
41
- game: (0, _game.selectGame)(state)
42
- };
43
- };
44
-
45
- var _default = (0, _reactRedux.connect)(mapStateToProps)(Bases);
46
-
47
- exports["default"] = _default;
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _reactRedux = require("react-redux");
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- var _game = require("../selectors/game");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
- var formatCount = function formatCount(count, total) {
19
- return '● '.repeat(count) + '○ '.repeat(total - count);
20
- };
21
-
22
- var Count = function Count(_ref) {
23
- var align = _ref.align,
24
- game = _ref.game;
25
- var linescore = game.getIn(['liveData', 'linescore']);
26
- var content = "B: {green-fg}".concat(formatCount(linescore.get('balls'), 4), "{/green-fg}\n") + "S: {red-fg}".concat(formatCount(linescore.get('strikes'), 3), "{/red-fg}\n") + "O: {red-fg}".concat(formatCount(linescore.get('outs'), 3), "{/red-fg}");
27
- return /*#__PURE__*/_react["default"].createElement("box", {
28
- align: align,
29
- content: content,
30
- tags: true
31
- });
32
- };
33
-
34
- Count.propTypes = {
35
- align: _propTypes["default"].string,
36
- game: _propTypes["default"].object
37
- };
38
-
39
- var mapStateToProps = function mapStateToProps(state) {
40
- return {
41
- game: (0, _game.selectGame)(state)
42
- };
43
- };
44
-
45
- var _default = (0, _reactRedux.connect)(mapStateToProps)(Count);
46
-
47
- exports["default"] = _default;
@@ -1,139 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _reactRedux = require("react-redux");
13
-
14
- var _game = require("../selectors/game");
15
-
16
- var _LineScore = _interopRequireDefault(require("./LineScore"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
-
20
- var getPlayer = function getPlayer(id, boxscore) {
21
- var homePlayer = boxscore.getIn(['home', 'players', 'ID' + id]);
22
-
23
- if (homePlayer !== undefined) {
24
- return homePlayer;
25
- }
26
-
27
- return boxscore.getIn(['away', 'players', 'ID' + id]);
28
- };
29
-
30
- var formatDecisions = function formatDecisions(decisions, boxscore) {
31
- if (!decisions) {
32
- return '';
33
- }
34
-
35
- var content = [];
36
- var winner = decisions.get('winner');
37
-
38
- if (winner) {
39
- var pitcher = getPlayer(winner.get('id'), boxscore);
40
- content.push("Win: ".concat(pitcher.getIn(['person', 'fullName']), " (").concat(pitcher.getIn(['seasonStats', 'pitching', 'wins']), "-").concat(pitcher.getIn(['seasonStats', 'pitching', 'losses']), ")"));
41
- }
42
-
43
- var loser = decisions.get('loser');
44
-
45
- if (loser) {
46
- var _pitcher = getPlayer(loser.get('id'), boxscore);
47
-
48
- content.push("Loss: ".concat(_pitcher.getIn(['person', 'fullName']), " (").concat(_pitcher.getIn(['seasonStats', 'pitching', 'wins']), "-").concat(_pitcher.getIn(['seasonStats', 'pitching', 'losses']), ")"));
49
- }
50
-
51
- var save = decisions.get('save');
52
-
53
- if (save) {
54
- var _pitcher2 = getPlayer(save.get('id'), boxscore);
55
-
56
- content.push("Save: ".concat(_pitcher2.getIn(['person', 'fullName']), " (").concat(_pitcher2.getIn(['seasonStats', 'pitching', 'saves']), ")"));
57
- }
58
-
59
- return content.join('\n');
60
- };
61
-
62
- var formatScore = function formatScore(status, linescore) {
63
- var display = '';
64
-
65
- if (status.get('detailedState') === 'Postponed') {
66
- display = status.get('detailedState');
67
-
68
- if (status.get('reason')) {
69
- display += '\n' + status.get('reason');
70
- }
71
- } else {
72
- display = "\n".concat(linescore.getIn(['teams', 'away', 'runs']), " - ").concat(linescore.getIn(['teams', 'home', 'runs']));
73
- }
74
-
75
- return display;
76
- };
77
-
78
- var FinishedGame = function FinishedGame(_ref) {
79
- var boxscore = _ref.boxscore,
80
- decisions = _ref.decisions,
81
- linescore = _ref.linescore,
82
- status = _ref.status,
83
- teams = _ref.teams;
84
- var awayTeam = "".concat(teams.getIn(['away', 'teamName']), "\n(").concat(teams.getIn(['away', 'record', 'wins']), "-").concat(teams.getIn(['away', 'record', 'losses']), ")");
85
- var homeTeam = "".concat(teams.getIn(['home', 'teamName']), "\n(").concat(teams.getIn(['home', 'record', 'wins']), "-").concat(teams.getIn(['home', 'record', 'losses']), ")");
86
- return /*#__PURE__*/_react["default"].createElement("element", null, /*#__PURE__*/_react["default"].createElement("element", {
87
- height: "60%"
88
- }, /*#__PURE__*/_react["default"].createElement("box", {
89
- content: awayTeam,
90
- width: "33%-1",
91
- top: "50%",
92
- align: "center"
93
- }), /*#__PURE__*/_react["default"].createElement("box", {
94
- content: formatScore(status, linescore),
95
- width: "33%-1",
96
- left: "33%",
97
- top: "50%",
98
- align: "center"
99
- }), /*#__PURE__*/_react["default"].createElement("box", {
100
- content: homeTeam,
101
- width: "34%",
102
- top: "50%",
103
- left: "66%",
104
- align: "center"
105
- })), /*#__PURE__*/_react["default"].createElement("element", {
106
- top: "60%+1",
107
- height: 3
108
- }, /*#__PURE__*/_react["default"].createElement(_LineScore["default"], {
109
- align: "center",
110
- "final": true
111
- })), /*#__PURE__*/_react["default"].createElement("element", {
112
- top: "60%+5",
113
- left: "50%-20"
114
- }, /*#__PURE__*/_react["default"].createElement("box", {
115
- content: formatDecisions(decisions, boxscore)
116
- })));
117
- };
118
-
119
- FinishedGame.propTypes = {
120
- boxscore: _propTypes["default"].object,
121
- decisions: _propTypes["default"].object,
122
- linescore: _propTypes["default"].object,
123
- status: _propTypes["default"].object,
124
- teams: _propTypes["default"].object
125
- };
126
-
127
- var mapStateToProps = function mapStateToProps(state) {
128
- return {
129
- boxscore: (0, _game.selectBoxscore)(state),
130
- decisions: (0, _game.selectDecisions)(state),
131
- linescore: (0, _game.selectLineScore)(state),
132
- status: (0, _game.selectGameStatus)(state),
133
- teams: (0, _game.selectTeams)(state)
134
- };
135
- };
136
-
137
- var _default = (0, _reactRedux.connect)(mapStateToProps)(FinishedGame);
138
-
139
- exports["default"] = _default;
@@ -1,145 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _reactRedux = require("react-redux");
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- var _game = require("../selectors/game");
15
-
16
- var _game2 = require("../actions/game");
17
-
18
- var _PreviewGame = _interopRequireDefault(require("./PreviewGame"));
19
-
20
- var _LiveGame = _interopRequireDefault(require("./LiveGame"));
21
-
22
- var _FinishedGame = _interopRequireDefault(require("./FinishedGame"));
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
-
26
- function _typeof(obj) { "@babel/helpers - typeof"; 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); }
27
-
28
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29
-
30
- 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); } }
31
-
32
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
33
-
34
- 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); }
35
-
36
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
37
-
38
- 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); }; }
39
-
40
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
41
-
42
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
-
44
- 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; } }
45
-
46
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
-
48
- var Game = /*#__PURE__*/function (_React$Component) {
49
- _inherits(Game, _React$Component);
50
-
51
- var _super = _createSuper(Game);
52
-
53
- function Game() {
54
- _classCallCheck(this, Game);
55
-
56
- return _super.apply(this, arguments);
57
- }
58
-
59
- _createClass(Game, [{
60
- key: "componentDidMount",
61
- value: function componentDidMount() {
62
- this.updateGameData();
63
- }
64
- }, {
65
- key: "componentDidUpdate",
66
- value: function componentDidUpdate(prevProps) {
67
- if (this.props.id !== prevProps.id) {
68
- this.updateGameData();
69
- }
70
- }
71
- }, {
72
- key: "componentWillUnmount",
73
- value: function componentWillUnmount() {
74
- clearTimeout(this.timer);
75
- }
76
- }, {
77
- key: "updateGameData",
78
- value: function updateGameData() {
79
- var _this = this;
80
-
81
- var _this$props = this.props,
82
- fetchGame = _this$props.fetchGame,
83
- game = _this$props.game,
84
- id = _this$props.id,
85
- fullUpdateRequired = _this$props.fullUpdateRequired;
86
- var start = fullUpdateRequired ? null : game && game.getIn(['metaData', 'timeStamp']);
87
- fetchGame(id, start).then(function () {
88
- var wait = (game && game.getIn(['metaData', 'wait']) || 10) * 1000;
89
- _this.timer = setTimeout(_this.updateGameData.bind(_this), wait);
90
- });
91
- }
92
- }, {
93
- key: "render",
94
- value: function render() {
95
- var game = this.props.game;
96
-
97
- if (!game || game.isEmpty()) {
98
- return /*#__PURE__*/_react["default"].createElement("element", null);
99
- }
100
-
101
- var Wrapped = null;
102
-
103
- switch (game.getIn(['gameData', 'status', 'abstractGameCode'])) {
104
- case 'P':
105
- Wrapped = _PreviewGame["default"];
106
- break;
107
-
108
- case 'L':
109
- Wrapped = _LiveGame["default"];
110
- break;
111
-
112
- case 'F':
113
- Wrapped = _FinishedGame["default"];
114
- break;
115
- }
116
-
117
- return /*#__PURE__*/_react["default"].createElement("element", null, /*#__PURE__*/_react["default"].createElement(Wrapped, null));
118
- }
119
- }]);
120
-
121
- return Game;
122
- }(_react["default"].Component);
123
-
124
- Game.propTypes = {
125
- fetchGame: _propTypes["default"].func,
126
- game: _propTypes["default"].object,
127
- id: _propTypes["default"].number,
128
- fullUpdateRequired: _propTypes["default"].bool
129
- };
130
-
131
- var mapStateToProps = function mapStateToProps(state) {
132
- return {
133
- game: (0, _game.selectGame)(state),
134
- fullUpdateRequired: (0, _game.selectFullUpdateRequired)(state),
135
- id: (0, _game.selectSelectedId)(state)
136
- };
137
- };
138
-
139
- var mapDispatchToProps = {
140
- fetchGame: _game2.fetchGame
141
- };
142
-
143
- var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Game);
144
-
145
- exports["default"] = _default;
@@ -1,196 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _reactRedux = require("react-redux");
11
-
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
-
14
- var _moment = _interopRequireDefault(require("moment"));
15
-
16
- var _schedule = require("../selectors/schedule");
17
-
18
- var _schedule2 = require("../actions/schedule");
19
-
20
- var _style = _interopRequireDefault(require("../style"));
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
-
24
- function _typeof(obj) { "@babel/helpers - typeof"; 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); }
25
-
26
- 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); }
27
-
28
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29
-
30
- 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); } }
31
-
32
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
33
-
34
- 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); }
35
-
36
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
37
-
38
- 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); }; }
39
-
40
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
41
-
42
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
-
44
- 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; } }
45
-
46
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
-
48
- var formatGame = function formatGame(game) {
49
- var startTime = (0, _moment["default"])(game.gameDate).format('LT');
50
- var start = game.doubleHeader === 'Y' && game.gameNumber > 1 ? 'Game ' + game.gameNumber : startTime;
51
-
52
- var teamName = function teamName(team) {
53
- return "".concat(team.team.teamName, " (").concat(team.leagueRecord.wins, "-").concat(team.leagueRecord.losses, ")");
54
- };
55
-
56
- var content = "".concat(start.padStart(8), " ").concat(teamName(game.teams.away), " at ").concat(teamName(game.teams.home));
57
- var gameState = game.status.abstractGameCode;
58
- var detailedState = game.status.detailedState;
59
-
60
- switch (gameState) {
61
- case 'P':
62
- break;
63
-
64
- case 'L':
65
- if (detailedState !== 'In Progress') {
66
- content += ' | ' + detailedState;
67
- }
68
-
69
- if (game.linescore) {
70
- content += ' | ' + game.linescore.inningState + ' ' + game.linescore.currentInningOrdinal + ' | ' + game.teams.away.team.abbreviation + ' ' + game.linescore.teams.away.runs + ' - ' + game.teams.home.team.abbreviation + ' ' + game.linescore.teams.home.runs;
71
- }
72
-
73
- break;
74
-
75
- case 'F':
76
- content += ' | ' + detailedState;
77
-
78
- if (game.status.reason) {
79
- content += ' | ' + game.status.reason;
80
- }
81
-
82
- if (game.linescore) {
83
- content += ' | ' + game.teams.away.team.abbreviation + ' ' + game.linescore.teams.away.runs + ' - ' + game.teams.home.team.abbreviation + ' ' + game.linescore.teams.home.runs;
84
- }
85
-
86
- break;
87
- }
88
-
89
- return content;
90
- };
91
-
92
- var GameList = /*#__PURE__*/function (_React$Component) {
93
- _inherits(GameList, _React$Component);
94
-
95
- var _super = _createSuper(GameList);
96
-
97
- function GameList(props) {
98
- var _this;
99
-
100
- _classCallCheck(this, GameList);
101
-
102
- _this = _super.call(this, props);
103
- _this.handleGameSelect = _this.handleGameSelect.bind(_assertThisInitialized(_this));
104
- return _this;
105
- }
106
-
107
- _createClass(GameList, [{
108
- key: "componentDidMount",
109
- value: function componentDidMount() {
110
- this.props.fetchSchedule();
111
- }
112
- }, {
113
- key: "handleGameSelect",
114
- value: function handleGameSelect(item, idx) {
115
- var _this$props = this.props,
116
- onGameSelect = _this$props.onGameSelect,
117
- schedule = _this$props.schedule;
118
- var selected = schedule.dates[0].games[idx];
119
- onGameSelect(selected);
120
- }
121
- }, {
122
- key: "render",
123
- value: function render() {
124
- var _this$props2 = this.props,
125
- loading = _this$props2.loading,
126
- schedule = _this$props2.schedule;
127
- var messageStyle = {
128
- left: 'center',
129
- top: 'center',
130
- height: '80%',
131
- width: '80%',
132
- border: {
133
- type: 'line'
134
- },
135
- align: 'center',
136
- valign: 'middle'
137
- };
138
-
139
- if (loading) {
140
- return /*#__PURE__*/_react["default"].createElement("box", _extends({}, messageStyle, {
141
- content: "Loading..."
142
- }));
143
- }
144
-
145
- if (schedule && !schedule.dates.length) {
146
- return /*#__PURE__*/_react["default"].createElement("box", _extends({}, messageStyle, {
147
- content: "No games today"
148
- }));
149
- }
150
-
151
- return /*#__PURE__*/_react["default"].createElement("list", {
152
- left: "center",
153
- top: "center",
154
- width: "80%",
155
- height: "80%",
156
- keys: true,
157
- vi: true,
158
- focused: true,
159
- border: {
160
- type: 'line'
161
- },
162
- label: " Select a game ",
163
- scrollbar: _style["default"].scrollbar,
164
- style: _style["default"].list,
165
- items: schedule && schedule.dates.length > 0 ? schedule.dates[0].games.map(formatGame) : [],
166
- onSelect: this.handleGameSelect
167
- });
168
- }
169
- }]);
170
-
171
- return GameList;
172
- }(_react["default"].Component);
173
-
174
- GameList.propTypes = {
175
- error: _propTypes["default"].object,
176
- fetchSchedule: _propTypes["default"].func,
177
- loading: _propTypes["default"].bool,
178
- onGameSelect: _propTypes["default"].func,
179
- schedule: _propTypes["default"].object
180
- };
181
-
182
- var mapStateToProps = function mapStateToProps(state) {
183
- return {
184
- loading: (0, _schedule.selectLoading)(state),
185
- error: (0, _schedule.selectError)(state),
186
- schedule: (0, _schedule.selectData)(state)
187
- };
188
- };
189
-
190
- var mapDispatchToProps = {
191
- fetchSchedule: _schedule2.fetchSchedule
192
- };
193
-
194
- var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(GameList);
195
-
196
- exports["default"] = _default;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _LoadingSpinner = _interopRequireDefault(require("./LoadingSpinner"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
- var HelpBar = function HelpBar() {
15
- return /*#__PURE__*/_react["default"].createElement("element", null, /*#__PURE__*/_react["default"].createElement(_LoadingSpinner["default"], null), /*#__PURE__*/_react["default"].createElement("box", {
16
- left: 3,
17
- content: '{inverse}Q{/inverse}:Quit {inverse}L{/inverse}:List Games',
18
- tags: true
19
- }));
20
- };
21
-
22
- var _default = HelpBar;
23
- exports["default"] = _default;