@times-components/ts-components 1.88.1 → 1.88.2-alpha.5
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/dist/components/opta/football/fixtures-ticker/OptaFootballFixturesTicker.js +2 -2
- package/dist/components/opta/football/fixtures-ticker/styles.js +73 -8
- package/dist/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.d.ts +9 -0
- package/dist/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.js +57 -0
- package/dist/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.stories.d.ts +1 -0
- package/dist/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.stories.js +21 -0
- package/dist/components/opta/football/fixtures-tournament/__tests__/OptaFootballFixtures.test.d.ts +2 -0
- package/dist/components/opta/football/fixtures-tournament/__tests__/OptaFootballFixtures.test.js +39 -0
- package/dist/components/opta/football/fixtures-tournament/styles.d.ts +4 -0
- package/dist/components/opta/football/fixtures-tournament/styles.js +266 -0
- package/dist/components/opta/football/player-stats/OptaFootballPlayerStats.d.ts +8 -0
- package/dist/components/opta/football/player-stats/OptaFootballPlayerStats.js +47 -0
- package/dist/components/opta/football/player-stats/OptaFootballPlayerStats.stories.d.ts +1 -0
- package/dist/components/opta/football/player-stats/OptaFootballPlayerStats.stories.js +26 -0
- package/dist/components/opta/football/player-stats/__tests__/OptaFootballMatchStats.test.d.ts +2 -0
- package/dist/components/opta/football/player-stats/__tests__/OptaFootballMatchStats.test.js +41 -0
- package/dist/components/opta/football/player-stats/styles.d.ts +1 -0
- package/dist/components/opta/football/player-stats/styles.js +153 -0
- package/dist/components/opta/football/shared-styles.js +23 -7
- package/dist/components/opta/football/standings/OptaFootballStandings.d.ts +1 -0
- package/dist/components/opta/football/standings/OptaFootballStandings.js +4 -4
- package/dist/components/opta/football/standings/OptaFootballStandings.stories.js +6 -1
- package/dist/components/opta/football/standings/__tests__/OptaFootballStandings.test.js +10 -1
- package/dist/components/opta/football/standings/styles.d.ts +3 -1
- package/dist/components/opta/football/standings/styles.js +5 -1
- package/dist/components/opta/utils/replaceNationalTeamDetails.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/package.json +16 -16
- package/rnw.js +1 -1
- package/src/components/opta/football/fixtures/__tests__/__snapshots__/OptaFootballFixtures.test.tsx.snap +2 -2
- package/src/components/opta/football/fixtures-ticker/OptaFootballFixturesTicker.tsx +1 -1
- package/src/components/opta/football/fixtures-ticker/__tests__/__snapshots__/OptaFootballFixturesTicker.test.tsx.snap +8 -8
- package/src/components/opta/football/fixtures-ticker/styles.ts +72 -7
- package/src/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.stories.tsx +32 -0
- package/src/components/opta/football/fixtures-tournament/OptaFootballFixturesTournament.tsx +93 -0
- package/src/components/opta/football/fixtures-tournament/__tests__/OptaFootballFixtures.test.tsx +51 -0
- package/src/components/opta/football/fixtures-tournament/__tests__/__snapshots__/OptaFootballFixtures.test.tsx.snap +34 -0
- package/src/components/opta/football/fixtures-tournament/styles.ts +273 -0
- package/src/components/opta/football/match-stats/__tests__/__snapshots__/OptaFootballMatchStats.test.tsx.snap +2 -2
- package/src/components/opta/football/player-stats/OptaFootballPlayerStats.stories.tsx +44 -0
- package/src/components/opta/football/player-stats/OptaFootballPlayerStats.tsx +81 -0
- package/src/components/opta/football/player-stats/__tests__/OptaFootballMatchStats.test.tsx +53 -0
- package/src/components/opta/football/player-stats/__tests__/__snapshots__/OptaFootballMatchStats.test.tsx.snap +34 -0
- package/src/components/opta/football/player-stats/styles.ts +154 -0
- package/src/components/opta/football/shared-styles.ts +22 -6
- package/src/components/opta/football/standings/OptaFootballStandings.stories.tsx +12 -0
- package/src/components/opta/football/standings/OptaFootballStandings.tsx +33 -28
- package/src/components/opta/football/standings/__tests__/OptaFootballStandings.test.tsx +15 -0
- package/src/components/opta/football/standings/__tests__/__snapshots__/OptaFootballStandings.test.tsx.snap +35 -2
- package/src/components/opta/football/standings/styles.ts +7 -1
- package/src/components/opta/football/summary/__tests__/__snapshots__/OptaFootballSummary.test.tsx.snap +2 -2
- package/src/components/opta/utils/replaceNationalTeamDetails.ts +1 -1
- package/src/index.ts +6 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { showcaseConverter } from '@times-components/storybook';
|
|
3
|
+
|
|
4
|
+
import { ArticleHarness } from '../../../../fixtures/article-harness/ArticleHarness';
|
|
5
|
+
import { OptaFootballPlayerStats } from './OptaFootballPlayerStats';
|
|
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
|
+
<OptaFootballPlayerStats
|
|
18
|
+
season="2020"
|
|
19
|
+
competition="3"
|
|
20
|
+
visible_categories="goals"
|
|
21
|
+
match="2041900"
|
|
22
|
+
/>
|
|
23
|
+
),
|
|
24
|
+
name: 'PlayerStats (goals)',
|
|
25
|
+
type: 'story'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
component: () => (
|
|
29
|
+
<OptaFootballPlayerStats
|
|
30
|
+
season="2020"
|
|
31
|
+
competition="3"
|
|
32
|
+
visible_categories="assists"
|
|
33
|
+
match="2041900"
|
|
34
|
+
/>
|
|
35
|
+
),
|
|
36
|
+
name: 'PlayerStats (assists)',
|
|
37
|
+
type: 'story'
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
name: 'Typescript Component/In Article/Football/PlayerStats'
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
showcaseConverter(module, showcase);
|
|
@@ -0,0 +1,81 @@
|
|
|
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 OptaFootballPlayerStats: React.FC<{
|
|
19
|
+
season: string;
|
|
20
|
+
competition: string;
|
|
21
|
+
match: string;
|
|
22
|
+
visible_categories: string; // goals | assists | cards_red | cards_yellow
|
|
23
|
+
full_width?: boolean;
|
|
24
|
+
}> = React.memo(
|
|
25
|
+
({ season, competition, match, full_width, visible_categories }) => {
|
|
26
|
+
const ref = React.createRef<HTMLDivElement>();
|
|
27
|
+
|
|
28
|
+
const [isReady, setIsReady] = useState<boolean>(false);
|
|
29
|
+
const isNationalComp = isNationalCompetition(competition);
|
|
30
|
+
|
|
31
|
+
useEffect(
|
|
32
|
+
() => {
|
|
33
|
+
const sport = 'football';
|
|
34
|
+
|
|
35
|
+
initSettings();
|
|
36
|
+
initStyleSheet(sport);
|
|
37
|
+
|
|
38
|
+
initScript().then(() => {
|
|
39
|
+
if (ref.current) {
|
|
40
|
+
ref.current.innerHTML = initElement('opta-widget', {
|
|
41
|
+
sport,
|
|
42
|
+
widget: 'player_ranking',
|
|
43
|
+
season,
|
|
44
|
+
competition,
|
|
45
|
+
match,
|
|
46
|
+
template: 'normal',
|
|
47
|
+
graph_style: 'relative',
|
|
48
|
+
visible_categories,
|
|
49
|
+
live: true,
|
|
50
|
+
show_match_header: true,
|
|
51
|
+
show_halftime_score: true,
|
|
52
|
+
show_competition_name: true,
|
|
53
|
+
show_date: true,
|
|
54
|
+
show_crests: true,
|
|
55
|
+
date_format: 'DD/MM/YYYY',
|
|
56
|
+
breakpoints: '520'
|
|
57
|
+
}).outerHTML;
|
|
58
|
+
|
|
59
|
+
initComponent();
|
|
60
|
+
setIsReady(true);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
[ref]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
isNationalComp && useUpdateNationalTeamDetails(ref, 'Opta-Image-Team');
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Container border={isReady} fullWidth={full_width}>
|
|
71
|
+
<WidgetContainer ref={ref} />
|
|
72
|
+
|
|
73
|
+
{!isReady && (
|
|
74
|
+
<PlaceholderContainer>
|
|
75
|
+
<Placeholder />
|
|
76
|
+
</PlaceholderContainer>
|
|
77
|
+
)}
|
|
78
|
+
</Container>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { OptaFootballPlayerStats } from '../OptaFootballPlayerStats';
|
|
30
|
+
|
|
31
|
+
const requiredProps = {
|
|
32
|
+
season: '2020',
|
|
33
|
+
competition: '3',
|
|
34
|
+
visible_categories: 'goals',
|
|
35
|
+
match: '2041900'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
describe('OptaFootballPlayerStats', () => {
|
|
39
|
+
it('should render correctly', async () => {
|
|
40
|
+
const { asFragment, getByText } = render(
|
|
41
|
+
<OptaFootballPlayerStats {...requiredProps} />
|
|
42
|
+
);
|
|
43
|
+
expect(asFragment()).toMatchSnapshot();
|
|
44
|
+
|
|
45
|
+
await waitForElementToBeRemoved(getByText('Placeholder'));
|
|
46
|
+
|
|
47
|
+
expect(mockInitSettings).toHaveBeenCalledTimes(2);
|
|
48
|
+
expect(mockInitStyleSheet).toHaveBeenCalledTimes(2);
|
|
49
|
+
expect(mockInitComponent).toHaveBeenCalledTimes(2);
|
|
50
|
+
|
|
51
|
+
expect(asFragment()).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`OptaFootballPlayerStats should render correctly 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="sc-bdVaJa giUBsz"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="sc-htpNat sc-bxivhb iNxpQd team-flags"
|
|
10
|
+
/>
|
|
11
|
+
<div
|
|
12
|
+
class="sc-bwzfXH kVYHKf"
|
|
13
|
+
>
|
|
14
|
+
Placeholder
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</DocumentFragment>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`OptaFootballPlayerStats should render correctly 2`] = `
|
|
21
|
+
<DocumentFragment>
|
|
22
|
+
<div
|
|
23
|
+
class="sc-bdVaJa hGXeaj"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="sc-htpNat sc-bxivhb iNxpQd team-flags"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Widget
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { breakpoints, colours, fonts } from '@times-components/ts-styleguide';
|
|
3
|
+
|
|
4
|
+
import { WidgetContainerBase } from '../shared-styles';
|
|
5
|
+
|
|
6
|
+
export const WidgetContainer = styled(WidgetContainerBase)`
|
|
7
|
+
.Opta {
|
|
8
|
+
h2 {
|
|
9
|
+
margin: 20px 0 10px 0 !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.Opta-Cf {
|
|
13
|
+
padding: 0;
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
|
|
16
|
+
table {
|
|
17
|
+
tbody {
|
|
18
|
+
tr {
|
|
19
|
+
th.Opta-Stats-Bars-Text {
|
|
20
|
+
height: auto;
|
|
21
|
+
padding: 20px 0 0 0;
|
|
22
|
+
color: ${colours.functional.brandColour};
|
|
23
|
+
font-family: ${fonts.supporting};
|
|
24
|
+
font-size: 13px;
|
|
25
|
+
line-height: 14px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
td {
|
|
29
|
+
height: auto;
|
|
30
|
+
color: ${colours.functional.brandColour};
|
|
31
|
+
font-family: ${fonts.headline};
|
|
32
|
+
font-size: 18px;
|
|
33
|
+
line-height: 18px;
|
|
34
|
+
padding: 0;
|
|
35
|
+
|
|
36
|
+
&.Opta-Crest {
|
|
37
|
+
text-align: left;
|
|
38
|
+
|
|
39
|
+
&.Opta-Home {
|
|
40
|
+
text-align: right;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
img {
|
|
44
|
+
width: 40px;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.Opta-Team {
|
|
49
|
+
padding-left: 10px;
|
|
50
|
+
font-size: 18px;
|
|
51
|
+
line-height: 18px;
|
|
52
|
+
|
|
53
|
+
&.Opta-Home {
|
|
54
|
+
padding-right: 10px;
|
|
55
|
+
padding-left: 0;
|
|
56
|
+
text-align: right;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&.Opta-Score {
|
|
61
|
+
width: 20px;
|
|
62
|
+
font-size: 24px;
|
|
63
|
+
line-height: 24px;
|
|
64
|
+
text-align: left;
|
|
65
|
+
|
|
66
|
+
&.Opta-Home {
|
|
67
|
+
text-align: right;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
span {
|
|
71
|
+
min-width: 0;
|
|
72
|
+
padding: 0;
|
|
73
|
+
color: inherit;
|
|
74
|
+
font-family: inherit;
|
|
75
|
+
font-size: inherit;
|
|
76
|
+
line-height: inherit;
|
|
77
|
+
text-align: inherit;
|
|
78
|
+
background-color: transparent !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@media (min-width: ${breakpoints.medium}px) {
|
|
82
|
+
width: 30px;
|
|
83
|
+
font-size: 32px;
|
|
84
|
+
line-height: 32px;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&.Opta-Divider {
|
|
89
|
+
width: 20px;
|
|
90
|
+
text-align: center;
|
|
91
|
+
|
|
92
|
+
abbr {
|
|
93
|
+
font-size: inherit;
|
|
94
|
+
line-height: inherit;
|
|
95
|
+
text-decoration: none;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.Opta-Bars {
|
|
100
|
+
margin: 0;
|
|
101
|
+
|
|
102
|
+
.Opta-Percent.Opta-Home {
|
|
103
|
+
background-color: ${colours.section.sport};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.Opta-Percent.Opta-Away {
|
|
107
|
+
background-color: ${colours.section.sport};
|
|
108
|
+
opacity: 0.5;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&.Opta-Score-Extras {
|
|
114
|
+
td {
|
|
115
|
+
color: ${colours.functional.brandColour};
|
|
116
|
+
font-family: ${fonts.supporting};
|
|
117
|
+
font-size: 14px;
|
|
118
|
+
line-height: 28px;
|
|
119
|
+
|
|
120
|
+
span {
|
|
121
|
+
color: inherit;
|
|
122
|
+
font-size: inherit;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&.Opta-MatchHeader-Details {
|
|
128
|
+
div {
|
|
129
|
+
padding: 0;
|
|
130
|
+
color: ${colours.section.sport};
|
|
131
|
+
font-family: ${fonts.supporting};
|
|
132
|
+
font-size: 12px;
|
|
133
|
+
line-height: 12px;
|
|
134
|
+
letter-spacing: 1px;
|
|
135
|
+
text-transform: uppercase;
|
|
136
|
+
background-color: transparent;
|
|
137
|
+
|
|
138
|
+
span {
|
|
139
|
+
margin: 0 6px;
|
|
140
|
+
color: inherit;
|
|
141
|
+
font-size: inherit;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
&.Opta-Stats-Bars {
|
|
149
|
+
margin-bottom: 20px;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
`;
|
|
@@ -30,26 +30,42 @@ const countries: Record<string, string> = {
|
|
|
30
30
|
|
|
31
31
|
const flagStyles = Object.keys(countries).map(
|
|
32
32
|
(countryCode: string) => `
|
|
33
|
-
.Opta-Team-${countryCode} .Opta-Team, .Opta-Team-${countryCode}.Opta-Team
|
|
33
|
+
.Opta-Team-${countryCode} .Opta-Team, .Opta-Team-${countryCode}.Opta-Team, .Opta-Player .Opta-Image-Team-${countryCode} {
|
|
34
34
|
background-image: url(https://nuk-tnl-editorial-prod-staticassets.s3.eu-west-1.amazonaws.com/opta/euro-flags/${
|
|
35
35
|
countries[countryCode]
|
|
36
36
|
}.svg);
|
|
37
37
|
background-size: 20px;
|
|
38
38
|
background-repeat: no-repeat;
|
|
39
|
-
|
|
40
|
-
@media (max-width: ${breakpoints.small}px) {
|
|
41
|
-
background-image: none;
|
|
42
|
-
padding-left: 0 !important;
|
|
43
|
-
}
|
|
44
39
|
}
|
|
45
40
|
.Opta-Team-${countryCode} .Opta-Team {
|
|
46
41
|
background-position: 0 13px;
|
|
47
42
|
padding-left: 28px;
|
|
43
|
+
|
|
44
|
+
@media (max-width: ${breakpoints.small}px) {
|
|
45
|
+
background-image: none;
|
|
46
|
+
padding-left: 0 !important;
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
49
|
.Opta-Team-${countryCode}.Opta-Team {
|
|
50
50
|
background-position: 10px 8px;
|
|
51
51
|
padding-left: 38px !important;
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
.Opta-Player .Opta-Image-Team-${countryCode} {
|
|
55
|
+
width: 100%;
|
|
56
|
+
display: block;
|
|
57
|
+
height: 100%;
|
|
58
|
+
background-position: 7px 3px;
|
|
59
|
+
|
|
60
|
+
&.Opta-Image-Medium {
|
|
61
|
+
background-size: 35px;
|
|
62
|
+
background-position: 0 6px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
img {
|
|
66
|
+
display: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
53
69
|
`
|
|
54
70
|
);
|
|
55
71
|
|
|
@@ -17,6 +17,18 @@ const showcase = {
|
|
|
17
17
|
name: 'Standings',
|
|
18
18
|
type: 'story'
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
component: () => (
|
|
22
|
+
<OptaFootballStandings
|
|
23
|
+
season="2023"
|
|
24
|
+
competition="3"
|
|
25
|
+
full_width
|
|
26
|
+
columns
|
|
27
|
+
/>
|
|
28
|
+
),
|
|
29
|
+
name: 'Standings (2 columns - desktop)',
|
|
30
|
+
type: 'story'
|
|
31
|
+
},
|
|
20
32
|
{
|
|
21
33
|
component: () => <OptaFootballStandings season="2023" competition="3" />,
|
|
22
34
|
name: 'Standings (inline)',
|
|
@@ -21,48 +21,53 @@ export const OptaFootballStandings: React.FC<{
|
|
|
21
21
|
default_nav?: string;
|
|
22
22
|
navigation?: boolean;
|
|
23
23
|
full_width?: boolean;
|
|
24
|
+
columns?: boolean;
|
|
24
25
|
}> = React.memo(
|
|
25
|
-
({
|
|
26
|
+
({
|
|
27
|
+
season,
|
|
28
|
+
competition,
|
|
29
|
+
default_nav = 1,
|
|
30
|
+
navigation,
|
|
31
|
+
full_width,
|
|
32
|
+
columns
|
|
33
|
+
}) => {
|
|
26
34
|
const ref = React.createRef<HTMLDivElement>();
|
|
27
35
|
|
|
28
36
|
const [isReady, setIsReady] = useState<boolean>(false);
|
|
29
37
|
const isNationalComp = isNationalCompetition(competition);
|
|
30
38
|
|
|
31
|
-
useEffect(
|
|
32
|
-
|
|
33
|
-
const sport = 'football';
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const sport = 'football';
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
initSettings();
|
|
43
|
+
initStyleSheet(sport);
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
initScript().then(() => {
|
|
46
|
+
if (ref.current) {
|
|
47
|
+
ref.current.innerHTML = initElement('opta-widget', {
|
|
48
|
+
sport,
|
|
49
|
+
widget: 'standings',
|
|
50
|
+
season,
|
|
51
|
+
competition,
|
|
52
|
+
live: true,
|
|
53
|
+
navigation: navigation ? 'dropdown' : undefined,
|
|
54
|
+
default_nav,
|
|
55
|
+
show_crests: !isNationalComp,
|
|
56
|
+
team_naming: 'brief',
|
|
57
|
+
breakpoints: 520
|
|
58
|
+
}).outerHTML;
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[ref]
|
|
59
|
-
);
|
|
60
|
+
initComponent();
|
|
61
|
+
setIsReady(true);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}, []);
|
|
60
65
|
|
|
61
66
|
isNationalComp && useUpdateNationalTeamDetails(ref, 'Opta-Team');
|
|
62
67
|
|
|
63
68
|
return (
|
|
64
69
|
<Container border={isReady} fullWidth={full_width}>
|
|
65
|
-
<WidgetContainer ref={ref} />
|
|
70
|
+
<WidgetContainer ref={ref} columns={columns} />
|
|
66
71
|
|
|
67
72
|
{!isReady && (
|
|
68
73
|
<PlaceholderContainer>
|
|
@@ -42,6 +42,21 @@ describe('OptaFootballStandings', () => {
|
|
|
42
42
|
|
|
43
43
|
await waitForElementToBeRemoved(getByText('Placeholder'));
|
|
44
44
|
|
|
45
|
+
expect(mockInitSettings).toHaveBeenCalledTimes(1);
|
|
46
|
+
expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
|
|
47
|
+
expect(mockInitComponent).toHaveBeenCalledTimes(1);
|
|
48
|
+
|
|
49
|
+
expect(asFragment()).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should render correctly, with columns', async () => {
|
|
53
|
+
const { asFragment, getByText } = render(
|
|
54
|
+
<OptaFootballStandings columns {...requiredProps} />
|
|
55
|
+
);
|
|
56
|
+
expect(asFragment()).toMatchSnapshot();
|
|
57
|
+
|
|
58
|
+
await waitForElementToBeRemoved(getByText('Placeholder'));
|
|
59
|
+
|
|
45
60
|
expect(mockInitSettings).toHaveBeenCalledTimes(2);
|
|
46
61
|
expect(mockInitStyleSheet).toHaveBeenCalledTimes(2);
|
|
47
62
|
expect(mockInitComponent).toHaveBeenCalledTimes(2);
|
|
@@ -6,7 +6,7 @@ exports[`OptaFootballStandings should render correctly 1`] = `
|
|
|
6
6
|
class="sc-bdVaJa giUBsz"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
|
-
class="sc-htpNat sc-bxivhb
|
|
9
|
+
class="sc-htpNat sc-bxivhb jlQRkQ team-flags"
|
|
10
10
|
/>
|
|
11
11
|
<div
|
|
12
12
|
class="sc-bwzfXH kVYHKf"
|
|
@@ -23,7 +23,40 @@ exports[`OptaFootballStandings should render correctly 2`] = `
|
|
|
23
23
|
class="sc-bdVaJa hGXeaj"
|
|
24
24
|
>
|
|
25
25
|
<div
|
|
26
|
-
class="sc-htpNat sc-bxivhb
|
|
26
|
+
class="sc-htpNat sc-bxivhb jlQRkQ team-flags"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Widget
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
exports[`OptaFootballStandings should render correctly, with columns 1`] = `
|
|
37
|
+
<DocumentFragment>
|
|
38
|
+
<div
|
|
39
|
+
class="sc-bdVaJa giUBsz"
|
|
40
|
+
>
|
|
41
|
+
<div
|
|
42
|
+
class="sc-htpNat sc-bxivhb hCEQsc team-flags"
|
|
43
|
+
/>
|
|
44
|
+
<div
|
|
45
|
+
class="sc-bwzfXH kVYHKf"
|
|
46
|
+
>
|
|
47
|
+
Placeholder
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</DocumentFragment>
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
exports[`OptaFootballStandings should render correctly, with columns 2`] = `
|
|
54
|
+
<DocumentFragment>
|
|
55
|
+
<div
|
|
56
|
+
class="sc-bdVaJa hGXeaj"
|
|
57
|
+
>
|
|
58
|
+
<div
|
|
59
|
+
class="sc-htpNat sc-bxivhb hCEQsc team-flags"
|
|
27
60
|
>
|
|
28
61
|
<div>
|
|
29
62
|
Widget
|
|
@@ -3,7 +3,9 @@ import { breakpoints, colours, fonts } from '@times-components/ts-styleguide';
|
|
|
3
3
|
|
|
4
4
|
import { WidgetContainerBase } from '../shared-styles';
|
|
5
5
|
|
|
6
|
-
export const WidgetContainer = styled(WidgetContainerBase)
|
|
6
|
+
export const WidgetContainer = styled(WidgetContainerBase)<{
|
|
7
|
+
columns?: boolean;
|
|
8
|
+
}>`
|
|
7
9
|
.Opta {
|
|
8
10
|
h3.Opta-groupname {
|
|
9
11
|
height: 40px;
|
|
@@ -33,6 +35,10 @@ export const WidgetContainer = styled(WidgetContainerBase)`
|
|
|
33
35
|
padding: 0;
|
|
34
36
|
background-color: transparent;
|
|
35
37
|
|
|
38
|
+
@media (min-width: ${breakpoints.medium}px) {
|
|
39
|
+
${({ columns }) => columns && 'column-count: 2;'};
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
&.Opta-Dropdown {
|
|
37
43
|
.Opta-Nav {
|
|
38
44
|
width: 110px;
|
|
@@ -6,7 +6,7 @@ exports[`OptaFootballSummary should render correctly 1`] = `
|
|
|
6
6
|
class="sc-bdVaJa giUBsz"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
|
-
class="sc-htpNat sc-bxivhb
|
|
9
|
+
class="sc-htpNat sc-bxivhb kUcFdM"
|
|
10
10
|
/>
|
|
11
11
|
<div
|
|
12
12
|
class="sc-bwzfXH kVYHKf"
|
|
@@ -23,7 +23,7 @@ exports[`OptaFootballSummary should render correctly 2`] = `
|
|
|
23
23
|
class="sc-bdVaJa hGXeaj"
|
|
24
24
|
>
|
|
25
25
|
<div
|
|
26
|
-
class="sc-htpNat sc-bxivhb
|
|
26
|
+
class="sc-htpNat sc-bxivhb kUcFdM"
|
|
27
27
|
>
|
|
28
28
|
<div>
|
|
29
29
|
Widget
|
package/src/index.ts
CHANGED
|
@@ -44,6 +44,9 @@ export {
|
|
|
44
44
|
export {
|
|
45
45
|
OptaFootballFixtures
|
|
46
46
|
} from './components/opta/football/fixtures/OptaFootballFixtures';
|
|
47
|
+
export {
|
|
48
|
+
OptaFootballFixturesTournament
|
|
49
|
+
} from './components/opta/football/fixtures-tournament/OptaFootballFixturesTournament';
|
|
47
50
|
export {
|
|
48
51
|
OptaFootballStandings
|
|
49
52
|
} from './components/opta/football/standings/OptaFootballStandings';
|
|
@@ -53,6 +56,9 @@ export {
|
|
|
53
56
|
export {
|
|
54
57
|
OptaFootballMatchStats
|
|
55
58
|
} from './components/opta/football/match-stats/OptaFootballMatchStats';
|
|
59
|
+
export {
|
|
60
|
+
OptaFootballPlayerStats
|
|
61
|
+
} from './components/opta/football/player-stats/OptaFootballPlayerStats';
|
|
56
62
|
|
|
57
63
|
export {
|
|
58
64
|
OptaRugbyFixtures
|