-
Notifications
You must be signed in to change notification settings - Fork 42
/
article-meta.web.js
83 lines (73 loc) · 1.99 KB
/
article-meta.web.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* eslint-disable react/require-default-props */
import React from "react";
import PropTypes from "prop-types";
import { Text, View } from "react-native";
import styled from "styled-components";
import { breakpoints, spacing } from "@times-components/styleguide";
import {
KeylineItem,
ArticleKeylineItem
} from "@times-components/article-skeleton";
import {
ArticleBylineWithLinks,
hasBylineData
} from "@times-components/article-byline";
import DatePublication from "@times-components/date-publication";
import { defaultProps, propTypes } from "./article-meta-prop-types";
import styles from "../styles/article-meta";
const MetaTextElement = styled(Text)`
padding-top: ${spacing(2)};
&:last-child {
padding-bottom: ${spacing(2)};
}
@media (min-width: ${breakpoints.wide}px) {
line-height: 18px;
padding-bottom: ${spacing(2)};
}
`;
function ArticleMeta({
bylines,
publicationName,
publishedTime,
onAuthorPress,
inline = false,
className = ""
}) {
const bylineRow = hasBylineData(bylines) ? (
<MetaTextElement>
<Text style={styles.byline}>
<ArticleBylineWithLinks ast={bylines} onAuthorPress={onAuthorPress} />
</Text>
</MetaTextElement>
) : null;
const publicationRow = (
<MetaTextElement>
<Text style={styles.datePublication}>
<DatePublication date={publishedTime} publication={publicationName} />
</Text>
</MetaTextElement>
);
const KeylineComponent = inline ? ArticleKeylineItem : KeylineItem;
return (
<>
{inline ? null : (
<KeylineComponent className={className}>
<View>{bylineRow}</View>
</KeylineComponent>
)}
<KeylineComponent className={className}>
<View>
{inline ? bylineRow : null}
{publicationRow}
</View>
</KeylineComponent>
</>
);
}
ArticleMeta.propTypes = {
...propTypes,
inline: PropTypes.bool,
className: PropTypes.string
};
ArticleMeta.defaultProps = defaultProps;
export default ArticleMeta;