@times-components/ts-components 1.88.0 → 1.88.2-alpha.10

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 (58) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/components/opta/football/fixtures-ticker/OptaFootballFixturesTicker.js +2 -2
  3. package/dist/components/opta/football/fixtures-ticker/styles.js +73 -8
  4. package/dist/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.d.ts +14 -0
  5. package/dist/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.js +61 -0
  6. package/dist/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.stories.d.ts +1 -0
  7. package/dist/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.stories.js +21 -0
  8. package/dist/components/opta/football/fixtures-tournament/__tests__/OptaFootballFixturesTournament.test.d.ts +2 -0
  9. package/dist/components/opta/football/fixtures-tournament/__tests__/OptaFootballFixturesTournament.test.js +56 -0
  10. package/dist/components/opta/football/fixtures-tournament/styles.d.ts +5 -0
  11. package/dist/components/opta/football/fixtures-tournament/styles.js +265 -0
  12. package/dist/components/opta/football/player-stats/OptaFootballPlayerStats.d.ts +8 -0
  13. package/dist/components/opta/football/player-stats/OptaFootballPlayerStats.js +47 -0
  14. package/dist/components/opta/football/player-stats/OptaFootballPlayerStats.stories.d.ts +1 -0
  15. package/dist/components/opta/football/player-stats/OptaFootballPlayerStats.stories.js +26 -0
  16. package/dist/components/opta/football/player-stats/__tests__/OptaFootballPlayerStats.test.d.ts +2 -0
  17. package/dist/components/opta/football/player-stats/__tests__/OptaFootballPlayerStats.test.js +41 -0
  18. package/dist/components/opta/football/player-stats/styles.d.ts +1 -0
  19. package/dist/components/opta/football/player-stats/styles.js +153 -0
  20. package/dist/components/opta/football/shared-styles.js +23 -7
  21. package/dist/components/opta/football/standings/OptaFootballStandings.d.ts +2 -0
  22. package/dist/components/opta/football/standings/OptaFootballStandings.js +5 -4
  23. package/dist/components/opta/football/standings/OptaFootballStandings.stories.js +7 -2
  24. package/dist/components/opta/football/standings/__tests__/OptaFootballStandings.test.js +16 -4
  25. package/dist/components/opta/football/standings/styles.d.ts +3 -1
  26. package/dist/components/opta/football/standings/styles.js +5 -1
  27. package/dist/components/opta/utils/__tests__/config.test.js +11 -2
  28. package/dist/components/opta/utils/replaceNationalTeamDetails.js +2 -2
  29. package/dist/index.d.ts +2 -0
  30. package/dist/index.js +3 -1
  31. package/jest.config.js +0 -1
  32. package/package.json +16 -16
  33. package/rnw.js +1 -1
  34. package/src/components/opta/football/fixtures/__tests__/__snapshots__/OptaFootballFixtures.test.tsx.snap +2 -2
  35. package/src/components/opta/football/fixtures-ticker/OptaFootballFixturesTicker.tsx +1 -1
  36. package/src/components/opta/football/fixtures-ticker/__tests__/__snapshots__/OptaFootballFixturesTicker.test.tsx.snap +8 -8
  37. package/src/components/opta/football/fixtures-ticker/styles.ts +72 -7
  38. package/src/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.stories.tsx +32 -0
  39. package/src/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.tsx +118 -0
  40. package/src/components/opta/football/fixtures-tournament/__tests__/OptaFootballFixturesTournament.test.tsx +82 -0
  41. package/src/components/opta/football/fixtures-tournament/__tests__/__snapshots__/OptaFootballFixturesTournament.test.tsx.snap +100 -0
  42. package/src/components/opta/football/fixtures-tournament/styles.ts +273 -0
  43. package/src/components/opta/football/match-stats/__tests__/__snapshots__/OptaFootballMatchStats.test.tsx.snap +2 -2
  44. package/src/components/opta/football/player-stats/OptaFootballPlayerStats.stories.tsx +43 -0
  45. package/src/components/opta/football/player-stats/OptaFootballPlayerStats.tsx +87 -0
  46. package/src/components/opta/football/player-stats/__tests__/OptaFootballPlayerStats.test.tsx +53 -0
  47. package/src/components/opta/football/player-stats/__tests__/__snapshots__/OptaFootballPlayerStats.test.tsx.snap +34 -0
  48. package/src/components/opta/football/player-stats/styles.ts +154 -0
  49. package/src/components/opta/football/shared-styles.ts +22 -6
  50. package/src/components/opta/football/standings/OptaFootballStandings.stories.tsx +19 -1
  51. package/src/components/opta/football/standings/OptaFootballStandings.tsx +36 -28
  52. package/src/components/opta/football/standings/__tests__/OptaFootballStandings.test.tsx +22 -3
  53. package/src/components/opta/football/standings/__tests__/__snapshots__/OptaFootballStandings.test.tsx.snap +35 -2
  54. package/src/components/opta/football/standings/styles.ts +7 -1
  55. package/src/components/opta/football/summary/__tests__/__snapshots__/OptaFootballSummary.test.tsx.snap +2 -2
  56. package/src/components/opta/utils/__tests__/config.test.tsx +20 -1
  57. package/src/components/opta/utils/replaceNationalTeamDetails.ts +1 -1
  58. package/src/index.ts +6 -0
@@ -6,7 +6,7 @@ exports[`OptaFootballFixtures should render correctly 1`] = `
6
6
  class="sc-bdVaJa giUBsz"
7
7
  >
8
8
  <div
9
- class="sc-htpNat sc-ifAKCX eHZPwb"
9
+ class="sc-htpNat sc-ifAKCX iHxEZu"
10
10
  />
11
11
  <div
12
12
  class="sc-bwzfXH kVYHKf"
@@ -23,7 +23,7 @@ exports[`OptaFootballFixtures should render correctly 2`] = `
23
23
  class="sc-bdVaJa hGXeaj"
24
24
  >
25
25
  <div
26
- class="sc-htpNat sc-ifAKCX eHZPwb"
26
+ class="sc-htpNat sc-ifAKCX iHxEZu"
27
27
  >
28
28
  <div>
29
29
  Widget
@@ -85,7 +85,7 @@ export const OptaFootballFixturesTicker: React.FC<{
85
85
  <WidgetContainer ref={ref} />
86
86
 
87
87
  {!isReady && (
88
- <PlaceholderContainer height={100}>
88
+ <PlaceholderContainer height={80}>
89
89
  <Placeholder />
90
90
  </PlaceholderContainer>
91
91
  )}
@@ -3,11 +3,11 @@
3
3
  exports[`OptaFootballFixturesTicker with flags should render correctly 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
- class="sc-htpNat sc-ifAKCX hfzpiP"
6
+ class="sc-htpNat sc-ifAKCX iDswry"
7
7
  />
8
8
  <div
9
- class="sc-bwzfXH eLGWmp"
10
- height="100"
9
+ class="sc-bwzfXH uxFfR"
10
+ height="80"
11
11
  >
12
12
  Placeholder
13
13
  </div>
@@ -17,7 +17,7 @@ exports[`OptaFootballFixturesTicker with flags should render correctly 1`] = `
17
17
  exports[`OptaFootballFixturesTicker with flags should render correctly 2`] = `
18
18
  <DocumentFragment>
19
19
  <div
20
- class="sc-htpNat sc-ifAKCX hfzpiP"
20
+ class="sc-htpNat sc-ifAKCX iDswry"
21
21
  >
22
22
  <div>
23
23
  Widget
@@ -29,11 +29,11 @@ exports[`OptaFootballFixturesTicker with flags should render correctly 2`] = `
29
29
  exports[`OptaFootballFixturesTicker without flags should render correctly 1`] = `
30
30
  <DocumentFragment>
31
31
  <div
32
- class="sc-htpNat sc-ifAKCX hfzpiP"
32
+ class="sc-htpNat sc-ifAKCX iDswry"
33
33
  />
34
34
  <div
35
- class="sc-bwzfXH eLGWmp"
36
- height="100"
35
+ class="sc-bwzfXH uxFfR"
36
+ height="80"
37
37
  >
38
38
  Placeholder
39
39
  </div>
@@ -43,7 +43,7 @@ exports[`OptaFootballFixturesTicker without flags should render correctly 1`] =
43
43
  exports[`OptaFootballFixturesTicker without flags should render correctly 2`] = `
44
44
  <DocumentFragment>
45
45
  <div
46
- class="sc-htpNat sc-ifAKCX hfzpiP"
46
+ class="sc-htpNat sc-ifAKCX iDswry"
47
47
  >
48
48
  <div>
49
49
  Widget
@@ -44,7 +44,37 @@ export const WidgetContainer = styled(WidgetContainerBase)`
44
44
  font-family: Roboto !important;
45
45
  }
46
46
 
47
+ .Opta-Scroll,
48
+ .Opta-Window {
49
+ height: 80px;
50
+ }
51
+
47
52
  @media (max-width: ${breakpoints.small}px) {
53
+ .Opta-Scroll {
54
+ &::before,
55
+ &::after {
56
+ content: '';
57
+ pointer-events: none;
58
+ position: absolute;
59
+ z-index: 15;
60
+ transition: all 0.3s linear 0s;
61
+ background-image: linear-gradient(
62
+ -90deg,
63
+ rgba(255, 255, 255, 0) 0%,
64
+ rgb(255, 255, 255) 100%
65
+ );
66
+ width: 64px;
67
+ height: 100%;
68
+ bottom: 0px;
69
+ left: 0;
70
+ }
71
+ &::after {
72
+ left: unset;
73
+ right: 0px;
74
+ transform: rotate(180deg);
75
+ }
76
+ }
77
+
48
78
  .Opta-Window {
49
79
  left: 0 !important;
50
80
  right: 0 !important;
@@ -53,10 +83,18 @@ export const WidgetContainer = styled(WidgetContainerBase)`
53
83
 
54
84
  .Opta-Scroller {
55
85
  background-color: white !important;
56
-
57
- border: 1px solid #999999 !important;
86
+ border: 1px solid #999 !important;
58
87
  border-radius: 2px;
88
+ box-sizing: border-box;
59
89
  padding: 39px 0 !important;
90
+ width: 28px !important;
91
+
92
+ &:hover {
93
+ background-color: #f5f5f5 !important;
94
+ }
95
+ &:active {
96
+ background-color: #eee !important;
97
+ }
60
98
 
61
99
  &::after {
62
100
  background: rgba(0, 0, 0, 0)
@@ -81,11 +119,18 @@ export const WidgetContainer = styled(WidgetContainerBase)`
81
119
  @media (max-width: ${breakpoints.small}px) {
82
120
  display: none !important;
83
121
  }
122
+ @media (max-width: ${breakpoints.medium}px) {
123
+ width: 18px !important;
124
+ }
125
+ @media (max-width: ${breakpoints.wide}px) {
126
+ width: 24px !important;
127
+ }
84
128
  }
85
129
 
86
130
  .Opta-fixture {
87
- background-color: #f5f5f5;
131
+ background-color: white;
88
132
  border-radius: 4px;
133
+ box-sizing: border-box;
89
134
  height: 80px;
90
135
  width: 160px !important;
91
136
  margin-inline: 4px;
@@ -109,16 +154,36 @@ export const WidgetContainer = styled(WidgetContainerBase)`
109
154
  .Opta-timings {
110
155
  height: 24px !important;
111
156
  order: -1;
112
- color: #aaaaaa !important;
157
+ color: #696969 !important;
158
+ }
159
+
160
+ .Opta-timings .Opta-Time * {
161
+ font-weight: 700;
162
+ color: #01000d !important;
113
163
  }
114
164
 
115
165
  .Opta-TeamName,
116
166
  .Opta-Team-Score {
117
167
  color: #01000d !important;
118
- font-weight: 700 !important;
168
+ font-family: 'Roboto-Medium' !important;
169
+ }
170
+
171
+ &.Opta-prematch {
172
+ background-color: #f5f5f5;
173
+ .Opta-Team-Score::after {
174
+ content: '-';
175
+ }
176
+ .Opta-timings .Opta-Time * {
177
+ font-weight: 400;
178
+ color: #696969 !important;
179
+ }
180
+ }
181
+
182
+ &.Opta-result {
183
+ border: 1px solid #ccc;
119
184
  }
120
- &.Opta-prematch .Opta-Team-Score::after {
121
- content: '-';
185
+ &.Opta-live {
186
+ border: 1px solid #01000d;
122
187
  }
123
188
 
124
189
  .Opta-Image-Team-Small {
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { showcaseConverter } from '@times-components/storybook';
3
+
4
+ import { ArticleHarness } from '../../../../fixtures/article-harness/ArticleHarness';
5
+ import { OptaFootballFixturesTournament } from './OptaFootballFixturesTournament';
6
+
7
+ const showcase = {
8
+ children: [
9
+ {
10
+ decorator: (storyFn: () => React.ReactNode) => (
11
+ <ArticleHarness>{storyFn()}</ArticleHarness>
12
+ ),
13
+ type: 'decorator'
14
+ },
15
+ {
16
+ component: () => (
17
+ <OptaFootballFixturesTournament
18
+ season="2023"
19
+ competition="3"
20
+ show_title={false}
21
+ full_width
22
+ />
23
+ ),
24
+ name: 'Fixture Tournament',
25
+ type: 'story'
26
+ }
27
+ ],
28
+ name: 'Typescript Component/In Article/Football/Fixtures'
29
+ };
30
+
31
+ // @ts-ignore
32
+ showcaseConverter(module, showcase);
@@ -0,0 +1,118 @@
1
+ import React, { useState, useEffect } from 'react';
2
+
3
+ import { Placeholder } from '@times-components/image';
4
+
5
+ import {
6
+ initSettings,
7
+ initStyleSheet,
8
+ initScript,
9
+ initElement,
10
+ initComponent
11
+ } from '../../utils/config';
12
+
13
+ import { Container, PlaceholderContainer } from '../shared-styles';
14
+ import { WidgetContainer } from './styles';
15
+ import { isNationalCompetition } from '../../utils/replaceNationalTeamDetails';
16
+ import { useUpdateNationalTeamDetails } from '../../utils/useUpdateNationalTeamDetails';
17
+
18
+ export const OptaFootballFixturesTournament: React.FC<{
19
+ season: string;
20
+ competition: string;
21
+ date_from?: string;
22
+ date_to?: string;
23
+ days_ahead?: number;
24
+ days_before?: number;
25
+ matchday?: string;
26
+ round?: string;
27
+ show_title?: boolean;
28
+ columns?: boolean;
29
+ full_width?: boolean;
30
+ }> = React.memo(
31
+ ({
32
+ season,
33
+ competition,
34
+ date_from,
35
+ date_to,
36
+ days_ahead,
37
+ days_before,
38
+ matchday,
39
+ round,
40
+ show_title = true,
41
+ columns = true,
42
+ full_width
43
+ }) => {
44
+ const ref = React.createRef<HTMLDivElement>();
45
+
46
+ const [isReady, setIsReady] = useState<boolean>(false);
47
+ const isNationalComp = isNationalCompetition(competition);
48
+
49
+ useEffect(() => {
50
+ const sport = 'football';
51
+
52
+ initSettings();
53
+ initStyleSheet(sport);
54
+
55
+ initScript().then(() => {
56
+ if (ref.current) {
57
+ ref.current.innerHTML = initElement(
58
+ 'opta-widget',
59
+ {
60
+ sport,
61
+ widget: 'fixtures',
62
+ season,
63
+ competition,
64
+ date_from,
65
+ date_to,
66
+ days_ahead,
67
+ days_before,
68
+ matchday,
69
+ round,
70
+ show_title,
71
+ live: true,
72
+ grouping: 'matchday',
73
+ show_grouping: true,
74
+ sub_grouping: 'date|matchday|group',
75
+ show_subgrouping: true,
76
+ show_crests: !isNationalComp,
77
+ date_format: 'dddd MMMM D YYYY',
78
+ breakpoints: 520
79
+ },
80
+ initElement('opta-widget', {
81
+ sport,
82
+ widget: 'match_summary',
83
+ season: '',
84
+ competition: '',
85
+ match: '',
86
+ live: true,
87
+ show_crests: true,
88
+ show_goals: true,
89
+ show_cards: 'red',
90
+ breakpoints: '520'
91
+ })
92
+ ).outerHTML;
93
+
94
+ initComponent();
95
+ setIsReady(true);
96
+ }
97
+ });
98
+ }, []);
99
+
100
+ isNationalComp && useUpdateNationalTeamDetails(ref, 'Opta-Team');
101
+
102
+ return (
103
+ <Container border={isReady} fullWidth={full_width}>
104
+ <WidgetContainer
105
+ ref={ref}
106
+ isNationalComp={isNationalComp}
107
+ columns={columns}
108
+ />
109
+
110
+ {!isReady && (
111
+ <PlaceholderContainer>
112
+ <Placeholder />
113
+ </PlaceholderContainer>
114
+ )}
115
+ </Container>
116
+ );
117
+ }
118
+ );
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+ import { render, waitForElementToBeRemoved } from '@testing-library/react';
3
+
4
+ import 'regenerator-runtime';
5
+ import '@testing-library/jest-dom';
6
+
7
+ jest.mock('@times-components/image', () => ({
8
+ Placeholder: () => <>Placeholder</>
9
+ }));
10
+
11
+ const mockInitSettings = jest.fn();
12
+ const mockInitStyleSheet = jest.fn();
13
+ const mockInitComponent = jest.fn();
14
+
15
+ const mockInitElement = () => {
16
+ const element = document.createElement('div');
17
+ element.appendChild(document.createTextNode('Widget'));
18
+ return element;
19
+ };
20
+
21
+ jest.mock('../../../utils/config', () => ({
22
+ initSettings: mockInitSettings,
23
+ initStyleSheet: mockInitStyleSheet,
24
+ initScript: () => new Promise(resolve => resolve({})),
25
+ initElement: mockInitElement,
26
+ initComponent: mockInitComponent
27
+ }));
28
+
29
+ import { OptaFootballFixturesTournament } from '../OptaFootballFixturesTournament';
30
+
31
+ afterEach(() => {
32
+ jest.clearAllMocks();
33
+ });
34
+
35
+ describe('OptaFootballFixturesTournament', () => {
36
+ it('should render national competitions correctly', async () => {
37
+ const { asFragment, getByText } = render(
38
+ <OptaFootballFixturesTournament season="2023" competition="3" />
39
+ );
40
+ expect(asFragment()).toMatchSnapshot();
41
+
42
+ await waitForElementToBeRemoved(getByText('Placeholder'));
43
+
44
+ expect(mockInitSettings).toHaveBeenCalledTimes(1);
45
+ expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
46
+ expect(mockInitComponent).toHaveBeenCalledTimes(1);
47
+
48
+ expect(asFragment()).toMatchSnapshot();
49
+ });
50
+ it('should render national competitions correctly with single column', async () => {
51
+ const { asFragment, getByText } = render(
52
+ <OptaFootballFixturesTournament
53
+ season="2023"
54
+ competition="3"
55
+ columns={false}
56
+ />
57
+ );
58
+ expect(asFragment()).toMatchSnapshot();
59
+
60
+ await waitForElementToBeRemoved(getByText('Placeholder'));
61
+
62
+ expect(mockInitSettings).toHaveBeenCalledTimes(1);
63
+ expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
64
+ expect(mockInitComponent).toHaveBeenCalledTimes(1);
65
+
66
+ expect(asFragment()).toMatchSnapshot();
67
+ });
68
+ it('should render other competitions correctly', async () => {
69
+ const { asFragment, getByText } = render(
70
+ <OptaFootballFixturesTournament season="2023" competition="8" />
71
+ );
72
+ expect(asFragment()).toMatchSnapshot();
73
+
74
+ await waitForElementToBeRemoved(getByText('Placeholder'));
75
+
76
+ expect(mockInitSettings).toHaveBeenCalledTimes(1);
77
+ expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
78
+ expect(mockInitComponent).toHaveBeenCalledTimes(1);
79
+
80
+ expect(asFragment()).toMatchSnapshot();
81
+ });
82
+ });
@@ -0,0 +1,100 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`OptaFootballFixturesTournament should render national competitions correctly 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="sc-bdVaJa giUBsz"
7
+ >
8
+ <div
9
+ class="sc-htpNat sc-ifAKCX hfjbYe team-flags"
10
+ />
11
+ <div
12
+ class="sc-bwzfXH kVYHKf"
13
+ >
14
+ Placeholder
15
+ </div>
16
+ </div>
17
+ </DocumentFragment>
18
+ `;
19
+
20
+ exports[`OptaFootballFixturesTournament should render national competitions correctly 2`] = `
21
+ <DocumentFragment>
22
+ <div
23
+ class="sc-bdVaJa hGXeaj"
24
+ >
25
+ <div
26
+ class="sc-htpNat sc-ifAKCX hfjbYe team-flags"
27
+ >
28
+ <div>
29
+ Widget
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </DocumentFragment>
34
+ `;
35
+
36
+ exports[`OptaFootballFixturesTournament should render national competitions correctly with single column 1`] = `
37
+ <DocumentFragment>
38
+ <div
39
+ class="sc-bdVaJa giUBsz"
40
+ >
41
+ <div
42
+ class="sc-htpNat sc-ifAKCX dNyttf team-flags"
43
+ />
44
+ <div
45
+ class="sc-bwzfXH kVYHKf"
46
+ >
47
+ Placeholder
48
+ </div>
49
+ </div>
50
+ </DocumentFragment>
51
+ `;
52
+
53
+ exports[`OptaFootballFixturesTournament should render national competitions correctly with single column 2`] = `
54
+ <DocumentFragment>
55
+ <div
56
+ class="sc-bdVaJa hGXeaj"
57
+ >
58
+ <div
59
+ class="sc-htpNat sc-ifAKCX dNyttf team-flags"
60
+ >
61
+ <div>
62
+ Widget
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </DocumentFragment>
67
+ `;
68
+
69
+ exports[`OptaFootballFixturesTournament should render other competitions correctly 1`] = `
70
+ <DocumentFragment>
71
+ <div
72
+ class="sc-bdVaJa giUBsz"
73
+ >
74
+ <div
75
+ class="sc-htpNat sc-ifAKCX dLyiar"
76
+ />
77
+ <div
78
+ class="sc-bwzfXH kVYHKf"
79
+ >
80
+ Placeholder
81
+ </div>
82
+ </div>
83
+ </DocumentFragment>
84
+ `;
85
+
86
+ exports[`OptaFootballFixturesTournament should render other competitions correctly 2`] = `
87
+ <DocumentFragment>
88
+ <div
89
+ class="sc-bdVaJa hGXeaj"
90
+ >
91
+ <div
92
+ class="sc-htpNat sc-ifAKCX dLyiar"
93
+ >
94
+ <div>
95
+ Widget
96
+ </div>
97
+ </div>
98
+ </div>
99
+ </DocumentFragment>
100
+ `;