gatsby-matrix-theme 7.2.3 → 7.2.4-beta.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ ## [7.2.4-beta.2](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v7.2.4-beta.1...v7.2.4-beta.2) (2022-10-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * es6 fixes ([9a5a550](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/9a5a5501140079d4ad0948b3b58869900010dc7c))
7
+ * removed es6 package ([d0cc1fe](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/d0cc1fe85186290697ea2b1614d0768ba9ab4421))
8
+
9
+
10
+ * Merge branch 'tm-3076-head-api' into 'beta' ([090bac3](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/090bac3b4b067cf3418112b624b26ccc19e4bcd7))
11
+
12
+ ## [7.2.4-beta.1](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v7.2.3...v7.2.4-beta.1) (2022-10-17)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * added test for tooltip component ([1c98dc9](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/1c98dc9ed453eef7102027b69e1617dee89ced78))
18
+ * horse calculator fixes ([db5fc7d](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/db5fc7d2e65e638349291fbeca3e6eaf1912ac29))
19
+ * horse racing calculator fixes ([e98a030](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/e98a0309c701607080b680c54c688d5ff6af9e7b))
20
+ * updated to latest core version ([1a10a89](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/1a10a8997762c8e1364911314131d74fdb1a02f1))
21
+
22
+
23
+ * Merge branch 'tm-3076-head-api' into 'beta' ([ae207e4](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/ae207e4d6ea26c353d46cd1699e6b7e7ddfaeacb))
24
+ * Merge branch 'tm-2958-horse-calculator-fixes' into 'master' ([766deb5](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/766deb5bc19af39f98f2cf2f13851ef6c397cbf5))
25
+
1
26
  ## [7.2.3](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v7.2.2...v7.2.3) (2022-10-13)
2
27
 
3
28
 
package/gatsby-config.js CHANGED
@@ -19,6 +19,12 @@ module.exports = {
19
19
  preconnectLinks: [process.env.IMAGE_CDN_URL],
20
20
  },
21
21
  },
22
+ {
23
+ resolve: `gatsby-plugin-compile-es6-packages`,
24
+ options: {
25
+ modules: [`gatsby-core-theme`],
26
+ },
27
+ },
22
28
  {
23
29
  resolve: `gatsby-plugin-sitemap`,
24
30
  options: {
@@ -46,11 +52,5 @@ module.exports = {
46
52
  `gatsby-plugin-image`,
47
53
  `gatsby-plugin-sharp`,
48
54
  `gatsby-transformer-sharp`,
49
- {
50
- resolve: `gatsby-plugin-compile-es6-packages`,
51
- options: {
52
- modules: [`gatsby-core-theme`],
53
- },
54
- },
55
55
  ],
56
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-matrix-theme",
3
- "version": "7.2.3",
3
+ "version": "7.2.4-beta.2",
4
4
  "main": "index.js",
5
5
  "description": "Matrix Theme NPM Package",
6
6
  "author": "",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "gatsby": "^4.20.0",
27
- "gatsby-core-theme": "12.0.4",
27
+ "gatsby-core-theme": "13.0.1-beta.3",
28
28
  "gatsby-plugin-sharp": "^4.10.2",
29
29
  "gatsby-plugin-sitemap": "^3.3.0",
30
30
  "gatsby-transformer-sharp": "^4.10.0",
@@ -56,10 +56,10 @@
56
56
  "babel-jest": "^26.6.3",
57
57
  "babel-loader": "^8.2.2",
58
58
  "babel-preset-gatsby": "^1.3.0",
59
- "gatsby-plugin-compile-es6-packages": "^2.1.0",
60
59
  "identity-obj-proxy": "^3.0.0",
61
60
  "jest": "^26.6.3",
62
- "sass-resources-loader": "^2.1.0"
61
+ "sass-resources-loader": "^2.1.0",
62
+ "gatsby-plugin-compile-es6-packages": "^2.1.0"
63
63
  },
64
64
  "jest": {
65
65
  "verbose": true,
@@ -3,20 +3,33 @@ import React, { useContext } from 'react';
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies
4
4
  import PropTypes from 'prop-types';
5
5
  import { Context } from 'gatsby-core-theme/src/context/TranslationsProvider';
6
-
6
+ import { BsQuestionCircle } from '@react-icons/all-files/bs/BsQuestionCircle';
7
7
  import { translate } from 'gatsby-core-theme/src/helpers/getters';
8
-
8
+ import Tooltip from '../tooltip';
9
9
  import styles from './select.module.scss';
10
10
 
11
- export default function Select({ label = null, id, onChangeFunc = () => {}, options, ref, index }) {
11
+ export default function Select({
12
+ label = null,
13
+ id,
14
+ onChangeFunc = () => {},
15
+ options,
16
+ refObj,
17
+ index,
18
+ tooltip = null,
19
+ }) {
12
20
  const { translations } = useContext(Context) || {};
13
21
 
14
22
  if (!label) {
15
23
  return (
16
- <div className={styles.dropdownStyling}>
17
- <select ref={ref} onChange={(e) => onChangeFunc(e, index)} id={id}>
24
+ <div className={`${styles.dropdownStyling} ${tooltip ? styles.tooltip : styles.fullWidth}`}>
25
+ <select ref={refObj} onChange={(e) => onChangeFunc(e, index)} id={id}>
18
26
  {options.map((option) => option)}
19
27
  </select>
28
+ {tooltip && (
29
+ <Tooltip content={translate(translations, `${id}_tooltip`, tooltip)}>
30
+ <BsQuestionCircle size="3rem" />
31
+ </Tooltip>
32
+ )}
20
33
  </div>
21
34
  );
22
35
  }
@@ -24,10 +37,15 @@ export default function Select({ label = null, id, onChangeFunc = () => {}, opti
24
37
  return (
25
38
  <label htmlFor={id}>
26
39
  {translate(translations, id, label)}
27
- <div className={styles.dropdownStyling}>
28
- <select ref={ref} onChange={(e) => onChangeFunc(e, index)} id={id}>
40
+ <div className={`${styles.dropdownStyling} ${tooltip ? styles.tooltip : styles.fullWidth}`}>
41
+ <select ref={refObj} onChange={(e) => onChangeFunc(e, index)} id={id}>
29
42
  {options.map((option) => option)}
30
43
  </select>
44
+ {tooltip && (
45
+ <Tooltip content={tooltip}>
46
+ <BsQuestionCircle size="3rem" />
47
+ </Tooltip>
48
+ )}
31
49
  </div>
32
50
  </label>
33
51
  );
@@ -38,6 +56,7 @@ Select.propTypes = {
38
56
  id: PropTypes.string,
39
57
  onChangeFunc: PropTypes.func,
40
58
  options: PropTypes.arrayOf(PropTypes.any),
41
- ref: PropTypes.func,
59
+ refObj: PropTypes.func,
42
60
  index: PropTypes.number,
61
+ tooltip: PropTypes.string,
43
62
  };
@@ -1,5 +1,12 @@
1
1
  .dropdownStyling {
2
2
  position: relative;
3
+
4
+ &.fullWidth {
5
+ > select {
6
+ width: 100%;
7
+ }
8
+ }
9
+
3
10
  select {
4
11
  -webkit-appearance: none;
5
12
  -moz-appearance: none;
@@ -7,11 +14,10 @@
7
14
  border: none;
8
15
  color: #1a1c1f;
9
16
  background: var(--horse-calc-input-background, #f3f2f2);
10
- border-radius: var(--horse-calc-input-border-radius, .4rem);
17
+ border-radius: var(--horse-calc-input-border-radius, 0.4rem);
11
18
  font-weight: 400;
12
19
  font-size: 16px;
13
20
  padding: 1.6rem 1.5rem;
14
- width: 100%;
15
21
 
16
22
  @include min(tablet) {
17
23
  padding: 1.6rem 2.4rem;
@@ -28,4 +34,18 @@
28
34
  right: 2.4rem;
29
35
  }
30
36
  }
37
+
38
+
31
39
  }
40
+
41
+ .tooltip {
42
+ @include flex-align(center, space-between);
43
+ > select {
44
+ width: 90%;
45
+ }
46
+
47
+ &:after {
48
+ left: 83%;
49
+ right: auto;
50
+ }
51
+ }
@@ -0,0 +1,36 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import React, { useState } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import styles from './tooltip.module.scss';
5
+
6
+ const Tooltip = ({ content, delay, children, direction }) => {
7
+ let timeout;
8
+ const [active, setActive] = useState(false);
9
+
10
+ const showTip = () => {
11
+ timeout = setTimeout(() => {
12
+ setActive(true);
13
+ }, delay || 400);
14
+ };
15
+
16
+ const hideTip = () => {
17
+ clearInterval(timeout);
18
+ setActive(false);
19
+ };
20
+
21
+ return (
22
+ <div className={styles.wrapper} onMouseEnter={showTip} onMouseLeave={hideTip}>
23
+ {children}
24
+ {active && <div className={`${styles.tooltip} ${direction || styles.top}`}>{content}</div>}
25
+ </div>
26
+ );
27
+ };
28
+
29
+ export default Tooltip;
30
+
31
+ Tooltip.propTypes = {
32
+ delay: PropTypes.number,
33
+ direction: PropTypes.string,
34
+ content: PropTypes.string,
35
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
36
+ };
@@ -0,0 +1,80 @@
1
+
2
+ .wrapper {
3
+ @include flex-align(center, center);
4
+ position: relative;
5
+ }
6
+
7
+ .tooltip {
8
+ position: absolute;
9
+ border-radius: 4px;
10
+ left: 50%;
11
+ transform: translateX(-50%);
12
+ padding: 6px;
13
+ color: var(--tooltip-text-color);
14
+ background: var(--tooltip-background-color);
15
+ font-size: 1rem;
16
+ z-index: 100;
17
+ white-space: nowrap;
18
+ }
19
+
20
+ .tooltip::before {
21
+ content: " ";
22
+ left: 50%;
23
+ border: solid transparent;
24
+ height: 0;
25
+ width: 0;
26
+ position: absolute;
27
+ pointer-events: none;
28
+ border-width: var(--tooltip-arrow-size);
29
+ margin-left: calc(var(--tooltip-arrow-size) * -1);
30
+ }
31
+
32
+ .tooltip.top {
33
+ top: calc(var(--tooltip-margin) * -1);
34
+ }
35
+
36
+ .tooltip.top::before {
37
+ top: 100%;
38
+ border-top-color: var(--tooltip-background-color);
39
+ }
40
+
41
+
42
+ .tooltip.right {
43
+ left: calc(100% + var(--tooltip-margin));
44
+ top: 50%;
45
+ transform: translateX(0) translateY(-50%);
46
+ }
47
+
48
+ .tooltip.right::before {
49
+ left: calc(var(--tooltip-arrow-size) * -1);
50
+ top: 50%;
51
+ transform: translateX(0) translateY(-50%);
52
+ border-right-color: var(--tooltip-background-color);
53
+ }
54
+
55
+ /* Absolute positioning */
56
+ .tooltip.bottom {
57
+ bottom: calc(var(--tooltip-margin) * -1);
58
+ }
59
+ /* CSS border triangles */
60
+ .tooltip.bottom::before {
61
+ bottom: 100%;
62
+ border-bottom-color: var(--tooltip-background-color);
63
+ }
64
+
65
+ /* Absolute positioning */
66
+ .tooltip.left {
67
+ left: auto;
68
+ right: calc(100% + var(--tooltip-margin));
69
+ top: 50%;
70
+ transform: translateX(0) translateY(-50%);
71
+ }
72
+ /* CSS border triangles */
73
+ .tooltip.left::before {
74
+ left: auto;
75
+ right: calc(var(--tooltip-arrow-size) * -2);
76
+ top: 50%;
77
+ transform: translateX(0) translateY(-50%);
78
+ border-left-color: var(--tooltip-background-color);
79
+ }
80
+
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import Tooltip from '.';
5
+
6
+ describe('Tooltip Component', () => {
7
+ test('render tooltip', async () => {
8
+ const { container, getByText } = render(
9
+ <Tooltip content="test content" direction="top" delay={0}>
10
+ Test Children
11
+ </Tooltip>
12
+ );
13
+ expect(container).toBeTruthy();
14
+
15
+ expect(getByText('Test Children')).toBeTruthy();
16
+
17
+ fireEvent.mouseEnter(screen.getByText('Test Children'));
18
+ await waitFor(() => screen.getByText('test content'));
19
+ });
20
+ });
@@ -40,10 +40,6 @@
40
40
  font-weight: 700;
41
41
  font-size: 16px;
42
42
  line-height: 23px;
43
-
44
- > div > select {
45
- width: 100% !important;
46
- }
47
43
  }
48
44
  }
49
45
 
@@ -202,3 +198,7 @@
202
198
  font-weight: 500;
203
199
  }
204
200
  }
201
+
202
+ .displayNone {
203
+ display: none;
204
+ }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-restricted-globals */
1
2
  /* eslint-disable react-hooks/exhaustive-deps */
2
3
  /* eslint-disable array-callback-return */
3
4
  /* eslint-disable no-return-assign */
@@ -41,6 +42,7 @@ const HorseCalculator = () => {
41
42
  const totalReturnRef = useRef(null);
42
43
  const totalProfitRef = useRef(null);
43
44
  const numSelectionRef = useRef(null);
45
+ const betTypeRef = useRef(null);
44
46
 
45
47
  const [activeBetType, setBetType] = useState(betType[0]);
46
48
  const [eachWay, setEachWay] = useState('No');
@@ -113,7 +115,11 @@ const HorseCalculator = () => {
113
115
  };
114
116
 
115
117
  const resetCalculation = () => {
116
- setBetType(betType[0]);
118
+ handleBetTypeChange({ target: { value: 0 } });
119
+
120
+ if (betTypeRef.current) {
121
+ betTypeRef.current.value = 0;
122
+ }
117
123
  };
118
124
 
119
125
  const getColspan = () => {
@@ -128,9 +134,9 @@ const HorseCalculator = () => {
128
134
 
129
135
  const updateTotals = (totals) => {
130
136
  const [outlay, totReturn, profit] = totals;
131
- totalOutlayRef.current.innerText = outlay;
132
- totalReturnRef.current.innerText = totReturn;
133
- totalProfitRef.current.innerText = profit;
137
+ totalOutlayRef.current.innerText = !isNaN(totReturn) ? outlay : '-';
138
+ totalReturnRef.current.innerText = !isNaN(totReturn) ? totReturn : '-';
139
+ totalProfitRef.current.innerText = !isNaN(totReturn) ? profit : '-';
134
140
  };
135
141
 
136
142
  const updateFoldTotals = (totals) => {
@@ -254,15 +260,18 @@ const HorseCalculator = () => {
254
260
  <Select
255
261
  id="bettype"
256
262
  label="Bet type:"
263
+ tooltip="Accumulator - A Single Bet on up to 20 Selections"
257
264
  onChangeFunc={handleBetTypeChange}
258
265
  options={betType.map((type, index) => (
259
266
  <option value={index}>{type.name}</option>
260
267
  ))}
268
+ refObj={betTypeRef}
261
269
  />
262
270
 
263
271
  <Select
264
272
  id="eachway"
265
273
  label="Each way?"
274
+ tooltip="Whether you are calculating an each way bet. Two individual bets of equal amount, one placed on the selection to win and the other on the same selection to place."
266
275
  onChangeFunc={handleEachWayChange}
267
276
  options={[
268
277
  <option value="Yes">Yes</option>,
@@ -272,10 +281,11 @@ const HorseCalculator = () => {
272
281
  ]}
273
282
  />
274
283
 
275
- {eachWay === 'Yes' && (
284
+ {eachWay === 'Yes' && activeBetType.multiple_options && (
276
285
  <Select
277
286
  id="multiple_options"
278
287
  label="Multiple Options:"
288
+ tooltip="Test"
279
289
  onChangeFunc={handleMultipleOption}
280
290
  options={[
281
291
  <option value="1">Default - Win-to-Win, Place-to-Place</option>,
@@ -288,17 +298,19 @@ const HorseCalculator = () => {
288
298
  <Select
289
299
  id="num_of_selection"
290
300
  label="Number of selections:"
301
+ tooltip="Pick how many horses you want to track below!"
291
302
  onChangeFunc={handleNumSelectionChange}
292
303
  options={[...Array(numSelection)].map((e, i) => (
293
304
  <option value={i + 1}>{i + 1}</option>
294
305
  ))}
295
- ref={numSelectionRef}
306
+ refObj={numSelectionRef}
296
307
  />
297
308
  )}
298
309
 
299
310
  <Select
300
311
  id="rulefour"
301
312
  label="Show rule 4?"
313
+ tooltip="Used in horse racing to adjust winnings when runners are withdrawn before the race."
302
314
  onChangeFunc={handleRuleFourChange}
303
315
  options={[
304
316
  <option value="Yes">Yes</option>,
@@ -311,6 +323,7 @@ const HorseCalculator = () => {
311
323
  <Select
312
324
  id="addNotes"
313
325
  label="Add Selection Notes?"
326
+ tooltip="Keep some personalized notes on your picks."
314
327
  onChangeFunc={handleAddNotesChange}
315
328
  options={[
316
329
  <option value="Yes">Yes</option>,
@@ -366,12 +379,22 @@ const HorseCalculator = () => {
366
379
  />
367
380
  </td>
368
381
  <td>
369
- <input onChange={calculateTotalBet} type="number" placeholder={2} />
382
+ <input
383
+ onChange={calculateTotalBet}
384
+ className={
385
+ outcomeSelection[index] === 'lost' || outcomeSelection[index] === 'void'
386
+ ? styles.displayNone
387
+ : ''
388
+ }
389
+ type="number"
390
+ placeholder={2}
391
+ />
370
392
  </td>
371
393
  {eachWay === 'Yes' && (
372
394
  <td>
373
395
  <Select
374
396
  id="place_odds"
397
+ onChangeFunc={calculateTotalBet}
375
398
  options={placeOddsoptions.map((option) => (
376
399
  <option value={option}>{option}</option>
377
400
  ))}
@@ -382,6 +405,7 @@ const HorseCalculator = () => {
382
405
  <td>
383
406
  <Select
384
407
  id="rule_four"
408
+ onChangeFunc={calculateTotalBet}
385
409
  options={ruleFourOptions.map((option) => (
386
410
  <option value={option}>{option}</option>
387
411
  ))}
@@ -401,12 +425,14 @@ const HorseCalculator = () => {
401
425
  <Select
402
426
  id="tiedposition"
403
427
  label="Tied position"
428
+ onChangeFunc={calculateTotalBet}
404
429
  options={[...Array(16)].map((e, i) => (
405
430
  <option value={i + 1}>{i + 1}</option>
406
431
  ))}
407
432
  />
408
433
  <Select
409
434
  id="deadheatrunners"
435
+ onChangeFunc={calculateTotalBet}
410
436
  label="Number of runnners in dead heat:"
411
437
  options={[...Array(16)].map((e, i) => (
412
438
  <option value={i + 1}>{i + 1}</option>
@@ -415,6 +441,7 @@ const HorseCalculator = () => {
415
441
  <Select
416
442
  id="placesoffered"
417
443
  label="Places Offered"
444
+ onChangeFunc={calculateTotalBet}
418
445
  options={[...Array(16)].map((e, i) => (
419
446
  <option value={i + 1}>{i + 1}</option>
420
447
  ))}
@@ -434,7 +461,8 @@ const HorseCalculator = () => {
434
461
  <Select
435
462
  id="fold_option"
436
463
  label="Fold options:"
437
- ref={foldOptionRef}
464
+ refObj={foldOptionRef}
465
+ tooltip="Accumulator - A Single Bet on up to 20 Selections"
438
466
  onChangeFunc={handleFoldOption}
439
467
  options={[
440
468
  <option value="1">Disabled</option>,
@@ -493,7 +521,7 @@ const HorseCalculator = () => {
493
521
  <Select
494
522
  id="one_winner_consolation"
495
523
  label="One Winner Consolation:"
496
- ref={oneWinnerConsolationRef}
524
+ refObj={oneWinnerConsolationRef}
497
525
  onChangeFunc={handleFoldOption}
498
526
  options={[
499
527
  <option value="0" selected="">
@@ -513,7 +541,7 @@ const HorseCalculator = () => {
513
541
  <Select
514
542
  id="stake_type"
515
543
  label="Stake Type:"
516
- ref={stakeTypeRef}
544
+ refObj={stakeTypeRef}
517
545
  options={[
518
546
  <option value="1" selected>
519
547
  Stake per Bet
@@ -552,6 +580,7 @@ const HorseCalculator = () => {
552
580
  </div>
553
581
  <div className={styles.ctaContainer}>
554
582
  <Button
583
+ isButton
555
584
  primaryColor={false}
556
585
  btnText={translate(translations, 'reset-calculation', 'Reset Calculation')}
557
586
  invertColors