@times-components/ts-components 1.144.1-d88954832f63cdbc40779d5cd4f06c4568affa14.22 → 1.145.1-ffc8fe2350c1f6194dbd798c9b12b0d865cd13fb.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 (60) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/components/opta/football/opta-match-stats/commentary/__tests__/OptaMatchStatsCommentary.test.js +36 -9
  3. package/dist/components/opta/football/opta-match-stats/shared/styles.js +33 -26
  4. package/dist/components/opta/football/opta-match-stats/stats-graphs/WidgetContainer.js +14 -1
  5. package/dist/components/opta/football/opta-match-stats/{matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.d.ts → stats-graphs/__tests__/WidgetContainer.test.d.ts} +0 -1
  6. package/dist/components/opta/football/opta-match-stats/stats-graphs/__tests__/WidgetContainer.test.js +57 -0
  7. package/dist/components/opta/football/opta-match-stats/summary/WidgetContainer.js +12 -4
  8. package/dist/components/opta/football/opta-match-stats/summary/__tests__/WidgetContainer.test.d.ts +1 -0
  9. package/dist/components/opta/football/opta-match-stats/summary/__tests__/WidgetContainer.test.js +70 -0
  10. package/dist/components/opta/shared/fixtures-ticker/OptaFixturesTicker.d.ts +1 -0
  11. package/dist/components/opta/shared/fixtures-ticker/OptaFixturesTicker.js +12 -3
  12. package/dist/components/opta/shared/fixtures-ticker/styles.d.ts +1 -0
  13. package/dist/components/opta/shared/fixtures-ticker/styles.js +8 -1
  14. package/dist/components/opta/utils/__tests__/useAddFixtureNavigation.test.d.ts +1 -0
  15. package/dist/components/opta/utils/__tests__/useAddFixtureNavigation.test.js +200 -0
  16. package/dist/components/opta/utils/useAddFixtureNavigation.d.ts +7 -0
  17. package/dist/components/opta/utils/useAddFixtureNavigation.js +77 -0
  18. package/dist/index.d.ts +0 -1
  19. package/dist/index.js +1 -2
  20. package/package.json +13 -12
  21. package/rnw.js +1 -1
  22. package/src/components/opta/football/opta-match-stats/commentary/__tests__/OptaMatchStatsCommentary.test.tsx +45 -10
  23. package/src/components/opta/football/opta-match-stats/commentary/__tests__/__snapshots__/OptaMatchStatsCommentary.test.tsx.snap +25 -10
  24. package/src/components/opta/football/opta-match-stats/shared/styles.ts +36 -28
  25. package/src/components/opta/football/opta-match-stats/stats-graphs/WidgetContainer.tsx +15 -0
  26. package/src/components/opta/football/opta-match-stats/stats-graphs/__tests__/WidgetContainer.test.tsx +117 -0
  27. package/src/components/opta/football/opta-match-stats/stats-graphs/__tests__/__snapshots__/OptaMatchStatsGraphs.test.tsx.snap +2 -2
  28. package/src/components/opta/football/opta-match-stats/summary/WidgetContainer.tsx +13 -3
  29. package/src/components/opta/football/opta-match-stats/summary/__tests__/WidgetContainer.test.tsx +125 -0
  30. package/src/components/opta/football/opta-match-stats/summary/__tests__/__snapshots__/OptaMatchStatsSummary.test.tsx.snap +1 -1
  31. package/src/components/opta/shared/fixtures-ticker/OptaFixturesTicker.tsx +19 -2
  32. package/src/components/opta/shared/fixtures-ticker/__tests__/__snapshots__/OptaFixturesTicker.test.tsx.snap +5 -5
  33. package/src/components/opta/shared/fixtures-ticker/styles.ts +9 -0
  34. package/src/components/opta/utils/__tests__/useAddFixtureNavigation.test.tsx +235 -0
  35. package/src/components/opta/utils/useAddFixtureNavigation.ts +101 -0
  36. package/src/index.ts +0 -3
  37. package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.d.ts +0 -10
  38. package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.js +0 -69
  39. package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.d.ts +0 -12
  40. package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.js +0 -90
  41. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.d.ts +0 -12
  42. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.js +0 -10
  43. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.d.ts +0 -1
  44. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.js +0 -24
  45. package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.js +0 -48
  46. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.d.ts +0 -1
  47. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.js +0 -19
  48. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.d.ts +0 -12
  49. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.js +0 -67
  50. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.d.ts +0 -6
  51. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.js +0 -714
  52. package/src/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.tsx +0 -108
  53. package/src/components/opta/football/opta-match-stats/matchday-live/MobileWidget.tsx +0 -158
  54. package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.tsx +0 -38
  55. package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.tsx +0 -23
  56. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.tsx +0 -61
  57. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/__snapshots__/OptaMatchStatsMatchdayLive.test.tsx.snap +0 -22
  58. package/src/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.tsx +0 -19
  59. package/src/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.tsx +0 -81
  60. package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx +0 -745
@@ -1,108 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import { Placeholder } from '@times-components/image';
3
- import {
4
- initSettings,
5
- initStyleSheet,
6
- initScript,
7
- initElement,
8
- initComponent
9
- } from '../../../utils/config';
10
- import { PlaceholderContainer } from '../../../shared/shared-styles';
11
- import { WidgetContainer } from './styles/WidgetContainer';
12
- import { WidgetWrapper } from '../shared/styles';
13
- import { TeamColor } from '../shared/types';
14
-
15
- export const DesktopWidget: React.FC<{
16
- season: string;
17
- competition: string;
18
- match: string;
19
- isApp?: boolean;
20
- homeTeamColor?: TeamColor;
21
- awayTeamColor?: TeamColor;
22
- }> = React.memo(
23
- ({
24
- season,
25
- competition,
26
- match,
27
- isApp = false,
28
- homeTeamColor = { light: '#000000', dark: '#a19c9cff' },
29
- awayTeamColor = { light: '#007A3F', dark: '#007A3F' }
30
- }) => {
31
- const ref = React.createRef<HTMLDivElement>();
32
- const [isReady, setIsReady] = useState<boolean>(false);
33
-
34
- useEffect(() => {
35
- const sport = 'football';
36
-
37
- initSettings();
38
- initStyleSheet(sport);
39
- initScript()
40
- .then(() => {
41
- if (ref.current) {
42
- ref.current.innerHTML = initElement('opta-widget', {
43
- sport,
44
- widget: 'matchday_live',
45
- season,
46
- competition,
47
- match,
48
- template: 'normal',
49
- live: true,
50
- orientation: 'horizontal',
51
- side: 'both',
52
- show_match_header: true,
53
- show_crests: true,
54
- show_pitch_crests: false,
55
- show_team_formation: true,
56
- show_score: false,
57
- show_halftime_score: false,
58
- show_competition_name: false,
59
- show_date: false,
60
- date_format: 'dddd D MMMM YYYY',
61
- narrow_date_format: 'DD/MM/YY',
62
- show_referee: true,
63
- show_venue: true,
64
- show_attendance: true,
65
- show_images: false,
66
- show_pitch_images: false,
67
- show_team_sheets: false,
68
- show_event_icons: true,
69
- show_player_names: true,
70
- show_player_stats: true,
71
- show_subs: 'all',
72
- competition_naming: 'brief',
73
- team_naming: 'full',
74
- player_naming: 'last_name',
75
- show_live: false,
76
- show_logo: false,
77
- show_title: false,
78
- breakpoints: '400, 700'
79
- }).outerHTML;
80
-
81
- initComponent();
82
- }
83
- })
84
- .then(() => {
85
- setIsReady(true);
86
- });
87
- }, []);
88
-
89
- return (
90
- <>
91
- <WidgetWrapper isApp={isApp} className="matchday-live-widget-desktop">
92
- <h3>Line-ups</h3>
93
- <WidgetContainer
94
- ref={ref}
95
- isApp={isApp}
96
- homeTeamColor={homeTeamColor}
97
- awayTeamColor={awayTeamColor}
98
- />
99
- </WidgetWrapper>
100
- {!isReady && (
101
- <PlaceholderContainer data-testid="placeholder">
102
- <Placeholder />
103
- </PlaceholderContainer>
104
- )}
105
- </>
106
- );
107
- }
108
- );
@@ -1,158 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import { Placeholder } from '@times-components/image';
3
- import {
4
- initSettings,
5
- initStyleSheet,
6
- initScript,
7
- initElement,
8
- initComponent
9
- } from '../../../utils/config';
10
- import { PlaceholderContainer } from '../../../shared/shared-styles';
11
- import { TeamColor } from '../shared/types';
12
- import { NavigationWrapper } from './styles/NavigationWrapper';
13
- import { WidgetContainer } from './styles/WidgetContainer';
14
-
15
- const widgetOptions = {
16
- widget: 'matchday_live',
17
- template: 'normal',
18
- live: true,
19
- orientation: 'vertical',
20
- show_match_header: true,
21
- show_crests: false,
22
- show_pitch_crests: false,
23
- show_team_formation: true,
24
- show_score: false,
25
- show_halftime_score: false,
26
- show_competition_name: false,
27
- show_date: false,
28
- date_format: 'dddd D MMMM YYYY',
29
- narrow_date_format: 'DD/MM/YY',
30
- show_referee: true,
31
- show_venue: false,
32
- show_attendance: false,
33
- show_images: false,
34
- show_pitch_images: false,
35
- show_team_sheets: false,
36
- show_event_icons: true,
37
- show_player_names: true,
38
- show_player_stats: true,
39
- show_subs: 'all',
40
- competition_naming: 'brief',
41
- team_naming: 'full',
42
- player_naming: 'last_name',
43
- show_live: false,
44
- show_logo: false,
45
- show_title: false
46
- };
47
-
48
- export const MobileWidget: React.FC<{
49
- season: string;
50
- competition: string;
51
- match: string;
52
- isApp?: boolean;
53
- homeTeamColor?: TeamColor;
54
- awayTeamColor?: TeamColor;
55
- homeTeamName: string;
56
- awayTeamName: string;
57
- }> = React.memo(
58
- ({
59
- season,
60
- competition,
61
- match,
62
- isApp = false,
63
- homeTeamColor = { light: '#000000', dark: '#a19c9cff' },
64
- awayTeamColor = { light: '#007A3F', dark: '#007A3F' },
65
- homeTeamName,
66
- awayTeamName
67
- }) => {
68
- const homeRef = React.createRef<HTMLDivElement>();
69
- const awayRef = React.createRef<HTMLDivElement>();
70
- const [isReady, setIsReady] = useState(false);
71
- const [activeTeam, setActiveTeam] = useState<'home' | 'away'>('home');
72
-
73
- useEffect(() => {
74
- const sport = 'football';
75
-
76
- initSettings();
77
- initStyleSheet(sport);
78
- initScript()
79
- .then(() => {
80
- if (homeRef.current) {
81
- homeRef.current.innerHTML = initElement('opta-widget', {
82
- ...widgetOptions,
83
- sport,
84
- season,
85
- competition,
86
- match,
87
- side: 'home'
88
- }).outerHTML;
89
- initComponent();
90
- }
91
- })
92
- .then(() => {
93
- if (awayRef.current) {
94
- awayRef.current.innerHTML = initElement('opta-widget', {
95
- ...widgetOptions,
96
- sport,
97
- season,
98
- competition,
99
- match,
100
- side: 'away'
101
- }).outerHTML;
102
- initComponent();
103
- }
104
- })
105
- .finally(() => {
106
- setIsReady(true);
107
- });
108
- }, []);
109
-
110
- return (
111
- <>
112
- <div className="matchday-live-widget-mobile">
113
- <NavigationWrapper
114
- data-testid="mobile-navigation-wrapper"
115
- activeTeam={activeTeam}
116
- homeTeamColor={homeTeamColor}
117
- awayTeamColor={awayTeamColor}
118
- isApp={isApp}
119
- >
120
- <div className="navigation-buttons">
121
- <button
122
- className={activeTeam === 'home' ? 'active home' : 'home'}
123
- onClick={() => setActiveTeam('home')}
124
- >
125
- {homeTeamName}
126
- </button>
127
- <button
128
- className={activeTeam === 'away' ? 'active away' : 'away'}
129
- onClick={() => setActiveTeam('away')}
130
- >
131
- {awayTeamName}
132
- </button>
133
- </div>
134
- <WidgetContainer
135
- className="home-widget-container"
136
- ref={homeRef}
137
- isApp={isApp}
138
- homeTeamColor={homeTeamColor}
139
- awayTeamColor={awayTeamColor}
140
- />
141
- <WidgetContainer
142
- className="away-widget-container"
143
- ref={awayRef}
144
- isApp={isApp}
145
- homeTeamColor={homeTeamColor}
146
- awayTeamColor={awayTeamColor}
147
- />
148
- {!isReady && (
149
- <PlaceholderContainer data-testid="placeholder">
150
- <Placeholder />
151
- </PlaceholderContainer>
152
- )}
153
- </NavigationWrapper>
154
- </div>
155
- </>
156
- );
157
- }
158
- );
@@ -1,38 +0,0 @@
1
- import React from 'react';
2
- import { showcaseConverter } from '@times-components/storybook';
3
-
4
- import { ArticleHarness } from '../../../../../fixtures/article-harness/ArticleHarness';
5
- import { OptaMatchStatsMatchdayLive } from './OptaMatchStatsMatchdayLive';
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
- return (
18
- <>
19
- <OptaMatchStatsMatchdayLive
20
- season="2025"
21
- competition="8"
22
- match="2562026"
23
- homeTeamName="Arsenal"
24
- awayTeamName="Brentford"
25
- />
26
- </>
27
- );
28
- },
29
- name: 'Summary',
30
- type: 'story'
31
- }
32
- ],
33
- name:
34
- 'Typescript Component/Opta Match Stats/Football/Match Stats Matchday Live'
35
- };
36
-
37
- // @ts-ignore
38
- showcaseConverter(module, showcase);
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import { TeamColor } from '../shared/types';
3
- import { DesktopWidget } from './DesktopWidget';
4
- import { MobileWidget } from './MobileWidget';
5
- import { MatchdayLiveController } from './styles/MatchdayLiveController';
6
-
7
- export const OptaMatchStatsMatchdayLive: React.FC<{
8
- season: string;
9
- competition: string;
10
- match: string;
11
- isApp?: boolean;
12
- homeTeamColor?: TeamColor;
13
- awayTeamColor?: TeamColor;
14
- homeTeamName: string;
15
- awayTeamName: string;
16
- }> = React.memo(props => {
17
- return (
18
- <MatchdayLiveController>
19
- <DesktopWidget {...props} />
20
- <MobileWidget {...props} />
21
- </MatchdayLiveController>
22
- );
23
- });
@@ -1,61 +0,0 @@
1
- import React from 'react';
2
- import { render, act } 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
- const mockHasMatchEvents = jest.fn();
15
-
16
- const mockInitElement = () => {
17
- const element = document.createElement('div');
18
- element.appendChild(document.createTextNode('Widget'));
19
- return element;
20
- };
21
-
22
- jest.mock('../../../../utils/config', () => ({
23
- initSettings: mockInitSettings,
24
- initStyleSheet: mockInitStyleSheet,
25
- initScript: () => new Promise(resolve => resolve({})),
26
- initElement: mockInitElement,
27
- initComponent: mockInitComponent
28
- }));
29
-
30
- import { OptaMatchStatsMatchdayLive } from '../OptaMatchStatsMatchdayLive';
31
-
32
- const requiredProps = {
33
- season: '2020',
34
- competition: '3',
35
- match: '2041900',
36
- homeTeamName: 'Liverpool',
37
- awayTeamName: 'Manchester City'
38
- };
39
-
40
- describe('OptaMatchStatsSummary', () => {
41
- beforeEach(() => {
42
- jest.clearAllMocks();
43
- });
44
-
45
- it('should render correctly', async () => {
46
- const { asFragment } = render(
47
- <OptaMatchStatsMatchdayLive {...requiredProps} />
48
- );
49
-
50
- act(() => {
51
- mockInitComponent();
52
- mockHasMatchEvents();
53
- });
54
-
55
- expect(mockInitSettings).toHaveBeenCalledTimes(1);
56
- expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
57
- expect(mockInitComponent).toHaveBeenCalledTimes(1);
58
-
59
- expect(asFragment()).toMatchSnapshot();
60
- });
61
- });
@@ -1,22 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`OptaMatchStatsSummary should render correctly 1`] = `
4
- <DocumentFragment>
5
- <div
6
- class="sc-bxivhb kxzVWs"
7
- >
8
- <h3>
9
- Match Stats
10
- </h3>
11
- <div
12
- class="sc-ifAKCX gaCiVe"
13
- />
14
- </div>
15
- <div
16
- class="sc-bwzfXH eSqyJ"
17
- data-testid="placeholder"
18
- >
19
- Placeholder
20
- </div>
21
- </DocumentFragment>
22
- `;
@@ -1,19 +0,0 @@
1
- import styled from 'styled-components';
2
- import { breakpoints } from '@times-components/ts-styleguide';
3
-
4
- export const MatchdayLiveController = styled.div`
5
- .matchday-live-widget-mobile {
6
- display: block;
7
- }
8
- .matchday-live-widget-desktop {
9
- display: none;
10
- }
11
- @media (min-width: ${breakpoints.medium}px) {
12
- .matchday-live-widget-mobile {
13
- display: none;
14
- }
15
- .matchday-live-widget-desktop {
16
- display: block;
17
- }
18
- }
19
- `;
@@ -1,81 +0,0 @@
1
- import styled from 'styled-components';
2
- import {
3
- backgroundColor,
4
- darkBackgroundColor,
5
- darkTextColor,
6
- textColor
7
- } from '../../shared/styles';
8
-
9
- export const NavigationWrapper = styled.div<{
10
- homeTeamColor: { light: string; dark: string };
11
- awayTeamColor: { light: string; dark: string };
12
- activeTeam: 'home' | 'away';
13
- isApp: boolean;
14
- }>`
15
- background-color: ${backgroundColor};
16
- ${props =>
17
- props.isApp &&
18
- `
19
- @media (prefers-color-scheme: dark) {
20
- background-color: ${darkBackgroundColor};
21
- }
22
- `} .navigation-buttons {
23
- display: grid;
24
- grid-template-columns: 1fr 1fr;
25
- button {
26
- -webkit-tap-highlight-color: transparent;
27
- background: none;
28
- border: none;
29
- font-family: Roboto, sans-serif;
30
- font-size: 16px;
31
- font-weight: 500;
32
- line-height: 150%;
33
- padding: 16px 8px;
34
- cursor: pointer;
35
- border-bottom: 2px solid ${backgroundColor};
36
- color: ${textColor};
37
-
38
- &.active {
39
- &.home {
40
- border-bottom: 2px solid ${props => props.homeTeamColor.light};
41
- color: ${props => props.homeTeamColor.light};
42
- }
43
- &.away {
44
- border-bottom: 2px solid ${props => props.awayTeamColor.light};
45
- color: ${props => props.awayTeamColor.light};
46
- }
47
- }
48
-
49
- ${props =>
50
- props.isApp &&
51
- `
52
- @media (prefers-color-scheme: dark) {
53
- border-bottom: 2px solid ${darkBackgroundColor};
54
- color: ${darkTextColor};
55
- &.active {
56
- &.home {
57
- border-bottom: 2px solid ${props.homeTeamColor.dark};
58
- color: ${props.homeTeamColor.dark};
59
- }
60
- &.away {
61
- border-bottom: 2px solid ${props.awayTeamColor.dark};
62
- color: ${props.awayTeamColor.dark};
63
- }
64
- }
65
- }
66
- `};
67
- }
68
- }
69
-
70
- .home-widget-container {
71
- visibility: ${props =>
72
- props.activeTeam === 'home' ? 'visible' : 'hidden'};
73
- height: ${props => (props.activeTeam === 'home' ? 'auto' : '0')};
74
- }
75
-
76
- .away-widget-container {
77
- visibility: ${props =>
78
- props.activeTeam === 'away' ? 'visible' : 'hidden'};
79
- height: ${props => (props.activeTeam === 'away' ? 'auto' : '0')};
80
- }
81
- `;