@times-components/ts-components 1.146.2-c9973aa4b92ab539c7e626ec928a64701390290d.3 → 1.147.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/matchday-live/DesktopWidget.d.ts +10 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.js +69 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.d.ts +12 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.js +90 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.d.ts +12 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.js +10 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.js +24 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.js +57 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.d.ts +2 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.js +48 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.js +19 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.d.ts +12 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.js +67 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.d.ts +6 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.js +736 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.js +33 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.js +36 -0
- package/dist/components/opta/football/opta-match-stats/shared/styles.js +8 -1
- package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.js +2 -2
- package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.js +1 -1
- package/dist/components/opta/football/opta-match-stats/summary/WidgetContainer.js +19 -5
- package/dist/components/social-embed/SocialVendor.d.ts +0 -3
- package/dist/components/social-embed/SocialVendor.js +2 -4
- package/dist/components/social-embed/__tests__/SocialVendor.test.js +1 -8
- package/dist/components/social-embed/constants.d.ts +0 -1
- package/dist/components/social-embed/constants.js +2 -3
- package/dist/components/social-embed/helpers/socialMediaVendors.js +1 -6
- package/dist/components/social-embed/styles.d.ts +0 -1
- package/dist/components/social-embed/styles.js +1 -28
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +16 -16
- package/rnw.js +1 -1
- package/src/components/opta/football/opta-match-stats/commentary/__tests__/__snapshots__/OptaMatchStatsCommentary.test.tsx.snap +1 -1
- package/src/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.tsx +108 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/MobileWidget.tsx +158 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.tsx +38 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.tsx +23 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.tsx +69 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.tsx +61 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/__snapshots__/OptaMatchStatsMatchdayLive.test.tsx.snap +61 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.tsx +19 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.tsx +81 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx +767 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.tsx +67 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.tsx +64 -0
- package/src/components/opta/football/opta-match-stats/shared/styles.ts +8 -0
- package/src/components/opta/football/opta-match-stats/stats-graphs/__tests__/__snapshots__/OptaMatchStatsGraphs.test.tsx.snap +1 -1
- package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.tsx +1 -1
- package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.tsx +1 -1
- package/src/components/opta/football/opta-match-stats/summary/WidgetContainer.tsx +18 -4
- package/src/components/opta/football/opta-match-stats/summary/__tests__/__snapshots__/OptaMatchStatsSummary.test.tsx.snap +1 -1
- package/src/components/social-embed/SocialVendor.tsx +1 -3
- package/src/components/social-embed/__tests__/SocialVendor.test.tsx +0 -11
- package/src/components/social-embed/constants.ts +1 -2
- package/src/components/social-embed/helpers/socialMediaVendors.ts +0 -5
- package/src/components/social-embed/styles.ts +0 -30
- package/src/index.ts +3 -0
- package/dist/components/social-embed/components/FacebookComponent.d.ts +0 -3
- package/dist/components/social-embed/components/FacebookComponent.js +0 -28
- package/src/components/social-embed/components/FacebookComponent.tsx +0 -38
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { NavigationWrapper } from '../NavigationWrapper';
|
|
5
|
+
|
|
6
|
+
const HomeColour = { light: '#123456', dark: '#abcdef' };
|
|
7
|
+
const AwayColour = { light: '#654321', dark: '#fedcba' };
|
|
8
|
+
|
|
9
|
+
describe('Matchday Live NavigationWrapper', () => {
|
|
10
|
+
it('renders with active home', () => {
|
|
11
|
+
const { container } = render(
|
|
12
|
+
<NavigationWrapper
|
|
13
|
+
isApp={false}
|
|
14
|
+
activeTeam="home"
|
|
15
|
+
homeTeamColor={HomeColour}
|
|
16
|
+
awayTeamColor={AwayColour}
|
|
17
|
+
>
|
|
18
|
+
<div className="navigation-buttons">
|
|
19
|
+
<button className="active home">Home</button>
|
|
20
|
+
<button className="away">Away</button>
|
|
21
|
+
</div>
|
|
22
|
+
<div className="home-widget-container">Home widget</div>
|
|
23
|
+
<div className="away-widget-container">Away widget</div>
|
|
24
|
+
</NavigationWrapper>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(container.querySelector('.navigation-buttons')).toBeInTheDocument();
|
|
28
|
+
expect(
|
|
29
|
+
container.querySelector('.navigation-buttons .active.home')
|
|
30
|
+
).toBeInTheDocument();
|
|
31
|
+
expect(
|
|
32
|
+
container.querySelector('.home-widget-container')
|
|
33
|
+
).toBeInTheDocument();
|
|
34
|
+
expect(
|
|
35
|
+
container.querySelector('.away-widget-container')
|
|
36
|
+
).toBeInTheDocument();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('renders with active away and isApp true', () => {
|
|
40
|
+
const { container } = render(
|
|
41
|
+
<NavigationWrapper
|
|
42
|
+
isApp={true}
|
|
43
|
+
activeTeam="away"
|
|
44
|
+
homeTeamColor={HomeColour}
|
|
45
|
+
awayTeamColor={AwayColour}
|
|
46
|
+
>
|
|
47
|
+
<div className="navigation-buttons">
|
|
48
|
+
<button className="home">Home</button>
|
|
49
|
+
<button className="active away">Away</button>
|
|
50
|
+
</div>
|
|
51
|
+
<div className="home-widget-container">Home widget</div>
|
|
52
|
+
<div className="away-widget-container">Away widget</div>
|
|
53
|
+
</NavigationWrapper>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(container.querySelector('.navigation-buttons')).toBeInTheDocument();
|
|
57
|
+
expect(
|
|
58
|
+
container.querySelector('.navigation-buttons .active.away')
|
|
59
|
+
).toBeInTheDocument();
|
|
60
|
+
expect(
|
|
61
|
+
container.querySelector('.home-widget-container')
|
|
62
|
+
).toBeInTheDocument();
|
|
63
|
+
expect(
|
|
64
|
+
container.querySelector('.away-widget-container')
|
|
65
|
+
).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { WidgetContainer } from '../WidgetContainer';
|
|
5
|
+
|
|
6
|
+
describe('Matchday Live WidgetContainer', () => {
|
|
7
|
+
const baseProps = {
|
|
8
|
+
isApp: true,
|
|
9
|
+
homeTeamColor: { light: '#000000', dark: '#a19c9cff' },
|
|
10
|
+
awayTeamColor: { light: '#007A3F', dark: '#007A3F' }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
it('generates styles', () => {
|
|
14
|
+
const { container } = render(
|
|
15
|
+
<WidgetContainer {...baseProps}>
|
|
16
|
+
<div className="Opta">
|
|
17
|
+
<div className="Opta_W">content</div>
|
|
18
|
+
</div>
|
|
19
|
+
</WidgetContainer>
|
|
20
|
+
);
|
|
21
|
+
expect(container.querySelector('.Opta > .Opta_W')).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('generates dark-mode styles under .Opta-Overlay .Opta-Flex', () => {
|
|
25
|
+
const { container } = render(
|
|
26
|
+
<WidgetContainer {...baseProps}>
|
|
27
|
+
<div className="Opta-Overlay">
|
|
28
|
+
<div className="Opta-Flex">flex</div>
|
|
29
|
+
</div>
|
|
30
|
+
</WidgetContainer>
|
|
31
|
+
);
|
|
32
|
+
expect(container.querySelector('.Opta-Overlay .Opta-Flex')).toBeTruthy();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('applies home-widget-container styles', () => {
|
|
36
|
+
const { container } = render(
|
|
37
|
+
<WidgetContainer {...baseProps} className="home-widget-container">
|
|
38
|
+
<div className="Opta-MatchHeader">
|
|
39
|
+
<div className="Opta-Away">Away Team</div>
|
|
40
|
+
</div>
|
|
41
|
+
</WidgetContainer>
|
|
42
|
+
);
|
|
43
|
+
expect(
|
|
44
|
+
container.querySelector(
|
|
45
|
+
'.home-widget-container .Opta-MatchHeader .Opta-Away'
|
|
46
|
+
)
|
|
47
|
+
).toBeTruthy();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('applies away-widget-container styles', () => {
|
|
51
|
+
const { container } = render(
|
|
52
|
+
<WidgetContainer {...baseProps} className="away-widget-container">
|
|
53
|
+
<div className="Opta-MatchHeader">
|
|
54
|
+
<div className="Opta-Home">Home Team</div>
|
|
55
|
+
</div>
|
|
56
|
+
</WidgetContainer>
|
|
57
|
+
);
|
|
58
|
+
expect(
|
|
59
|
+
container.querySelector(
|
|
60
|
+
'.away-widget-container .Opta-MatchHeader .Opta-Home'
|
|
61
|
+
)
|
|
62
|
+
).toBeTruthy();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -54,5 +54,13 @@ export const WidgetWrapper = styled.div<{
|
|
|
54
54
|
@media (max-width: ${maxMDBreakpoint}px) {
|
|
55
55
|
display: none;
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
${props =>
|
|
59
|
+
props.isApp &&
|
|
60
|
+
`
|
|
61
|
+
@media(prefers-color-scheme: dark) {
|
|
62
|
+
color: ${darkTextColor} !important;
|
|
63
|
+
}
|
|
64
|
+
`}
|
|
57
65
|
}
|
|
58
66
|
`;
|
|
@@ -94,9 +94,14 @@ export const WidgetContainer = styled.div<{
|
|
|
94
94
|
.Opta-Team {
|
|
95
95
|
flex: 1;
|
|
96
96
|
font-family: ${fonts.headline};
|
|
97
|
-
font-size:
|
|
97
|
+
font-size: 20px;
|
|
98
98
|
font-weight: 800;
|
|
99
99
|
color: ${textColor};
|
|
100
|
+
|
|
101
|
+
@media (min-width: ${1024}px) {
|
|
102
|
+
font-size: 24px;
|
|
103
|
+
}
|
|
104
|
+
|
|
100
105
|
${props =>
|
|
101
106
|
props.isApp &&
|
|
102
107
|
`
|
|
@@ -316,14 +321,23 @@ export const WidgetContainer = styled.div<{
|
|
|
316
321
|
display: flex;
|
|
317
322
|
text-align: right;
|
|
318
323
|
}
|
|
324
|
+
|
|
325
|
+
&.Opta-Home {
|
|
326
|
+
.Opta-Event-Player {
|
|
327
|
+
text-align: left;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
&.Opta-Away {
|
|
332
|
+
.Opta-Event-Player {
|
|
333
|
+
text-align: right;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
319
336
|
}
|
|
320
337
|
|
|
321
338
|
.Opta-Event-Text {
|
|
322
339
|
display: flex;
|
|
323
340
|
align-items: center;
|
|
324
|
-
.Opta-Event-Player {
|
|
325
|
-
text-align: left;
|
|
326
|
-
}
|
|
327
341
|
|
|
328
342
|
&.Opta-Home {
|
|
329
343
|
li {
|
|
@@ -3,14 +3,12 @@ import { Twitter } from './components/TwitterComponent';
|
|
|
3
3
|
import { Youtube } from './components/YoutubeComponent';
|
|
4
4
|
import { TikTok } from './components/TiktokComponent';
|
|
5
5
|
import { Instagram } from './components/InstagramComponent';
|
|
6
|
-
import { Facebook } from './components/FacebookComponent';
|
|
7
6
|
|
|
8
7
|
const vendors = {
|
|
9
8
|
twitter: Twitter,
|
|
10
9
|
youtube: Youtube,
|
|
11
10
|
tiktok: TikTok,
|
|
12
|
-
instagram: Instagram
|
|
13
|
-
facebook: Facebook
|
|
11
|
+
instagram: Instagram
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
export type VendorName = keyof typeof vendors;
|
|
@@ -29,12 +29,6 @@ jest.mock('../components/InstagramComponent', () => ({
|
|
|
29
29
|
))
|
|
30
30
|
}));
|
|
31
31
|
|
|
32
|
-
jest.mock('../components/FacebookComponent', () => ({
|
|
33
|
-
Facebook: jest.fn(() => (
|
|
34
|
-
<div data-testid="facebook-component">Facebook Component</div>
|
|
35
|
-
))
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
32
|
describe('Vendor Component', () => {
|
|
39
33
|
const renderVendor = (vendorName: VendorName, url: string) =>
|
|
40
34
|
render(<Vendor vendorName={vendorName} url={url} />);
|
|
@@ -62,11 +56,6 @@ describe('Vendor Component', () => {
|
|
|
62
56
|
expect(screen.getByTestId('instagram-component')).toBeInTheDocument();
|
|
63
57
|
});
|
|
64
58
|
|
|
65
|
-
it('renders the Facebook component when vendorName is "facebook"', () => {
|
|
66
|
-
renderVendor('facebook' as VendorName, 'https://facebook.com/some/video');
|
|
67
|
-
expect(screen.getByTestId('facebook-component')).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
59
|
it('throws an error if an invalid vendorName is provided', () => {
|
|
71
60
|
const renderInvalidVendor = () =>
|
|
72
61
|
render(
|
|
@@ -96,33 +96,3 @@ export const InstagramContainer = styled.blockquote`
|
|
|
96
96
|
width: calc(100% - 2px);
|
|
97
97
|
position: relative;
|
|
98
98
|
`;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
export const FacebookContainer = styled.div`
|
|
102
|
-
width: 100%;
|
|
103
|
-
max-width: 540px;
|
|
104
|
-
margin: 24px auto;
|
|
105
|
-
|
|
106
|
-
background: #ffffff;
|
|
107
|
-
border: 1px solid #dadde1;
|
|
108
|
-
border-radius: 8px;
|
|
109
|
-
|
|
110
|
-
min-height: 200px;
|
|
111
|
-
|
|
112
|
-
display: flex;
|
|
113
|
-
justify-content: center;
|
|
114
|
-
align-items: center;
|
|
115
|
-
|
|
116
|
-
iframe {
|
|
117
|
-
width: 100% !important;
|
|
118
|
-
border: none;
|
|
119
|
-
overflow: hidden;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
span,
|
|
123
|
-
.fb-post,
|
|
124
|
-
.fb-video {
|
|
125
|
-
width: 100% !important;
|
|
126
|
-
}
|
|
127
|
-
`;
|
|
128
|
-
|
package/src/index.ts
CHANGED
|
@@ -152,3 +152,6 @@ export {
|
|
|
152
152
|
export {
|
|
153
153
|
OptaMatchStatsCommentary
|
|
154
154
|
} from './components/opta/football/opta-match-stats/commentary/OptaMatchStatsCommentary';
|
|
155
|
+
export {
|
|
156
|
+
OptaMatchStatsMatchdayLive
|
|
157
|
+
} from './components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import { FacebookContainer } from '../styles';
|
|
3
|
-
import { Placeholder } from '@times-components/image';
|
|
4
|
-
export const Facebook = ({ url }) => {
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
if (!document.getElementById('fb-root')) {
|
|
7
|
-
const fbRoot = document.createElement('div');
|
|
8
|
-
fbRoot.id = 'fb-root';
|
|
9
|
-
document.body.appendChild(fbRoot);
|
|
10
|
-
}
|
|
11
|
-
// Load SDK only once
|
|
12
|
-
if (!window.FB) {
|
|
13
|
-
const script = document.createElement('script');
|
|
14
|
-
script.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v18.0';
|
|
15
|
-
script.async = true;
|
|
16
|
-
script.defer = true;
|
|
17
|
-
script.crossOrigin = 'anonymous';
|
|
18
|
-
document.body.appendChild(script);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
// If SDK already loaded, re-parse
|
|
22
|
-
window.FB.XFBML.parse();
|
|
23
|
-
}
|
|
24
|
-
}, []);
|
|
25
|
-
return (React.createElement(FacebookContainer, { className: "fb-post", "data-href": url, "data-width": "500", "data-show-text": "true" },
|
|
26
|
-
React.createElement(Placeholder, null)));
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRmFjZWJvb2tDb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY29tcG9uZW50cy9zb2NpYWwtZW1iZWQvY29tcG9uZW50cy9GYWNlYm9va0NvbXBvbmVudC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsRUFBRSxTQUFTLEVBQUUsTUFBTSxPQUFPLENBQUM7QUFDekMsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sV0FBVyxDQUFDO0FBQzlDLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUV0RCxNQUFNLENBQUMsTUFBTSxRQUFRLEdBQUcsQ0FBQyxFQUFFLEdBQUcsRUFBbUIsRUFBRSxFQUFFO0lBQ25ELFNBQVMsQ0FBQyxHQUFHLEVBQUU7UUFDYixJQUFJLENBQUMsUUFBUSxDQUFDLGNBQWMsQ0FBQyxTQUFTLENBQUMsRUFBRTtZQUN2QyxNQUFNLE1BQU0sR0FBRyxRQUFRLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQzdDLE1BQU0sQ0FBQyxFQUFFLEdBQUcsU0FBUyxDQUFDO1lBQ3RCLFFBQVEsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDO1NBQ25DO1FBRUQscUJBQXFCO1FBQ3JCLElBQUksQ0FBRSxNQUFjLENBQUMsRUFBRSxFQUFFO1lBQ3ZCLE1BQU0sTUFBTSxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUMsUUFBUSxDQUFDLENBQUM7WUFDaEQsTUFBTSxDQUFDLEdBQUcsR0FBRyxpRUFBaUUsQ0FBQztZQUMvRSxNQUFNLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQztZQUNwQixNQUFNLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQztZQUNwQixNQUFNLENBQUMsV0FBVyxHQUFHLFdBQVcsQ0FBQztZQUNqQyxRQUFRLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQztTQUNuQzthQUFNO1lBQ0wsa0NBQWtDO1lBQ2pDLE1BQWMsQ0FBQyxFQUFFLENBQUMsS0FBSyxDQUFDLEtBQUssRUFBRSxDQUFDO1NBQ2xDO0lBQ0gsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDO0lBRVAsT0FBTyxDQUNMLG9CQUFDLGlCQUFpQixJQUNoQixTQUFTLEVBQUMsU0FBUyxlQUNSLEdBQUcsZ0JBQ0gsS0FBSyxvQkFDRCxNQUFNO1FBRXJCLG9CQUFDLFdBQVcsT0FBRyxDQUNHLENBQ3JCLENBQUM7QUFDSixDQUFDLENBQUMifQ==
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import { FacebookContainer } from '../styles';
|
|
3
|
-
import { Placeholder } from '@times-components/image';
|
|
4
|
-
|
|
5
|
-
export const Facebook = ({ url }: { url: string }) => {
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (!document.getElementById('fb-root')) {
|
|
8
|
-
const fbRoot = document.createElement('div');
|
|
9
|
-
fbRoot.id = 'fb-root';
|
|
10
|
-
document.body.appendChild(fbRoot);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Load SDK only once
|
|
14
|
-
if (!(window as any).FB) {
|
|
15
|
-
const script = document.createElement('script');
|
|
16
|
-
script.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v18.0';
|
|
17
|
-
script.async = true;
|
|
18
|
-
script.defer = true;
|
|
19
|
-
script.crossOrigin = 'anonymous';
|
|
20
|
-
document.body.appendChild(script);
|
|
21
|
-
} else {
|
|
22
|
-
// If SDK already loaded, re-parse
|
|
23
|
-
(window as any).FB.XFBML.parse();
|
|
24
|
-
}
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<FacebookContainer
|
|
29
|
-
className="fb-post"
|
|
30
|
-
data-href={url}
|
|
31
|
-
data-width="500"
|
|
32
|
-
data-show-text="true"
|
|
33
|
-
>
|
|
34
|
-
<Placeholder />
|
|
35
|
-
</FacebookContainer>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|