@times-components/ts-components 1.44.0 → 1.45.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.
@@ -43,16 +43,16 @@ exports[`<LatestFromSection> renders 1`] = `
43
43
  </h3>
44
44
  </div>
45
45
  <div
46
- class="config__Base-bs1997-0 config__Base-bs1997-2 ETkHz config__Base-bs1997-0 config__Base-bs1997-2 ETkHz css-view-1dbjc4n"
46
+ class="tc-view__TcView-nuazoi-0 config__Base-bs1997-0 config__Base-bs1997-2 gpmFGs"
47
47
  >
48
48
  <div
49
- class="responsive__SliceContainer-sc-1kirgpc-0 ioiqOj responsive__SliceContainer-sc-1kirgpc-0 ioiqOj css-view-1dbjc4n"
49
+ class="tc-view__TcView-nuazoi-0 responsive__SliceContainer-sc-1kirgpc-0 dOGrmV"
50
50
  >
51
51
  <div
52
- class="responsive__Base-sc-1lqbq6a-1 responsive__Base-sc-1lqbq6a-2 responsive__Base-sc-1lqbq6a-4 gpRihd responsive__Base-sc-1lqbq6a-1 responsive__Base-sc-1lqbq6a-2 responsive__Base-sc-1lqbq6a-4 gpRihd css-view-1dbjc4n"
52
+ class="tc-view__TcView-nuazoi-0 responsive__Base-sc-1lqbq6a-1 responsive__Base-sc-1lqbq6a-2 responsive__Base-sc-1lqbq6a-4 fwcUxi"
53
53
  >
54
54
  <div
55
- class="responsive__ChildContainer-sc-1lqbq6a-0 hdJTrx responsive__ChildContainer-sc-1lqbq6a-0 hdJTrx css-view-1dbjc4n"
55
+ class="tc-view__TcView-nuazoi-0 responsive__ChildContainer-sc-1lqbq6a-0 wGIJh"
56
56
  >
57
57
  <div
58
58
  data-testid="related-article-item"
@@ -195,10 +195,10 @@ exports[`<LatestFromSection> renders 1`] = `
195
195
  </div>
196
196
  </div>
197
197
  <div
198
- class="responsive-sc-1kirgpc-1 fAXubH responsive-sc-1kirgpc-1 fAXubH css-view-1dbjc4n"
198
+ class="tc-view__TcView-nuazoi-0 responsive-sc-1kirgpc-1 kpLnTa"
199
199
  />
200
200
  <div
201
- class="responsive__ChildContainer-sc-1lqbq6a-0 hdJTrx responsive__ChildContainer-sc-1lqbq6a-0 hdJTrx css-view-1dbjc4n"
201
+ class="tc-view__TcView-nuazoi-0 responsive__ChildContainer-sc-1lqbq6a-0 wGIJh"
202
202
  >
203
203
  <div
204
204
  data-testid="related-article-item"
@@ -341,10 +341,10 @@ exports[`<LatestFromSection> renders 1`] = `
341
341
  </div>
342
342
  </div>
343
343
  <div
344
- class="responsive-sc-1kirgpc-1 fAXubH responsive-sc-1kirgpc-1 fAXubH css-view-1dbjc4n"
344
+ class="tc-view__TcView-nuazoi-0 responsive-sc-1kirgpc-1 kpLnTa"
345
345
  />
346
346
  <div
347
- class="responsive__ChildContainer-sc-1lqbq6a-0 hdJTrx responsive__ChildContainer-sc-1lqbq6a-0 hdJTrx css-view-1dbjc4n"
347
+ class="tc-view__TcView-nuazoi-0 responsive__ChildContainer-sc-1lqbq6a-0 wGIJh"
348
348
  >
349
349
  <div
350
350
  data-testid="related-article-item"
@@ -1,60 +1,48 @@
1
1
  import React from 'react';
2
-
3
- import { showcaseConverter } from '@times-components/storybook';
2
+ import { storiesOf } from '@storybook/react';
4
3
 
5
4
  import { getArticles } from './helpers';
6
5
  import { FetchProvider } from '../../helpers/fetch/FetchProvider';
6
+ import { TrackingContextProvider } from '../../helpers/tracking/TrackingContextProvider';
7
7
  import previewData from '../../fixtures/preview-data/recommended-articles';
8
8
  import analyticsStream from '../../fixtures/analytics-actions/analytics-actions';
9
9
 
10
10
  import { RecommendedArticles } from './RecommendedArticles';
11
11
 
12
- const recommArticles = {
13
- children: [
14
- {
15
- component: () => (
16
- <FetchProvider previewData={getArticles(previewData, 1)}>
17
- <RecommendedArticles
18
- heading="Today's news"
19
- isVisible
20
- analyticsStream={analyticsStream}
21
- />
22
- </FetchProvider>
23
- ),
24
- name: 'Recommended Articles - 1 Article',
25
- platform: 'web',
26
- type: 'story'
27
- },
28
- {
29
- component: () => (
30
- <FetchProvider previewData={getArticles(previewData, 2)}>
31
- <RecommendedArticles
32
- heading="Today's business"
33
- isVisible
34
- analyticsStream={analyticsStream}
35
- />
36
- </FetchProvider>
37
- ),
38
- name: 'Recommended Articles - 2 Article',
39
- platform: 'web',
40
- type: 'story'
41
- },
42
- {
43
- component: () => (
44
- <FetchProvider previewData={previewData}>
45
- <RecommendedArticles
46
- heading="Today's sport"
47
- isVisible
48
- analyticsStream={analyticsStream}
49
- />
50
- </FetchProvider>
51
- ),
52
- name: 'Recommended Articles - 3 Article',
53
- platform: 'web',
54
- type: 'story'
55
- }
56
- ],
57
- name: 'Typescript Component/Recommended Articles'
58
- };
59
-
60
- showcaseConverter(module, recommArticles);
12
+ storiesOf('Typescript Component/Recommended Articles', module)
13
+ .addDecorator((storyFn: () => React.ReactNode) => (
14
+ <TrackingContextProvider
15
+ context={{
16
+ component: 'ArticleSkeleton',
17
+ object: 'RecommendedArticles',
18
+ attrs: {
19
+ event_navigation_action: 'navigation',
20
+ event_navigation_name: 'widget : relevant article',
21
+ event_navigation_browsing_method: 'click',
22
+ section_details: 'section : <section>',
23
+ article_name: '<headline>',
24
+ widget_headline: '<headline>',
25
+ widget_section: '<section>',
26
+ widget_type: "today's section"
27
+ }
28
+ }}
29
+ analyticsStream={analyticsStream}
30
+ >
31
+ <div>{storyFn()}</div>
32
+ </TrackingContextProvider>
33
+ ))
34
+ .add('Recommended Articles - 1 Article', () => (
35
+ <FetchProvider previewData={getArticles(previewData, 1)}>
36
+ <RecommendedArticles heading="Today's news" isVisible />
37
+ </FetchProvider>
38
+ ))
39
+ .add('Recommended Articles - 2 Article', () => (
40
+ <FetchProvider previewData={getArticles(previewData, 2)}>
41
+ <RecommendedArticles heading="Today's business" isVisible />
42
+ </FetchProvider>
43
+ ))
44
+ .add('Recommended Articles - 3 Article', () => (
45
+ <FetchProvider previewData={previewData}>
46
+ <RecommendedArticles heading="Today's sport" isVisible />
47
+ </FetchProvider>
48
+ ));
@@ -9,8 +9,7 @@ import { getRelatedArticlesSlice } from './formatters';
9
9
  export const RecommendedArticles: React.FC<{
10
10
  heading: string;
11
11
  isVisible?: boolean;
12
- analyticsStream?: (evt: any) => void;
13
- }> = ({ heading, isVisible, analyticsStream }) => {
12
+ }> = ({ heading, isVisible }) => {
14
13
  const { loading, error, data } = useFetch<any>();
15
14
 
16
15
  if (loading || error || data === undefined) {
@@ -29,7 +28,6 @@ export const RecommendedArticles: React.FC<{
29
28
  if (fireAnalyticsEvent) {
30
29
  fireAnalyticsEvent({
31
30
  action: 'Clicked',
32
- object: 'RecommendedArticles',
33
31
  attrs: { article_parent_name: found ? found.article.headline : '' }
34
32
  });
35
33
  }
@@ -45,7 +43,8 @@ export const RecommendedArticles: React.FC<{
45
43
  slice={slice}
46
44
  isVisible
47
45
  onPress={onClickHandler}
48
- analyticsStream={analyticsStream}
46
+ // tslint:disable-next-line: no-empty
47
+ analyticsStream={() => {}}
49
48
  />
50
49
  </div>
51
50
  );
@@ -9,14 +9,7 @@ export const RecommendedFetch: React.FC<{
9
9
  articleHeadline: string;
10
10
  articleSection: string;
11
11
  isVisible?: boolean;
12
- analyticsStream?: (evt: any) => void;
13
- }> = ({
14
- articleId,
15
- articleHeadline,
16
- articleSection,
17
- isVisible,
18
- analyticsStream
19
- }) => {
12
+ }> = ({ articleId, articleHeadline, articleSection, isVisible }) => {
20
13
  const [isClientSide, setIsClientSide] = useState<boolean>(false);
21
14
 
22
15
  useEffect(() => {
@@ -44,11 +37,7 @@ export const RecommendedFetch: React.FC<{
44
37
  }
45
38
  }}
46
39
  >
47
- <RecommendedArticles
48
- heading={heading}
49
- isVisible={isVisible}
50
- analyticsStream={analyticsStream}
51
- />
40
+ <RecommendedArticles heading={heading} isVisible={isVisible} />
52
41
  </TrackingContextProvider>
53
42
  </FetchProvider>
54
43
  ) : null;
@@ -63,9 +63,7 @@ describe('<RecommendedArticles>', () => {
63
63
  it('should render the initial loading state correctly', () => {
64
64
  (useFetch as jest.Mock).mockReturnValue({ loading: true });
65
65
 
66
- const { asFragment } = render(
67
- <RecommendedArticles heading={heading} analyticsStream={() => ({})} />
68
- );
66
+ const { asFragment } = render(<RecommendedArticles heading={heading} />);
69
67
 
70
68
  expect(asFragment().firstChild).toBeNull();
71
69
  });
@@ -73,9 +71,7 @@ describe('<RecommendedArticles>', () => {
73
71
  it('should render the error state correctly', () => {
74
72
  (useFetch as jest.Mock).mockReturnValue({ error: 'Some error occurred' });
75
73
 
76
- const { asFragment } = render(
77
- <RecommendedArticles heading={heading} analyticsStream={() => ({})} />
78
- );
74
+ const { asFragment } = render(<RecommendedArticles heading={heading} />);
79
75
 
80
76
  expect(asFragment().firstChild).toBeNull();
81
77
  });
@@ -86,11 +82,7 @@ describe('<RecommendedArticles>', () => {
86
82
  });
87
83
 
88
84
  const { asFragment, getByText } = render(
89
- <RecommendedArticles
90
- heading={heading}
91
- isVisible
92
- analyticsStream={() => ({})}
93
- />
85
+ <RecommendedArticles heading={heading} isVisible />
94
86
  );
95
87
 
96
88
  expect(getByText(heading));
@@ -104,7 +96,7 @@ describe('<RecommendedArticles>', () => {
104
96
  });
105
97
 
106
98
  const { asFragment, getByText } = render(
107
- <RecommendedArticles heading={heading} analyticsStream={() => ({})} />
99
+ <RecommendedArticles heading={heading} />
108
100
  );
109
101
 
110
102
  expect(getByText(heading));
@@ -117,11 +109,7 @@ describe('<RecommendedArticles>', () => {
117
109
  (useFetch as jest.Mock).mockReturnValue({ data: previewData });
118
110
 
119
111
  const { asFragment, getByText } = render(
120
- <RecommendedArticles
121
- heading={heading}
122
- isVisible
123
- analyticsStream={() => ({})}
124
- />
112
+ <RecommendedArticles heading={heading} isVisible />
125
113
  );
126
114
 
127
115
  expect(getByText(heading));
@@ -141,11 +129,7 @@ describe('<RecommendedArticles>', () => {
141
129
  context={initialContext}
142
130
  analyticsStream={analyticsStream}
143
131
  >
144
- <RecommendedArticles
145
- heading={heading}
146
- isVisible
147
- analyticsStream={() => ({})}
148
- />
132
+ <RecommendedArticles heading={heading} isVisible />
149
133
  </TrackingContextProvider>
150
134
  );
151
135
 
@@ -23,7 +23,6 @@ describe('<RecommendedFetch>', () => {
23
23
  articleId="1234"
24
24
  articleHeadline="Some headline"
25
25
  articleSection="News"
26
- analyticsStream={() => ({})}
27
26
  />
28
27
  );
29
28