@times-components/ts-components 1.160.1 → 1.161.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/CHANGELOG.md +11 -0
- package/dist/components/opta/football/opta-match-stats/stats-graphs/WidgetContainer.js +3 -1
- package/dist/components/opta/shared/fixtures-ticker/OptaFixturesTicker.d.ts +0 -1
- package/dist/components/opta/shared/fixtures-ticker/OptaFixturesTicker.js +4 -5
- package/dist/components/opta/shared/fixtures-ticker/styles.d.ts +0 -1
- package/dist/components/opta/shared/fixtures-ticker/styles.js +5 -8
- package/dist/components/opta/utils/__tests__/addFixturesPageLink.test.js +2 -1
- package/dist/components/opta/utils/__tests__/useAddFixtureNavigation.test.js +20 -1
- package/dist/components/opta/utils/addFixturesPageLink.js +2 -1
- package/dist/components/opta/utils/useAddFixtureNavigation.js +11 -4
- package/dist/components/trip-cards/__tests__/index.test.js +23 -1
- package/package.json +3 -3
- package/rnw.js +1 -1
- package/src/components/opta/football/opta-match-stats/stats-graphs/WidgetContainer.tsx +2 -0
- package/src/components/opta/football/opta-match-stats/stats-graphs/__tests__/__snapshots__/OptaMatchStatsGraphs.test.tsx.snap +1 -1
- package/src/components/opta/shared/fixtures-ticker/OptaFixturesTicker.tsx +2 -10
- package/src/components/opta/shared/fixtures-ticker/__tests__/__snapshots__/OptaFixturesTicker.test.tsx.snap +5 -5
- package/src/components/opta/shared/fixtures-ticker/styles.ts +4 -9
- package/src/components/opta/utils/__tests__/addFixturesPageLink.test.tsx +1 -0
- package/src/components/opta/utils/__tests__/useAddFixtureNavigation.test.tsx +22 -0
- package/src/components/opta/utils/addFixturesPageLink.ts +1 -0
- package/src/components/opta/utils/useAddFixtureNavigation.ts +13 -3
- package/src/components/trip-cards/__tests__/index.test.tsx +24 -0
|
@@ -242,6 +242,8 @@ export const WidgetContainer = styled.div<{
|
|
|
242
242
|
}
|
|
243
243
|
@media (max-width: ${maxMDBreakpoint}px) {
|
|
244
244
|
font-weight: 500;
|
|
245
|
+
height: auto !important;
|
|
246
|
+
min-height: 30px;
|
|
245
247
|
// Stops labels overlapping stat numbers
|
|
246
248
|
padding-inline: 60px !important;
|
|
247
249
|
}
|
|
@@ -31,7 +31,6 @@ export type OptaFixturesTickerProps = {
|
|
|
31
31
|
showButtons?: boolean;
|
|
32
32
|
fixturesPageUrl?: string;
|
|
33
33
|
sport: OptaSport;
|
|
34
|
-
enableMatchStatsNavigation?: 'true' | 'false';
|
|
35
34
|
matchStatsBasePath?: string;
|
|
36
35
|
};
|
|
37
36
|
|
|
@@ -48,7 +47,6 @@ export const OptaFixturesTicker: React.FC<OptaFixturesTickerProps> = React.memo(
|
|
|
48
47
|
showButtons,
|
|
49
48
|
fixturesPageUrl,
|
|
50
49
|
sport,
|
|
51
|
-
enableMatchStatsNavigation = 'false',
|
|
52
50
|
matchStatsBasePath
|
|
53
51
|
}) => {
|
|
54
52
|
const ref = React.createRef<HTMLDivElement>();
|
|
@@ -105,8 +103,7 @@ export const OptaFixturesTicker: React.FC<OptaFixturesTickerProps> = React.memo(
|
|
|
105
103
|
!isApp &&
|
|
106
104
|
useFixturePageLink(ref, 'Opta-Room', fixturesPageUrl);
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
sport === 'football' &&
|
|
106
|
+
sport === 'football' &&
|
|
110
107
|
useAddFixtureNavigation({
|
|
111
108
|
ref,
|
|
112
109
|
sport,
|
|
@@ -122,12 +119,7 @@ export const OptaFixturesTicker: React.FC<OptaFixturesTickerProps> = React.memo(
|
|
|
122
119
|
<Placeholder />
|
|
123
120
|
</PlaceholderContainer>
|
|
124
121
|
)}
|
|
125
|
-
<WidgetContainer
|
|
126
|
-
ref={ref}
|
|
127
|
-
isApp={isApp}
|
|
128
|
-
showButtons={showButtons}
|
|
129
|
-
enableMatchStatsNavigation={enableMatchStatsNavigation === 'true'}
|
|
130
|
-
/>
|
|
122
|
+
<WidgetContainer ref={ref} isApp={isApp} showButtons={showButtons} />
|
|
131
123
|
</Container>
|
|
132
124
|
);
|
|
133
125
|
}
|
|
@@ -11,7 +11,7 @@ exports[`OptaFixturesTicker rugby should render correctly 1`] = `
|
|
|
11
11
|
Placeholder
|
|
12
12
|
</div>
|
|
13
13
|
<div
|
|
14
|
-
class="sc-htpNat sc-EHOje
|
|
14
|
+
class="sc-htpNat sc-EHOje hGWwCO"
|
|
15
15
|
/>
|
|
16
16
|
</div>
|
|
17
17
|
</DocumentFragment>
|
|
@@ -28,7 +28,7 @@ exports[`OptaFixturesTicker with flags should render correctly 1`] = `
|
|
|
28
28
|
Placeholder
|
|
29
29
|
</div>
|
|
30
30
|
<div
|
|
31
|
-
class="sc-htpNat sc-EHOje
|
|
31
|
+
class="sc-htpNat sc-EHOje hGWwCO"
|
|
32
32
|
/>
|
|
33
33
|
</div>
|
|
34
34
|
</DocumentFragment>
|
|
@@ -45,7 +45,7 @@ exports[`OptaFixturesTicker without flags should render correctly 1`] = `
|
|
|
45
45
|
Placeholder
|
|
46
46
|
</div>
|
|
47
47
|
<div
|
|
48
|
-
class="sc-htpNat sc-EHOje
|
|
48
|
+
class="sc-htpNat sc-EHOje hGWwCO"
|
|
49
49
|
/>
|
|
50
50
|
</div>
|
|
51
51
|
</DocumentFragment>
|
|
@@ -62,7 +62,7 @@ exports[`OptaFixturesTicker without flags should render correctly with fixturesP
|
|
|
62
62
|
Placeholder
|
|
63
63
|
</div>
|
|
64
64
|
<div
|
|
65
|
-
class="sc-htpNat sc-EHOje
|
|
65
|
+
class="sc-htpNat sc-EHOje hGWwCO"
|
|
66
66
|
/>
|
|
67
67
|
</div>
|
|
68
68
|
</DocumentFragment>
|
|
@@ -79,7 +79,7 @@ exports[`OptaFixturesTicker without flags should render correctly with isApp pro
|
|
|
79
79
|
Placeholder
|
|
80
80
|
</div>
|
|
81
81
|
<div
|
|
82
|
-
class="sc-htpNat sc-EHOje
|
|
82
|
+
class="sc-htpNat sc-EHOje nwAwg"
|
|
83
83
|
/>
|
|
84
84
|
</div>
|
|
85
85
|
</DocumentFragment>
|
|
@@ -48,7 +48,6 @@ export const WidgetContainerOverride = styled(WidgetContainerBase)`
|
|
|
48
48
|
export const WidgetContainer = styled(WidgetContainerBase)<{
|
|
49
49
|
isApp?: boolean;
|
|
50
50
|
showButtons?: boolean;
|
|
51
|
-
enableMatchStatsNavigation?: boolean;
|
|
52
51
|
}>`
|
|
53
52
|
|
|
54
53
|
|
|
@@ -206,14 +205,10 @@ export const WidgetContainer = styled(WidgetContainerBase)<{
|
|
|
206
205
|
display: flex;
|
|
207
206
|
flex-direction: column;
|
|
208
207
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
cursor: pointer;
|
|
214
|
-
}
|
|
215
|
-
`}
|
|
216
|
-
|
|
208
|
+
&[data-has-fixtures-page-link='true']:hover {
|
|
209
|
+
cursor: pointer;
|
|
210
|
+
}
|
|
211
|
+
|
|
217
212
|
> div {
|
|
218
213
|
background-color: white !important;
|
|
219
214
|
}
|
|
@@ -232,4 +232,26 @@ describe('useAddFixtureNavigation', () => {
|
|
|
232
232
|
const fixture = container.querySelector('.Opta-fixture') as any;
|
|
233
233
|
expect(fixture._optaClickBound).toBe(true);
|
|
234
234
|
});
|
|
235
|
+
|
|
236
|
+
it('does not bind click handler for PreMatch or Abandoned fixtures', () => {
|
|
237
|
+
const html = `
|
|
238
|
+
<div class="Opta-fixture" data-match="2561904" data-period="PreMatch">
|
|
239
|
+
<span class="Opta-Team Opta-Home Opta-Team-123"></span>
|
|
240
|
+
<span class="Opta-Team Opta-Away Opta-Team-456"></span>
|
|
241
|
+
</div>
|
|
242
|
+
<div class="Opta-fixture" data-match="2561905" data-period="Abandoned">
|
|
243
|
+
<span class="Opta-Team Opta-Home Opta-Team-123"></span>
|
|
244
|
+
<span class="Opta-Team Opta-Away Opta-Team-456"></span>
|
|
245
|
+
</div>
|
|
246
|
+
`;
|
|
247
|
+
|
|
248
|
+
renderFixtures(html);
|
|
249
|
+
act(() => {
|
|
250
|
+
jest.advanceTimersByTime(500);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
const fixtures = container.querySelectorAll('.Opta-fixture');
|
|
254
|
+
expect((fixtures[0] as any)._optaClickBound).toBeUndefined();
|
|
255
|
+
expect((fixtures[1] as any)._optaClickBound).toBeUndefined();
|
|
256
|
+
});
|
|
235
257
|
});
|
|
@@ -70,6 +70,11 @@ const updateTimestamps = (
|
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
// Only allow navigation for Premier League games with stats available.
|
|
74
|
+
if (['PreMatch', 'Abandoned'].includes(status) || competition !== '8') {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
const safeWindow = window as any;
|
|
74
79
|
const isIOS =
|
|
75
80
|
safeWindow.webkit &&
|
|
@@ -80,14 +85,18 @@ const updateTimestamps = (
|
|
|
80
85
|
|
|
81
86
|
const baseMatchStatsPath =
|
|
82
87
|
matchStatsBasePath || `/sport/${sport}/match-stats`;
|
|
83
|
-
|
|
88
|
+
let navigationUrl =
|
|
84
89
|
`${baseMatchStatsPath}?competition=${competition}` +
|
|
85
90
|
`&season=${season}` +
|
|
86
91
|
`&match=${match}` +
|
|
87
92
|
`&status=${status}` +
|
|
88
93
|
`&homeTeam=${homeTeam}` +
|
|
89
|
-
`&awayTeam=${awayTeam}
|
|
90
|
-
|
|
94
|
+
`&awayTeam=${awayTeam}`;
|
|
95
|
+
|
|
96
|
+
if (baseMatchStatsPath.includes('world-cup-2026')) {
|
|
97
|
+
navigationUrl += '&enableMatchStats=true';
|
|
98
|
+
}
|
|
99
|
+
|
|
91
100
|
const appMessage = {
|
|
92
101
|
type: 'openPage',
|
|
93
102
|
title: 'Football',
|
|
@@ -105,6 +114,7 @@ const updateTimestamps = (
|
|
|
105
114
|
window.location.href = navigationUrl;
|
|
106
115
|
}
|
|
107
116
|
});
|
|
117
|
+
el.setAttribute('data-has-fixtures-page-link', 'true');
|
|
108
118
|
(el as any)._optaClickBound = true;
|
|
109
119
|
clearInterval(updateTimestampsInterval);
|
|
110
120
|
});
|
|
@@ -79,7 +79,27 @@ describe('TripCards', () => {
|
|
|
79
79
|
titleurl: 'https://example.com'
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
const RealDate = global.Date;
|
|
83
|
+
|
|
82
84
|
beforeEach(() => {
|
|
85
|
+
const fixedDate = new RealDate('2025-12-01T00:00:00Z');
|
|
86
|
+
// tslint:disable-next-line
|
|
87
|
+
const MockDate = class extends RealDate {
|
|
88
|
+
constructor(...args: any[]) {
|
|
89
|
+
if (args.length === 0) {
|
|
90
|
+
super(fixedDate.getTime());
|
|
91
|
+
} else {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
super(...args);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// tslint:disable-next-line
|
|
98
|
+
static now() {
|
|
99
|
+
return fixedDate.getTime();
|
|
100
|
+
}
|
|
101
|
+
} as DateConstructor;
|
|
102
|
+
global.Date = MockDate;
|
|
83
103
|
jest.clearAllMocks();
|
|
84
104
|
|
|
85
105
|
// Mock matchMedia for each test
|
|
@@ -110,6 +130,10 @@ describe('TripCards', () => {
|
|
|
110
130
|
});
|
|
111
131
|
});
|
|
112
132
|
|
|
133
|
+
afterEach(() => {
|
|
134
|
+
global.Date = RealDate;
|
|
135
|
+
});
|
|
136
|
+
|
|
113
137
|
describe('Mock Data Mode', () => {
|
|
114
138
|
it('renders cards when useMockData is true', async () => {
|
|
115
139
|
render(<TripCards element={mockElement} useMockData={true} />);
|