@times-components/ts-components 1.78.1-alpha.52 → 1.79.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/article-header/ArticleBylineBlock.d.ts +2 -2
- package/dist/components/article-header/ArticleBylineBlock.js +13 -12
- package/dist/components/article-header/ArticleBylineBlock.stories.js +2 -2
- package/dist/components/article-header/ArticleHeader.js +4 -4
- package/dist/components/article-header/__tests__/ArticleBylineBlock.test.js +3 -3
- package/dist/components/article-header/styles.d.ts +1 -1
- package/dist/components/article-header/styles.js +2 -2
- package/dist/types/related-article-slice.d.ts +1 -1
- package/package.json +16 -16
- package/rnw.js +1 -1
- package/src/components/article-header/ArticleBylineBlock.stories.tsx +1 -1
- package/src/components/article-header/ArticleBylineBlock.tsx +18 -17
- package/src/components/article-header/ArticleHeader.tsx +4 -4
- package/src/components/article-header/__tests__/ArticleBylineBlock.test.tsx +2 -2
- package/src/components/article-header/styles.ts +1 -1
- package/src/types/related-article-slice.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ArticleBylineAuthorData } from '../../types/related-article-slice';
|
|
3
3
|
import {
|
|
4
4
|
BylineBlockContainer,
|
|
5
5
|
BylineBlockImgContainer,
|
|
@@ -8,42 +8,43 @@ import {
|
|
|
8
8
|
BylineBlockAuthorContent,
|
|
9
9
|
BylineBlockAuthorName,
|
|
10
10
|
BylineBlockAuthorJobTitle,
|
|
11
|
-
|
|
11
|
+
BylineBlockDescription
|
|
12
12
|
} from './styles';
|
|
13
13
|
|
|
14
14
|
export const ArticleBylineBlock: React.FC<{
|
|
15
|
-
|
|
15
|
+
authorData?: ArticleBylineAuthorData;
|
|
16
16
|
description?: string;
|
|
17
|
-
}> = ({
|
|
18
|
-
if (
|
|
17
|
+
}> = ({ authorData, description }) => {
|
|
18
|
+
if (
|
|
19
|
+
!((authorData && authorData.name) || (authorData && authorData.image)) &&
|
|
20
|
+
!description
|
|
21
|
+
) {
|
|
19
22
|
return null;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
return (
|
|
23
26
|
<BylineBlockContainer>
|
|
24
|
-
{
|
|
25
|
-
|
|
27
|
+
{authorData &&
|
|
28
|
+
authorData.image && (
|
|
26
29
|
<BylineBlockImgContainer>
|
|
27
|
-
<BylineBlockImg src={
|
|
30
|
+
<BylineBlockImg src={authorData.image} alt={authorData.name} />
|
|
28
31
|
</BylineBlockImgContainer>
|
|
29
32
|
)}
|
|
30
33
|
<BylineBlockContent>
|
|
31
34
|
<BylineBlockAuthorContent>
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
<BylineBlockAuthorName>{
|
|
35
|
+
{authorData &&
|
|
36
|
+
authorData.name && (
|
|
37
|
+
<BylineBlockAuthorName>{authorData.name}</BylineBlockAuthorName>
|
|
35
38
|
)}
|
|
36
|
-
{
|
|
37
|
-
|
|
39
|
+
{authorData &&
|
|
40
|
+
authorData.jobTitle && (
|
|
38
41
|
<BylineBlockAuthorJobTitle>
|
|
39
|
-
{
|
|
42
|
+
{authorData.jobTitle}
|
|
40
43
|
</BylineBlockAuthorJobTitle>
|
|
41
44
|
)}
|
|
42
45
|
</BylineBlockAuthorContent>
|
|
43
46
|
{description && (
|
|
44
|
-
<
|
|
45
|
-
{description}
|
|
46
|
-
</BylineBlockAuthorDescription>
|
|
47
|
+
<BylineBlockDescription>{description}</BylineBlockDescription>
|
|
47
48
|
)}
|
|
48
49
|
</BylineBlockContent>
|
|
49
50
|
</BylineBlockContainer>
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
UpdatesContainer,
|
|
22
22
|
FlagContainer
|
|
23
23
|
} from './styles';
|
|
24
|
-
import {
|
|
24
|
+
import { ArticleBylineAuthorData } from '../../types/related-article-slice';
|
|
25
25
|
import { ArticleBylineBlock } from './ArticleBylineBlock';
|
|
26
26
|
|
|
27
27
|
const anchorString = (updateTxt = '', headlineTxt = '') => {
|
|
@@ -41,7 +41,7 @@ const ArticleHeader: React.FC<{
|
|
|
41
41
|
description?: string;
|
|
42
42
|
}> = ({ updated, breaking, headline, authorSlug, description }) => {
|
|
43
43
|
const [timezone, setTimezone] = useState<string>('');
|
|
44
|
-
const [
|
|
44
|
+
const [authorData, setAuthorData] = useState<ArticleBylineAuthorData>();
|
|
45
45
|
|
|
46
46
|
const currentDateTime = new Date();
|
|
47
47
|
const updatedDate = new Date(updated);
|
|
@@ -63,7 +63,7 @@ const ArticleHeader: React.FC<{
|
|
|
63
63
|
try {
|
|
64
64
|
const response = await fetch(`/api/author-profile/${authorSlug}`);
|
|
65
65
|
const authorDetails = await response.json();
|
|
66
|
-
|
|
66
|
+
setAuthorData(authorDetails);
|
|
67
67
|
} catch (err) {
|
|
68
68
|
// tslint:disable-next-line:no-console
|
|
69
69
|
console.log(err);
|
|
@@ -125,7 +125,7 @@ const ArticleHeader: React.FC<{
|
|
|
125
125
|
</UpdatesContainer>
|
|
126
126
|
|
|
127
127
|
{headline && <Headline>{safeDecodeURIComponent(headline)}</Headline>}
|
|
128
|
-
<ArticleBylineBlock
|
|
128
|
+
<ArticleBylineBlock authorData={authorData} description={description} />
|
|
129
129
|
</Container>
|
|
130
130
|
);
|
|
131
131
|
};
|
|
@@ -16,7 +16,7 @@ describe('Article byline block', () => {
|
|
|
16
16
|
|
|
17
17
|
it('Displays description', () => {
|
|
18
18
|
const { getByText } = render(
|
|
19
|
-
<ArticleBylineBlock
|
|
19
|
+
<ArticleBylineBlock authorData={undefined} description={description} />
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
expect(getByText(description)).toBeVisible();
|
|
@@ -31,7 +31,7 @@ describe('Article byline block', () => {
|
|
|
31
31
|
|
|
32
32
|
it('Displays author details and description', () => {
|
|
33
33
|
const { getByText, getByRole } = render(
|
|
34
|
-
<ArticleBylineBlock
|
|
34
|
+
<ArticleBylineBlock authorData={data} description={description} />
|
|
35
35
|
);
|
|
36
36
|
expect(getByText(data.name)).toBeVisible();
|
|
37
37
|
expect(getByText(data.jobTitle)).toBeVisible();
|
|
@@ -133,7 +133,7 @@ export const BylineBlockAuthorJobTitle = styled.p`
|
|
|
133
133
|
margin-block: 0;
|
|
134
134
|
`;
|
|
135
135
|
|
|
136
|
-
export const
|
|
136
|
+
export const BylineBlockDescription = styled.p`
|
|
137
137
|
color: #696969;
|
|
138
138
|
font-weight: 500;
|
|
139
139
|
margin-block: 0;
|