-
Notifications
You must be signed in to change notification settings - Fork 42
/
article-header.web.js
67 lines (62 loc) · 2.04 KB
/
article-header.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
import React from "react";
import { View } from "react-native";
import { ArticleFlags } from "@times-components/article-flag";
import Context from "@times-components/context";
import { fonts } from "@times-components/styleguide";
import { gqlRgbaToStyle } from "@times-components/utils";
import Label from "../article-label/article-label";
import Standfirst from "../article-standfirst/article-standfirst";
import {
articleHeaderPropTypes,
articleHeaderDefaultProps
} from "./article-header-prop-types";
import styles from "../styles";
import {
FlagsContainer,
HeaderContainer,
HeadlineContainer
} from "../styles/responsive";
const ArticleHeader = ({
backgroundColour: rgbBackgroundColour,
flags,
hasVideo,
headline,
label,
standfirst,
textColour: rgbTextColour
}) => {
const backgroundColour = gqlRgbaToStyle(rgbBackgroundColour);
const textColour = gqlRgbaToStyle(rgbTextColour);
return (
<Context.Consumer>
{({ theme: { headlineFont, headlineCase } }) => (
<View
style={{ backgroundColor: backgroundColour, order: 2, width: "100%" }}
>
<HeaderContainer style={styles.container}>
<Label color={textColour} isVideo={hasVideo} label={label} />
<HeadlineContainer
accessibilityRole="header"
aria-level="1"
style={[
styles.articleHeadline,
{ color: textColour },
headlineFont ? { fontFamily: fonts[headlineFont] } : null,
headlineCase ? { textTransform: headlineCase } : null
]}
>
{headline}
</HeadlineContainer>
<FlagsContainer>
<ArticleFlags color={textColour} flags={flags} />
</FlagsContainer>
<Standfirst color={textColour} standfirst={standfirst} />
</HeaderContainer>
</View>
)}
</Context.Consumer>
);
};
ArticleHeader.propTypes = articleHeaderPropTypes;
ArticleHeader.defaultProps = articleHeaderDefaultProps;
export default ArticleHeader;