@times-components/ts-components 1.104.1-alpha.58 → 1.104.1-alpha.67
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 +41 -0
- package/dist/components/article-sidebar/ArticleSidebar.js +2 -2
- package/dist/components/article-sidebar/styles.js +3 -3
- package/dist/components/newsletter-puff/InlineNewsletterPuff.js +23 -25
- package/dist/components/newsletter-puff/NewsletterPuff.stories.js +2 -20
- package/dist/components/newsletter-puff/__tests__/AutoNewsletterPuff.test.js +2 -20
- package/dist/components/newsletter-puff/__tests__/InlineNewsletterPuff.test.js +24 -33
- package/dist/components/newsletter-puff/newsletter/Newsletter.d.ts +4 -5
- package/dist/components/newsletter-puff/newsletter/Newsletter.js +13 -10
- package/dist/components/recommended-articles/__tests__/formatters.test.js +4 -4
- package/dist/components/recommended-articles/formatters.d.ts +1 -0
- package/dist/components/recommended-articles/formatters.js +2 -2
- package/dist/components/social-embed/BlockedEmbedMessage.d.ts +8 -0
- package/dist/components/social-embed/BlockedEmbedMessage.js +32 -0
- package/dist/components/social-embed/SocialMediaEmbed.d.ts +10 -9
- package/dist/components/social-embed/SocialMediaEmbed.js +44 -42
- package/dist/components/social-embed/constants.d.ts +12 -0
- package/dist/components/social-embed/constants.js +13 -0
- package/dist/components/social-embed/helpers/__tests__/vendorConsent.test.d.ts +1 -0
- package/dist/components/social-embed/helpers/__tests__/vendorConsent.test.js +53 -0
- package/dist/components/social-embed/helpers/enableCookies.d.ts +1 -1
- package/dist/components/social-embed/helpers/enableCookies.js +3 -3
- package/dist/components/social-embed/helpers/privacyModal.d.ts +1 -4
- package/dist/components/social-embed/helpers/privacyModal.js +1 -6
- package/dist/components/social-embed/helpers/vendorConsent.d.ts +2 -1
- package/dist/components/social-embed/helpers/vendorConsent.js +3 -5
- package/dist/components/social-embed/types.d.ts +9 -0
- package/dist/components/social-embed/types.js +2 -0
- package/dist/fixtures/preview-data/recommended-articles.d.ts +3 -0
- package/dist/fixtures/preview-data/recommended-articles.js +11 -1
- package/package.json +4 -5
- package/rnw.js +1 -1
- package/src/components/article-sidebar/ArticleSidebar.tsx +1 -1
- package/src/components/article-sidebar/__tests__/__snapshots__/index.test.tsx.snap +5 -5
- package/src/components/article-sidebar/styles.ts +3 -3
- package/src/components/newsletter-puff/InlineNewsletterPuff.tsx +34 -46
- package/src/components/newsletter-puff/NewsletterPuff.stories.tsx +1 -22
- package/src/components/newsletter-puff/__tests__/AutoNewsletterPuff.test.tsx +1 -22
- package/src/components/newsletter-puff/__tests__/InlineNewsletterPuff.test.tsx +31 -40
- package/src/components/newsletter-puff/__tests__/__snapshots__/InlineNewsletterPuff.test.tsx.snap +18 -35
- package/src/components/newsletter-puff/newsletter/Newsletter.tsx +26 -26
- package/src/components/recommended-articles/__tests__/formatters.test.tsx +3 -5
- package/src/components/recommended-articles/formatters.ts +2 -1
- package/src/components/social-embed/BlockedEmbedMessage.tsx +67 -0
- package/src/components/social-embed/SocialMediaEmbed.tsx +71 -87
- package/src/components/social-embed/constants.ts +14 -0
- package/src/components/social-embed/helpers/__tests__/vendorConsent.test.ts +77 -0
- package/src/components/social-embed/helpers/enableCookies.ts +2 -5
- package/src/components/social-embed/helpers/privacyModal.ts +1 -5
- package/src/components/social-embed/helpers/vendorConsent.ts +5 -8
- package/src/components/social-embed/types.ts +13 -0
- package/src/fixtures/preview-data/recommended-articles.ts +19 -0
- package/src/types/externs.d.ts +1 -1
|
@@ -62,7 +62,7 @@ export const ArticleSidebar: FC<ArticleSideBarProps> = ({
|
|
|
62
62
|
}
|
|
63
63
|
className="trigger-card-link"
|
|
64
64
|
>
|
|
65
|
-
<PuzzleImage src={imgUrl} alt="Puzzle thumbnail" />
|
|
65
|
+
<PuzzleImage src={imgUrl} alt="Puzzle category thumbnail" />
|
|
66
66
|
<ItemTitle>{title}</ItemTitle>
|
|
67
67
|
</PuzzleContainer>
|
|
68
68
|
<Divider />
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
exports[`ArticleSidebar should render ArticleSidebar component 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="sc-bwzfXH
|
|
6
|
+
class="sc-bwzfXH gYmlvh"
|
|
7
7
|
>
|
|
8
8
|
<a
|
|
9
|
-
class="trigger sc-ifAKCX
|
|
9
|
+
class="trigger sc-ifAKCX YFVti"
|
|
10
10
|
href="https://www.thetimes.com/puzzles"
|
|
11
11
|
>
|
|
12
12
|
<div
|
|
@@ -18,7 +18,7 @@ exports[`ArticleSidebar should render ArticleSidebar component 1`] = `
|
|
|
18
18
|
Puzzles for you
|
|
19
19
|
</h3>
|
|
20
20
|
<button
|
|
21
|
-
class="sc-gzVnrw
|
|
21
|
+
class="sc-gzVnrw eoEpFe"
|
|
22
22
|
>
|
|
23
23
|
<svg
|
|
24
24
|
aria-hidden="true"
|
|
@@ -52,7 +52,7 @@ exports[`ArticleSidebar should render ArticleSidebar component 1`] = `
|
|
|
52
52
|
href="https://www.thetimes.com/puzzles/crossword"
|
|
53
53
|
>
|
|
54
54
|
<img
|
|
55
|
-
alt="Puzzle thumbnail"
|
|
55
|
+
alt="Puzzle category thumbnail"
|
|
56
56
|
class="sc-iwsKbI elYeaz"
|
|
57
57
|
src="https://www.thetimes.com/imageserver/image/%2Fpuzzles%2Ficons%2F33b27655-dcc9-421f-906f-b2b10dd26865.png?crop=1250%2C833%2C0%2C0&resize=500"
|
|
58
58
|
/>
|
|
@@ -70,7 +70,7 @@ exports[`ArticleSidebar should render ArticleSidebar component 1`] = `
|
|
|
70
70
|
href="https://www.thetimes.com/puzzles/sudoku"
|
|
71
71
|
>
|
|
72
72
|
<img
|
|
73
|
-
alt="Puzzle thumbnail"
|
|
73
|
+
alt="Puzzle category thumbnail"
|
|
74
74
|
class="sc-iwsKbI elYeaz"
|
|
75
75
|
src="https://www.thetimes.com/imageserver/image/%2Fpuzzles%2Ficons%2F33b27655-dcc9-421f-906f-b2b10dd26865.png?crop=1250%2C833%2C0%2C0&resize=500"
|
|
76
76
|
/>
|
|
@@ -11,7 +11,7 @@ export const Container = styled.div`
|
|
|
11
11
|
padding-top: 12px;
|
|
12
12
|
border-style: solid none none none;
|
|
13
13
|
border-width: 3px;
|
|
14
|
-
border-color: #
|
|
14
|
+
border-color: #c05729;
|
|
15
15
|
`;
|
|
16
16
|
|
|
17
17
|
export const Description = styled.p`
|
|
@@ -47,7 +47,7 @@ export const Link = styled.a`
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
h3 {
|
|
50
|
-
color: #
|
|
50
|
+
color: #c05729;
|
|
51
51
|
}
|
|
52
52
|
`;
|
|
53
53
|
|
|
@@ -68,7 +68,7 @@ export const Title = styled.h3`
|
|
|
68
68
|
|
|
69
69
|
export const ChevronButton = styled.button`
|
|
70
70
|
background-color: #eeeeee;
|
|
71
|
-
color: #
|
|
71
|
+
color: #c05729;
|
|
72
72
|
border-radius: 50%;
|
|
73
73
|
border: none;
|
|
74
74
|
cursor: pointer;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Mutation } from 'react-apollo';
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
3
2
|
|
|
4
3
|
import { GetNewsletter } from '@times-components/provider';
|
|
5
|
-
import { subscribeNewsletter as subscribeNewsletterMutation } from '@times-components/provider-queries';
|
|
6
4
|
import { Placeholder } from '@times-components/image';
|
|
7
5
|
import { capitalise } from '@times-components/utils';
|
|
8
6
|
|
|
@@ -11,6 +9,8 @@ import { Newsletter } from './newsletter/Newsletter';
|
|
|
11
9
|
import { TrackingContextProvider } from '../../helpers/tracking/TrackingContextProvider';
|
|
12
10
|
|
|
13
11
|
import { InpContainer } from './styles';
|
|
12
|
+
import { FetchProvider } from '../../helpers/fetch/FetchProvider';
|
|
13
|
+
import { ContentProvider } from '../save-star/ContentProvider';
|
|
14
14
|
|
|
15
15
|
type InlineNewsletterPuffProps = {
|
|
16
16
|
copy: string;
|
|
@@ -25,8 +25,10 @@ export const InlineNewsletterPuff = ({
|
|
|
25
25
|
headline,
|
|
26
26
|
section
|
|
27
27
|
}: InlineNewsletterPuffProps) => {
|
|
28
|
-
const [
|
|
29
|
-
|
|
28
|
+
const [url, setUrl] = useState<string>(
|
|
29
|
+
`/api/is-subscribed-newsletter/${code}`
|
|
30
|
+
);
|
|
31
|
+
const fetchOptions = useMemo(() => ({ credentials: 'same-origin' }), []);
|
|
30
32
|
|
|
31
33
|
return (
|
|
32
34
|
<GetNewsletter code={code} ssr={false} debounceTimeMs={0}>
|
|
@@ -43,58 +45,44 @@ export const InlineNewsletterPuff = ({
|
|
|
43
45
|
);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
if (newsletter.isSubscribed
|
|
48
|
+
if (newsletter.isSubscribed) {
|
|
47
49
|
return null;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
scrolledEvent={{
|
|
73
|
-
object: 'NewsletterPuffButton',
|
|
74
|
-
attrs: {
|
|
75
|
-
event_navigation_name:
|
|
76
|
-
'widget : puff : sign up now : displayed',
|
|
77
|
-
event_navigation_browsing_method: 'automated',
|
|
78
|
-
event_navigation_action: 'navigation'
|
|
79
|
-
}
|
|
80
|
-
}}
|
|
81
|
-
>
|
|
82
|
-
{({ intersectObserverRef }) => (
|
|
53
|
+
<FetchProvider url={url} options={fetchOptions}>
|
|
54
|
+
<TrackingContextProvider
|
|
55
|
+
context={{
|
|
56
|
+
object: 'InlineNewsletterPuff',
|
|
57
|
+
attrs: {
|
|
58
|
+
article_parent_name: newsletter.title,
|
|
59
|
+
event_navigation_action: 'navigation'
|
|
60
|
+
}
|
|
61
|
+
}}
|
|
62
|
+
scrolledEvent={{
|
|
63
|
+
object: 'NewsletterPuffButton',
|
|
64
|
+
attrs: {
|
|
65
|
+
event_navigation_name:
|
|
66
|
+
'widget : puff : sign up now : displayed',
|
|
67
|
+
event_navigation_browsing_method: 'automated',
|
|
68
|
+
event_navigation_action: 'navigation'
|
|
69
|
+
}
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
{({ intersectObserverRef }) => (
|
|
73
|
+
<ContentProvider>
|
|
83
74
|
<Newsletter
|
|
84
75
|
intersectObserverRef={intersectObserverRef}
|
|
85
76
|
section={capitalise(section)}
|
|
86
|
-
justSubscribed={justSubscribed}
|
|
87
|
-
justSubscribedError={justSubscribedError}
|
|
88
77
|
headline={headline}
|
|
89
|
-
updatingSubscription={updatingSubscription}
|
|
90
78
|
copy={copy}
|
|
91
79
|
code={code}
|
|
92
|
-
subscribeNewsletter={
|
|
80
|
+
subscribeNewsletter={setUrl}
|
|
93
81
|
/>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</
|
|
82
|
+
</ContentProvider>
|
|
83
|
+
)}
|
|
84
|
+
</TrackingContextProvider>
|
|
85
|
+
</FetchProvider>
|
|
98
86
|
);
|
|
99
87
|
}}
|
|
100
88
|
</GetNewsletter>
|
|
@@ -2,10 +2,7 @@ import { showcaseConverter } from '@times-components/storybook';
|
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { MockedProvider } from '@times-components/provider-test-tools';
|
|
5
|
-
import {
|
|
6
|
-
getNewsletter,
|
|
7
|
-
subscribeNewsletter
|
|
8
|
-
} from '@times-components/provider-queries';
|
|
5
|
+
import { getNewsletter } from '@times-components/provider-queries';
|
|
9
6
|
|
|
10
7
|
import { AutoNewsletterPuff } from './AutoNewsletterPuff';
|
|
11
8
|
import { InlineNewsletterPuff } from './InlineNewsletterPuff';
|
|
@@ -33,24 +30,6 @@ const mocks = [
|
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
delay: 1000,
|
|
39
|
-
request: {
|
|
40
|
-
query: subscribeNewsletter,
|
|
41
|
-
variables: {
|
|
42
|
-
code: 'TNL-101'
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
result: {
|
|
46
|
-
data: {
|
|
47
|
-
subscribeNewsletter: {
|
|
48
|
-
id: 'a2l6E000000CdHzQAK',
|
|
49
|
-
isSubscribed: true,
|
|
50
|
-
__typename: 'Newsletter'
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
33
|
}
|
|
55
34
|
];
|
|
56
35
|
|
|
@@ -5,10 +5,7 @@ import { cleanup, render } from '@testing-library/react';
|
|
|
5
5
|
import { AutoNewsletterPuff } from '../AutoNewsletterPuff';
|
|
6
6
|
import FakeIntersectionObserver from '../../../test-utils/FakeIntersectionObserver';
|
|
7
7
|
import { MockedProvider } from '@times-components/provider-test-tools';
|
|
8
|
-
import {
|
|
9
|
-
getNewsletter,
|
|
10
|
-
subscribeNewsletter
|
|
11
|
-
} from '@times-components/provider-queries';
|
|
8
|
+
import { getNewsletter } from '@times-components/provider-queries';
|
|
12
9
|
|
|
13
10
|
const defaultProps = {
|
|
14
11
|
code: '123',
|
|
@@ -35,24 +32,6 @@ const mocks = [
|
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
delay: 1000,
|
|
41
|
-
request: {
|
|
42
|
-
query: subscribeNewsletter,
|
|
43
|
-
variables: {
|
|
44
|
-
code: 'TNL-101'
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
result: {
|
|
48
|
-
data: {
|
|
49
|
-
subscribeNewsletter: {
|
|
50
|
-
id: 'a2l6E000000CdHzQAK',
|
|
51
|
-
isSubscribed: true,
|
|
52
|
-
__typename: 'Newsletter'
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
35
|
}
|
|
57
36
|
];
|
|
58
37
|
|
|
@@ -2,22 +2,25 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { delay } from '@times-components/test-utils';
|
|
4
4
|
|
|
5
|
-
import { render,
|
|
5
|
+
import { render, cleanup, fireEvent } from '@testing-library/react';
|
|
6
6
|
import '@testing-library/jest-dom';
|
|
7
7
|
|
|
8
8
|
import { MockedProvider } from '@times-components/provider-test-tools';
|
|
9
9
|
|
|
10
10
|
import mockDate from 'mockdate';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
getNewsletter,
|
|
14
|
-
subscribeNewsletter
|
|
15
|
-
} from '@times-components/provider-queries';
|
|
12
|
+
import { getNewsletter } from '@times-components/provider-queries';
|
|
16
13
|
import { InlineNewsletterPuff } from '../InlineNewsletterPuff';
|
|
17
14
|
import { TrackingContextProvider } from '../../../helpers/tracking/TrackingContextProvider';
|
|
15
|
+
import { useFetch } from '../../../helpers/fetch/FetchProvider';
|
|
18
16
|
|
|
19
17
|
import FakeIntersectionObserver from '../../../test-utils/FakeIntersectionObserver';
|
|
20
18
|
|
|
19
|
+
jest.mock('../../../helpers/fetch/FetchProvider', () => ({
|
|
20
|
+
...jest.requireActual('../../../helpers/fetch/FetchProvider'),
|
|
21
|
+
useFetch: jest.fn()
|
|
22
|
+
}));
|
|
23
|
+
|
|
21
24
|
const renderComponent = (
|
|
22
25
|
analyticsStream?: () => void,
|
|
23
26
|
mocks: any[] = [
|
|
@@ -38,25 +41,6 @@ const renderComponent = (
|
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
delay: 50,
|
|
44
|
-
request: {
|
|
45
|
-
query: subscribeNewsletter,
|
|
46
|
-
variables: {
|
|
47
|
-
code: 'TNL-119'
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
result: {
|
|
51
|
-
data: {
|
|
52
|
-
subscribeNewsletter: {
|
|
53
|
-
id: 'a2l6E000000CdHzQAK',
|
|
54
|
-
isSubscribed: true,
|
|
55
|
-
title: 'RED BOX',
|
|
56
|
-
__typename: 'Newsletter'
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
44
|
}
|
|
61
45
|
]
|
|
62
46
|
) =>
|
|
@@ -95,22 +79,6 @@ describe('Inline Newsletter Puff', () => {
|
|
|
95
79
|
expect(component.baseElement).toMatchSnapshot();
|
|
96
80
|
});
|
|
97
81
|
|
|
98
|
-
it('renders signup state', async () => {
|
|
99
|
-
const component = renderComponent();
|
|
100
|
-
await component.findAllByText('Sign up with one click');
|
|
101
|
-
expect(component.baseElement).toMatchSnapshot();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('renders loading state state', async () => {
|
|
105
|
-
const component = renderComponent();
|
|
106
|
-
const oneClickSignUp = await component.findAllByText(
|
|
107
|
-
'Sign up with one click'
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
fireEvent.click(oneClickSignUp[0]);
|
|
111
|
-
expect(component.baseElement).toMatchSnapshot();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
82
|
it('renders null when is already subscribed', async () => {
|
|
115
83
|
const component = renderComponent(jest.fn(), [
|
|
116
84
|
{
|
|
@@ -137,6 +105,26 @@ describe('Inline Newsletter Puff', () => {
|
|
|
137
105
|
expect(component.baseElement).toMatchSnapshot();
|
|
138
106
|
});
|
|
139
107
|
|
|
108
|
+
it('renders signup state', async () => {
|
|
109
|
+
(useFetch as jest.Mock).mockReturnValue({ data: { isSubscribed: false } });
|
|
110
|
+
|
|
111
|
+
const component = renderComponent();
|
|
112
|
+
await component.findAllByText('Sign up with one click');
|
|
113
|
+
expect(component.baseElement).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('renders loading state state', async () => {
|
|
117
|
+
(useFetch as jest.Mock).mockReturnValue({ data: { isSubscribed: false } });
|
|
118
|
+
|
|
119
|
+
const component = renderComponent();
|
|
120
|
+
const oneClickSignUp = await component.findAllByText(
|
|
121
|
+
'Sign up with one click'
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
fireEvent.click(oneClickSignUp[0]);
|
|
125
|
+
expect(component.baseElement).toMatchSnapshot();
|
|
126
|
+
});
|
|
127
|
+
|
|
140
128
|
it('renders signup view when not already subscribed', async () => {
|
|
141
129
|
const component = renderComponent();
|
|
142
130
|
|
|
@@ -159,6 +147,9 @@ describe('Inline Newsletter Puff', () => {
|
|
|
159
147
|
|
|
160
148
|
it('Sign up with one click : displayed', async () => {
|
|
161
149
|
const analyticsStream = jest.fn();
|
|
150
|
+
(useFetch as jest.Mock).mockReturnValue({
|
|
151
|
+
data: { isSubscribed: false }
|
|
152
|
+
});
|
|
162
153
|
const component = renderComponent(analyticsStream);
|
|
163
154
|
|
|
164
155
|
await component.findAllByText('Sign up with one click');
|
package/src/components/newsletter-puff/__tests__/__snapshots__/InlineNewsletterPuff.test.tsx.snap
CHANGED
|
@@ -7,54 +7,37 @@ exports[`Inline Newsletter Puff renders loading state state 1`] = `
|
|
|
7
7
|
class="sc-htpNat sc-ifAKCX iWYiTB"
|
|
8
8
|
>
|
|
9
9
|
<div
|
|
10
|
-
class="sc-htpNat sc-
|
|
11
|
-
>
|
|
12
|
-
<div
|
|
13
|
-
class="sc-htpNat sc-htoDjs bnLiNW"
|
|
14
|
-
>
|
|
15
|
-
<div
|
|
16
|
-
class="sc-gzVnrw TDlzj"
|
|
17
|
-
/>
|
|
18
|
-
<div
|
|
19
|
-
class="sc-gzVnrw TDlzj"
|
|
20
|
-
/>
|
|
21
|
-
<div
|
|
22
|
-
class="sc-gzVnrw TDlzj"
|
|
23
|
-
/>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
<div
|
|
27
|
-
class="sc-htpNat sc-iwsKbI cuimXU"
|
|
10
|
+
class="sc-htpNat sc-dnqmqq duLROv"
|
|
28
11
|
>
|
|
29
12
|
<div
|
|
30
13
|
class="sc-bxivhb sc-gqjmRU kcwRFH"
|
|
31
14
|
>
|
|
15
|
+
You've succesfully signed up to
|
|
16
|
+
|
|
32
17
|
<div
|
|
33
18
|
class="sc-bxivhb sc-gZMcBi bklePC"
|
|
34
19
|
>
|
|
35
|
-
Politics. Explained
|
|
20
|
+
Politics. Explained..
|
|
36
21
|
|
|
37
22
|
</div>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
<a
|
|
24
|
+
class="link__RespLink-sc-1ocvixa-0 dfMuic"
|
|
25
|
+
href="https://home.thetimes.co.uk/myNews"
|
|
41
26
|
>
|
|
42
|
-
<
|
|
43
|
-
class="sc-
|
|
27
|
+
<div
|
|
28
|
+
class="hover-icon__HoverIcon-sc-1ge5rtz-0 jJVcIr"
|
|
44
29
|
>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
<div
|
|
31
|
+
class="sc-bxivhb sc-EHOje jzxwzj"
|
|
32
|
+
>
|
|
33
|
+
Explore our newsletters
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</a>
|
|
48
37
|
</div>
|
|
49
38
|
<div
|
|
50
|
-
class="sc-htpNat sc-
|
|
51
|
-
|
|
52
|
-
<button
|
|
53
|
-
class="sc-bdVaJa knKdEu"
|
|
54
|
-
>
|
|
55
|
-
Sign up with one click
|
|
56
|
-
</button>
|
|
57
|
-
</div>
|
|
39
|
+
class="sc-htpNat sc-jTzLTM gzkEml"
|
|
40
|
+
/>
|
|
58
41
|
</div>
|
|
59
42
|
</div>
|
|
60
43
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { NewsletterPuffButton } from '../newsletter-puff-button/NewsletterPuffButton';
|
|
4
4
|
import { NewsletterPuffLink } from '../newsletter-puff-link/NewsletterPuffLink';
|
|
@@ -18,55 +18,55 @@ import { InpContainer } from '../styles';
|
|
|
18
18
|
type NewsletterProps = {
|
|
19
19
|
intersectObserverRef: (ref: HTMLElement | null) => void;
|
|
20
20
|
section?: string;
|
|
21
|
-
justSubscribed: boolean;
|
|
22
|
-
justSubscribedError: boolean;
|
|
23
21
|
headline: string;
|
|
24
|
-
updatingSubscription: boolean;
|
|
25
22
|
copy: string;
|
|
26
23
|
code: string;
|
|
27
|
-
subscribeNewsletter:
|
|
24
|
+
subscribeNewsletter: any;
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
error?: string;
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
export const Newsletter = ({
|
|
31
30
|
intersectObserverRef,
|
|
32
31
|
section,
|
|
33
|
-
justSubscribed,
|
|
34
|
-
justSubscribedError,
|
|
35
32
|
headline,
|
|
36
|
-
updatingSubscription,
|
|
37
33
|
copy,
|
|
38
34
|
code,
|
|
39
|
-
subscribeNewsletter
|
|
35
|
+
subscribeNewsletter,
|
|
36
|
+
loading,
|
|
37
|
+
error
|
|
40
38
|
}: NewsletterProps) => {
|
|
39
|
+
const [justSubscribed, setJustSubscribed] = useState(false);
|
|
41
40
|
const PuffButton = (style: 'link' | 'button') => (
|
|
42
41
|
<InpSignupCTAContainer ref={intersectObserverRef} childStyle={style}>
|
|
43
42
|
<NewsletterPuffButton
|
|
44
43
|
style={style}
|
|
45
|
-
updatingSubscription={
|
|
44
|
+
updatingSubscription={loading}
|
|
46
45
|
onPress={() => {
|
|
47
|
-
if (!
|
|
48
|
-
|
|
46
|
+
if (!loading) {
|
|
47
|
+
setJustSubscribed(true);
|
|
48
|
+
subscribeNewsletter(`/api/subscribe-newsletter/${code}`);
|
|
49
49
|
}
|
|
50
50
|
}}
|
|
51
51
|
/>
|
|
52
52
|
</InpSignupCTAContainer>
|
|
53
53
|
);
|
|
54
|
-
|
|
55
54
|
return (
|
|
56
55
|
<React.Fragment>
|
|
57
56
|
<InpContainer section={section}>
|
|
58
|
-
{
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
{loading && <LoadingOverlay />}
|
|
58
|
+
{!error &&
|
|
59
|
+
justSubscribed && (
|
|
60
|
+
<InpSubscribedContainer>
|
|
61
|
+
<InpCopy>
|
|
62
|
+
You've succesfully signed up to{' '}
|
|
63
|
+
<InpSignupHeadline>{`${headline}.`} </InpSignupHeadline>
|
|
64
|
+
<NewsletterPuffLink />
|
|
65
|
+
</InpCopy>
|
|
66
|
+
<InpPreferencesContainer />
|
|
67
|
+
</InpSubscribedContainer>
|
|
68
|
+
)}
|
|
69
|
+
{error && (
|
|
70
70
|
<InpSubscribedContainer>
|
|
71
71
|
<InpCopy>
|
|
72
72
|
An error occurred. Please use the link below.
|
|
@@ -76,7 +76,7 @@ export const Newsletter = ({
|
|
|
76
76
|
</InpSubscribedContainer>
|
|
77
77
|
)}
|
|
78
78
|
{!justSubscribed &&
|
|
79
|
-
!
|
|
79
|
+
!error && (
|
|
80
80
|
<InpSignupContainer>
|
|
81
81
|
<InpCopy>
|
|
82
82
|
<InpSignupHeadline>{headline} </InpSignupHeadline>
|
|
@@ -23,7 +23,7 @@ const expectedArticles = [
|
|
|
23
23
|
summary:
|
|
24
24
|
'How is your bank balance? Even if the cost of living crisis doesn’t constitute a crisis for you, you’ll have noticed that you’re suddenly paying more for and what felt reasonable may now...',
|
|
25
25
|
url:
|
|
26
|
-
'
|
|
26
|
+
'l1/l2/article/save-or-splurge-what-experts-spend-their-own-money-on-tdd65qlj6'
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
byline: '',
|
|
@@ -42,8 +42,7 @@ const expectedArticles = [
|
|
|
42
42
|
label: 'Obituary',
|
|
43
43
|
summary:
|
|
44
44
|
'On August 1, 1981, Major Ian Crooke, the operations officer of 22 Special Air Service in Hereford, received a telephone call from London. A Marxist coup d’état was taking place in the former British...',
|
|
45
|
-
url:
|
|
46
|
-
'https://www.thetimes.co.uk/article/lieutenant-colonel-ian-crooke-obituary-t0b890wgp'
|
|
45
|
+
url: 'l1/l2/article/lieutenant-colonel-ian-crooke-obituary-t0b890wgp'
|
|
47
46
|
},
|
|
48
47
|
{
|
|
49
48
|
byline: 'Patrick Maguire',
|
|
@@ -62,8 +61,7 @@ const expectedArticles = [
|
|
|
62
61
|
label: 'RED BOX | PATRICK MAGUIRE',
|
|
63
62
|
summary:
|
|
64
63
|
'Worse than May. Worse than Major. As bad as Thatcher. of his own MPs, far more than even the most pessimistic whip predicted this time yesterday. Can Boris...',
|
|
65
|
-
url:
|
|
66
|
-
'https://www.thetimes.co.uk/article/is-the-party-over-for-boris-johnson-k8s0jxv6r'
|
|
64
|
+
url: 'l1/l2/article/is-the-party-over-for-boris-johnson-k8s0jxv6r'
|
|
67
65
|
}
|
|
68
66
|
];
|
|
69
67
|
|
|
@@ -31,6 +31,7 @@ type Article = {
|
|
|
31
31
|
bylines?: Byline[];
|
|
32
32
|
summary?: Summary;
|
|
33
33
|
media?: Media;
|
|
34
|
+
categoryPath: string;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
// HELPERS
|
|
@@ -66,7 +67,7 @@ const getImage = (media?: Media) => {
|
|
|
66
67
|
|
|
67
68
|
const formatArticle = (article: Article): SliceArticle => {
|
|
68
69
|
return {
|
|
69
|
-
url: article.
|
|
70
|
+
url: article.categoryPath,
|
|
70
71
|
label: article.label,
|
|
71
72
|
byline: getBylines(article.bylines),
|
|
72
73
|
headline: article.headline,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { FC, MouseEvent, Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AllowButton,
|
|
4
|
+
CardContainer,
|
|
5
|
+
CustomIconContainer,
|
|
6
|
+
EnableButton,
|
|
7
|
+
Header,
|
|
8
|
+
LinkPrivacyManager,
|
|
9
|
+
Paragraph,
|
|
10
|
+
Title
|
|
11
|
+
} from './styles';
|
|
12
|
+
import { InfoIcon } from '../inline-message/InfoIcon';
|
|
13
|
+
import { getVendorTitle } from './helpers/getVendorTitle';
|
|
14
|
+
import { enableCookies } from './helpers/enableCookies';
|
|
15
|
+
import { openPrivacyModal } from './helpers/privacyModal';
|
|
16
|
+
import { socialMediaVendors } from './helpers/socialMediaVendors';
|
|
17
|
+
import { VendorName } from './types';
|
|
18
|
+
import { modalType } from './constants';
|
|
19
|
+
|
|
20
|
+
type BlockedEmbedMessageProps = {
|
|
21
|
+
vendorName: VendorName;
|
|
22
|
+
setIsSocialEmbedAllowed: Dispatch<SetStateAction<boolean>>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const BlockedEmbedMessage: FC<BlockedEmbedMessageProps> = ({
|
|
26
|
+
vendorName,
|
|
27
|
+
setIsSocialEmbedAllowed
|
|
28
|
+
}) => {
|
|
29
|
+
const allowCookiesOnce = () => {
|
|
30
|
+
enableCookies(vendorName);
|
|
31
|
+
setIsSocialEmbedAllowed(true);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const handlePrivacyManagerClick = (e: MouseEvent<HTMLAnchorElement>) => {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
openPrivacyModal(
|
|
37
|
+
modalType.GDPR,
|
|
38
|
+
window.__TIMES_CONFIG__.sourcepoint.gdprMessageId
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<CardContainer>
|
|
44
|
+
<Header>
|
|
45
|
+
<CustomIconContainer>
|
|
46
|
+
<InfoIcon />
|
|
47
|
+
</CustomIconContainer>
|
|
48
|
+
<Title>
|
|
49
|
+
{getVendorTitle(vendorName, socialMediaVendors)} content blocked
|
|
50
|
+
</Title>
|
|
51
|
+
</Header>
|
|
52
|
+
<Paragraph>
|
|
53
|
+
Please enable cookies and other technologies to view this content. You
|
|
54
|
+
can update your cookies preferences any time using{' '}
|
|
55
|
+
<LinkPrivacyManager href="#" onClick={handlePrivacyManagerClick}>
|
|
56
|
+
privacy manager.
|
|
57
|
+
</LinkPrivacyManager>
|
|
58
|
+
</Paragraph>
|
|
59
|
+
<EnableButton onClick={() => enableCookies(vendorName)}>
|
|
60
|
+
Enable cookies
|
|
61
|
+
</EnableButton>
|
|
62
|
+
<AllowButton onClick={() => allowCookiesOnce()}>
|
|
63
|
+
Allow cookies once
|
|
64
|
+
</AllowButton>
|
|
65
|
+
</CardContainer>
|
|
66
|
+
);
|
|
67
|
+
};
|