@times-components/ts-components 1.22.3 → 1.25.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.
@@ -1,25 +1,61 @@
1
- import styled from 'styled-components';
1
+ import styled, { keyframes } from 'styled-components';
2
2
  import { fonts } from '@times-components/styleguide';
3
3
  import { FlagType } from './ArticleFlag';
4
4
  import { gqlRgbaToStyle } from '@times-components/utils';
5
5
 
6
- export const ArticleFlagContainer = styled.div`
6
+ export const LiveArticleFlagContainer = styled.div`
7
+ background-color: #9f0000;
8
+ height: 24px;
9
+ padding: 7px 7px 7px 9px;
7
10
  display: flex;
8
- align-items: center;
9
11
  flex-direction: row;
12
+ width: fit-content;
10
13
  `;
11
14
 
12
- export const LiveFlagAndTimestampContainer = styled.div`
15
+ export const LiveArticleFlagText = styled.span`
16
+ font-family: ${fonts.supporting};
17
+ color: #ffffff;
18
+ font-weight: 500;
19
+ font-size: 12px;
20
+ letter-spacing: 0.1em;
21
+ `;
22
+
23
+ const flashing = keyframes`
24
+ 0% {
25
+ background-color: #ffffff;
26
+ }
27
+
28
+ 50% {
29
+ background-color: #9f0000;
30
+ }
31
+
32
+ 100% {
33
+ background-color: #ffffff;
34
+ }`;
35
+
36
+ export const LiveArticleFlagIconContainer = styled.div`
37
+ height: 100%;
38
+ display: flex;
39
+ align-items: center;
40
+ margin-right: 7px;
41
+ `;
42
+
43
+ export const LiveArticleFlagIcon = styled.div`
44
+ height: 6px;
45
+ width: 6px;
46
+ animation: ${flashing} 2000ms infinite;
47
+ `;
48
+
49
+ export const ArticleFlagContainer = styled.div`
13
50
  display: flex;
14
51
  align-items: center;
15
52
  flex-direction: row;
16
53
  `;
17
54
 
18
- export const LiveArticleFlagContainer = styled.div`
55
+ export const LiveFlagAndTimestampContainer = styled.div`
19
56
  display: flex;
20
- padding: 2px 6px;
21
- background-color: #9f0000;
22
- align-items: baseline;
57
+ align-items: center;
58
+ flex-direction: row;
23
59
  `;
24
60
 
25
61
  export const ArticleFlagBullet = styled.div`
@@ -29,12 +65,6 @@ export const ArticleFlagBullet = styled.div`
29
65
  background-color: ${({ color }) => gqlRgbaToStyle(color) || color};
30
66
  `;
31
67
 
32
- export const LiveIconContainer = styled.div`
33
- margin-right: 8px;
34
- color: #ffffff;
35
- align-self: self-start;
36
- `;
37
-
38
68
  export const ArticleFlagTextContainer = styled.div`
39
69
  font-family: TimesDigitalW04-RegularSC;
40
70
  font-size: 12px;
@@ -45,15 +75,6 @@ export const ArticleFlagTextContainer = styled.div`
45
75
  color: ${({ color }) => gqlRgbaToStyle(color) || color};
46
76
  `;
47
77
 
48
- export const LiveArticleFlagText = styled.span`
49
- font-family: ${fonts.supporting};
50
- color: #ffffff;
51
- font-weight: 500;
52
- font-size: 12px;
53
- letter-spacing: 0.1em;
54
- line-height: 16px;
55
- `;
56
-
57
78
  export const FlagPadding = styled.div<{ allFlags: FlagType }>`
58
79
  margin-right: ${({ allFlags }) => (allFlags.length > 1 ? '15px' : 0)};
59
80
  `;
@@ -33,18 +33,26 @@ const ArticleHeader: React.FC<{
33
33
  roundingMethod: 'floor'
34
34
  }) + ' ago';
35
35
  const diffInSeconds = differenceInSeconds(currentDateTime, updatedDate);
36
+ const anchorString = (updateTxt = '', headlineTxt = '') => {
37
+ const onlyNumbersReg = /\D+/g;
38
+ const onlyNumbers = updateTxt.replace(onlyNumbersReg, '');
39
+ const acronymReg = /\b(\w)/g;
40
+ const acronymMatch = headlineTxt.match(acronymReg);
41
+ const acronym = acronymMatch === null ? '' : acronymMatch.join('');
42
+ return `u_${onlyNumbers}${acronym}`;
43
+ };
36
44
 
37
45
  const isLessThan1Minute = diffInSeconds < 60;
38
46
  const isLessThan1Hour = diffInSeconds < 60 * 60;
39
47
  const isLessThan13Hours = diffInSeconds < 60 * 60 * 13;
40
48
  const isDaysAgo = differenceInCalendarDays(currentDateTime, updatedDate) >= 1;
41
-
49
+ const anchorPoint = anchorString(updated, headline);
42
50
  const isBreaking = breaking
43
51
  ? Boolean(breaking.toLowerCase() === 'true')
44
52
  : false;
45
53
 
46
54
  return (
47
- <Container isBreaking={isBreaking && isLessThan1Hour}>
55
+ <Container isBreaking={isBreaking && isLessThan1Hour} id={anchorPoint}>
48
56
  <UpdatesContainer>
49
57
  <UpdatedTimeItems>
50
58
  {isBreaking && isLessThan1Hour ? (
@@ -5,6 +5,7 @@ exports[`ArticleHeader In one calendar day Within the first minute of update - B
5
5
  <div>
6
6
  <div
7
7
  class="sc-bdVaJa cQBRMp"
8
+ id="u_20211231063000T222"
8
9
  >
9
10
  <div
10
11
  class="sc-bwzfXH htoLMg"
@@ -16,23 +17,23 @@ exports[`ArticleHeader In one calendar day Within the first minute of update - B
16
17
  class="sc-dnqmqq bGasAc"
17
18
  >
18
19
  <div
19
- class="sc-gZMcBi erfHmy"
20
+ class="sc-fjdhpX Vdnui"
20
21
  >
21
22
  <div
22
- class="sc-gqjmRU fwGLTx"
23
+ class="sc-iwsKbI fqYeBv"
23
24
  >
24
25
  <div
25
- class="sc-jTzLTM bTqqzd"
26
+ class="sc-gqjmRU cTMoEm"
26
27
  >
27
-
28
- </div>
29
- <div>
30
- <span
31
- class="sc-jzJRlG erbwEj"
32
- >
33
- BREAKING
34
- </span>
28
+ <div
29
+ class="sc-VigVT rGeCL"
30
+ />
35
31
  </div>
32
+ <span
33
+ class="sc-gZMcBi iBeFrd"
34
+ >
35
+ BREAKING
36
+ </span>
36
37
  </div>
37
38
  </div>
38
39
  </div>
@@ -59,6 +60,7 @@ exports[`ArticleHeader In one calendar day Within the first minute of update - N
59
60
  <div>
60
61
  <div
61
62
  class="sc-bdVaJa fLcQHz"
63
+ id="u_20211231063000"
62
64
  >
63
65
  <div
64
66
  class="sc-bwzfXH htoLMg"
@@ -84,6 +86,7 @@ exports[`ArticleHeader In one calendar day Within the first minute of update - N
84
86
  <div>
85
87
  <div
86
88
  class="sc-bdVaJa fLcQHz"
89
+ id="u_20211231063000T222"
87
90
  >
88
91
  <div
89
92
  class="sc-bwzfXH htoLMg"
@@ -53,14 +53,12 @@ describe('<FetchProvider>', () => {
53
53
  it('loading', async () => {
54
54
  fetchMock.mockResponse(async () => ({ body: '{ "value" : "boo" }' }));
55
55
 
56
- const { asFragment, findByText } = render(
56
+ const { findByText } = render(
57
57
  <FetchProvider url="http://thetimes.co.uk">
58
58
  <TestComponent />
59
59
  </FetchProvider>
60
60
  );
61
61
  await findByText('Loading');
62
-
63
- expect(asFragment()).toMatchSnapshot();
64
62
  });
65
63
 
66
64
  it('error', async () => {
@@ -24,14 +24,6 @@ exports[`<FetchProvider> fetch 1`] = `
24
24
  </DocumentFragment>
25
25
  `;
26
26
 
27
- exports[`<FetchProvider> loading 1`] = `
28
- <DocumentFragment>
29
- <div>
30
- boo
31
- </div>
32
- </DocumentFragment>
33
- `;
34
-
35
27
  exports[`<FetchProvider> preview 1`] = `
36
28
  <DocumentFragment>
37
29
  <div>