@times-components/ts-components 1.27.0 → 1.29.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.
@@ -54,10 +54,11 @@ const flagsMapping = (override = '') => {
54
54
  color: override
55
55
  };
56
56
  }
57
+
57
58
  return new Map([
58
59
  ['NEW', <NewArticleFlag {...colourProp} />],
59
- ['LIVE', <LiveArticleFlag />],
60
- ['BREAKING', <BreakingArticleFlag />],
60
+ ['LIVE', <LiveArticleFlag {...colourProp} />],
61
+ ['BREAKING', <BreakingArticleFlag {...colourProp} />],
61
62
  ['UPDATED', <UpdatedArticleFlag {...colourProp} />],
62
63
  ['EXCLUSIVE', <ExclusiveArticleFlag {...colourProp} />],
63
64
  ['SPONSORED', <SponsoredArticleFlag {...colourProp} />],
@@ -9,7 +9,10 @@ import {
9
9
  import { UpdatedTimestamp } from '../updated-timestamp/UpdatedTimestamp';
10
10
  import { useUpdatedTime } from '../../helpers/time/UpdatedTimeProvider';
11
11
 
12
- export const BaseLiveArticleFlag: React.FC<{ title: string }> = ({ title }) => {
12
+ export const BaseLiveArticleFlag: React.FC<{
13
+ title: string;
14
+ timeStampTextColor?: string;
15
+ }> = ({ title, timeStampTextColor }) => {
13
16
  const updatedTime = useUpdatedTime();
14
17
 
15
18
  return (
@@ -20,15 +23,15 @@ export const BaseLiveArticleFlag: React.FC<{ title: string }> = ({ title }) => {
20
23
  </LiveArticleFlagIconContainer>
21
24
  <LiveArticleFlagText>{title}</LiveArticleFlagText>
22
25
  </LiveArticleFlagContainer>
23
- <UpdatedTimestamp updatedTime={updatedTime} />
26
+ <UpdatedTimestamp updatedTime={updatedTime} color={timeStampTextColor} />
24
27
  </LiveFlagAndTimestampContainer>
25
28
  );
26
29
  };
27
30
 
28
- export const LiveArticleFlag: React.FC = () => (
29
- <BaseLiveArticleFlag title="LIVE" />
31
+ export const LiveArticleFlag: React.FC<{ color?: string }> = ({ color }) => (
32
+ <BaseLiveArticleFlag timeStampTextColor={color} title="LIVE" />
30
33
  );
31
34
 
32
- export const BreakingArticleFlag: React.FC = () => (
33
- <BaseLiveArticleFlag title="BREAKING" />
34
- );
35
+ export const BreakingArticleFlag: React.FC<{ color?: string }> = ({
36
+ color
37
+ }) => <BaseLiveArticleFlag timeStampTextColor={color} title="BREAKING" />;
@@ -43,12 +43,12 @@ const scrollEvent = {
43
43
  }
44
44
  };
45
45
 
46
- const clickEvent = (buttonLabel: string, isLiveOrBreaking?: string) => ({
46
+ const clickEvent = (buttonLabel: string, flag?: string) => ({
47
47
  action: 'Clicked',
48
48
  attrs: {
49
49
  event_navigation_name: `button : ${buttonLabel}`,
50
50
  event_navigation_browsing_method: 'click',
51
- other_details: isLiveOrBreaking
51
+ article_flag: flag
52
52
  }
53
53
  });
54
54
 
@@ -57,12 +57,13 @@ export const InArticlePuff: React.FC<{
57
57
  forceImageAspectRatio?: AspectRatios;
58
58
  isLiveOrBreaking?: string;
59
59
  }> = ({ sectionColour, forceImageAspectRatio, isLiveOrBreaking }) => {
60
+ const articleFlag = isLiveOrBreaking || 'no flag';
60
61
  const handleClick = (
61
62
  fireAnalyticsEvent: (evt: TrackingContext) => void,
62
63
  buttonLabel: string
63
64
  ) => {
64
65
  fireAnalyticsEvent &&
65
- fireAnalyticsEvent(clickEvent(buttonLabel, isLiveOrBreaking));
66
+ fireAnalyticsEvent(clickEvent(buttonLabel, articleFlag));
66
67
  };
67
68
 
68
69
  const { loading, error, data } = useFetch<InArticlePuffDeckData>();
@@ -98,7 +99,7 @@ export const InArticlePuff: React.FC<{
98
99
  component_type: 'in-article component : puff : interactive',
99
100
  event_navigation_action: 'navigation',
100
101
  component_name: `${headline}`,
101
- other_details: isLiveOrBreaking
102
+ article_flag: articleFlag
102
103
  }
103
104
  }}
104
105
  scrolledEvent={scrollEvent}
@@ -169,13 +169,13 @@ describe('InArticlePuff', () => {
169
169
  event_navigation_action: 'navigation',
170
170
  event_navigation_browsing_method: 'scroll',
171
171
  event_navigation_name: 'in-article component displayed : puff',
172
- section: 'section'
172
+ section: 'section',
173
+ article_flag: 'no flag'
173
174
  }
174
175
  });
175
176
  });
176
177
 
177
178
  it('fires click event when Read more clicked', () => {
178
- mockIsLiveOrBreakingFlag = 'live';
179
179
  (useFetch as jest.Mock).mockReturnValue(
180
180
  deckApiPayloadWrapper(optionalFields)
181
181
  );
@@ -187,12 +187,12 @@ describe('InArticlePuff', () => {
187
187
  attrs: {
188
188
  articleHeadline: 'articleHeadline',
189
189
  section: 'section',
190
- other_details: 'live'
190
+ article_flag: 'live'
191
191
  }
192
192
  }}
193
193
  analyticsStream={analyticsStream}
194
194
  >
195
- <InArticlePuff {...requiredProps} />
195
+ <InArticlePuff sectionColour="yellow" isLiveOrBreaking={'live'} />
196
196
  </TrackingContextProvider>
197
197
  );
198
198
 
@@ -213,13 +213,12 @@ describe('InArticlePuff', () => {
213
213
  event_navigation_browsing_method: 'click',
214
214
  event_navigation_name: 'button : Read the full article',
215
215
  section: 'section',
216
- other_details: 'live'
216
+ article_flag: 'live'
217
217
  }
218
218
  });
219
219
  });
220
220
 
221
221
  it('fires click event when headline clicked', () => {
222
- mockIsLiveOrBreakingFlag = 'breaking';
223
222
  (useFetch as jest.Mock).mockReturnValue(
224
223
  deckApiPayloadWrapper(optionalFields)
225
224
  );
@@ -231,12 +230,12 @@ describe('InArticlePuff', () => {
231
230
  attrs: {
232
231
  articleHeadline: 'articleHeadline',
233
232
  section: 'section',
234
- other_details: 'breaking'
233
+ article_flag: 'breaking'
235
234
  }
236
235
  }}
237
236
  analyticsStream={analyticsStream}
238
237
  >
239
- <InArticlePuff {...requiredProps} />
238
+ <InArticlePuff sectionColour="yellow" isLiveOrBreaking={'breaking'} />
240
239
  </TrackingContextProvider>
241
240
  );
242
241
 
@@ -257,7 +256,7 @@ describe('InArticlePuff', () => {
257
256
  event_navigation_browsing_method: 'click',
258
257
  event_navigation_name: 'button : headline',
259
258
  section: 'section',
260
- other_details: 'breaking'
259
+ article_flag: 'breaking'
261
260
  }
262
261
  });
263
262
  });
@@ -297,7 +296,8 @@ describe('InArticlePuff', () => {
297
296
  event_navigation_action: 'navigation',
298
297
  event_navigation_browsing_method: 'click',
299
298
  event_navigation_name: 'button : image',
300
- section: 'section'
299
+ section: 'section',
300
+ article_flag: 'no flag'
301
301
  }
302
302
  });
303
303
  });
@@ -5,7 +5,8 @@ import { Container, TimeSinceUpdate } from './styles';
5
5
 
6
6
  export const UpdatedTimestamp: React.FC<{
7
7
  updatedTime?: string;
8
- }> = ({ updatedTime }) => {
8
+ color?: string;
9
+ }> = ({ updatedTime, color }) => {
9
10
  if (!updatedTime) {
10
11
  return null;
11
12
  }
@@ -23,11 +24,11 @@ export const UpdatedTimestamp: React.FC<{
23
24
  return (
24
25
  <Container>
25
26
  {!isLessThan1Minute && isLessThan13Hours ? (
26
- <TimeSinceUpdate data-testId="MinutesHoursSinceUpdate">
27
+ <TimeSinceUpdate color={color} data-testId="MinutesHoursSinceUpdate">
27
28
  {`Updated ${timeSincePublishing}`}
28
29
  </TimeSinceUpdate>
29
30
  ) : !isLessThan13Hours ? (
30
- <TimeSinceUpdate data-testId="DateTimeUpdated">
31
+ <TimeSinceUpdate color={color} data-testId="DateTimeUpdated">
31
32
  {`Updated `}
32
33
  {format(updatedDate, 'MMMM d, ')}
33
34
  {format(updatedDate, 'h.mmaaa')}
@@ -47,4 +47,12 @@ describe('UpdatedTimestamp', () => {
47
47
  'Updated February 28, 9.00am'
48
48
  );
49
49
  });
50
+
51
+ it('shows timestamp with an overrided color', () => {
52
+ MockDate.set('2022-02-28T23:30:00Z');
53
+ const { baseElement } = render(
54
+ <UpdatedTimestamp updatedTime={updated} color={'yellow'} />
55
+ );
56
+ expect(baseElement).toMatchSnapshot();
57
+ });
50
58
  });
@@ -9,3 +9,23 @@ exports[`UpdatedTimestamp does not show the timestamp within the first minute af
9
9
  </div>
10
10
  </body>
11
11
  `;
12
+
13
+ exports[`UpdatedTimestamp shows timestamp with an overrided color 1`] = `
14
+ <body>
15
+ <div>
16
+ <div
17
+ class="sc-bdVaJa cSmEjS"
18
+ >
19
+ <div
20
+ class="sc-bwzfXH gjKjda"
21
+ color="yellow"
22
+ data-testid="DateTimeUpdated"
23
+ >
24
+ Updated
25
+ February 28,
26
+ 9.00am
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </body>
31
+ `;
@@ -7,8 +7,8 @@ export const Container = styled.div`
7
7
  padding: 3px 0 0 8px;
8
8
  `;
9
9
 
10
- export const TimeSinceUpdate = styled.div`
11
- color: ${colours.functional.primary};
10
+ export const TimeSinceUpdate = styled.div<{ color?: string }>`
11
+ color: ${({ color }) => color || colours.functional.primary};
12
12
  font-family: ${fonts.supporting};
13
13
  font-size: 12px;
14
14
  line-height: 16px;