@quintype/native-components 2.20.0-fix-rtl-issues.1 → 2.20.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 +122 -0
- package/package.json +7 -8
- package/src/Icons/ClockIcon/index.js +9 -5
- package/src/components/ActionText/ActionText.js +7 -9
- package/src/components/ActionText/ActionText.test.js +5 -12
- package/src/components/AlsoRead/index.js +1 -1
- package/src/components/AlsoRead/styles.js +2 -0
- package/src/components/AuthorRow/AuthorRow.test.js +4 -9
- package/src/components/AuthorRow/index.js +16 -12
- package/src/components/BackNavigator/styles.js +2 -0
- package/src/components/Button/index.js +13 -9
- package/src/components/CollectionCard/index.js +6 -1
- package/src/components/CollectionCardNew/index.js +5 -1
- package/src/components/CollectionTitleNew/styles.js +0 -1
- package/src/components/CustomSwitch/index.js +16 -10
- package/src/components/Header/index.js +13 -9
- package/src/components/JSEmbedElement/index.js +3 -1
- package/src/components/PDFReader/styles.js +1 -0
- package/src/components/PrimaryStoryCard/index.js +60 -24
- package/src/components/PrimaryStoryCard/styles.js +29 -5
- package/src/components/PrimaryStoryCardNew/index.js +67 -18
- package/src/components/PrimaryStoryCardNew/styles.js +29 -5
- package/src/components/RadioButton/index.js +24 -9
- package/src/components/SecondaryStoryCard/index.js +60 -22
- package/src/components/SecondaryStoryCard/styles.js +29 -4
- package/src/components/SecondaryStoryCardNew/index.js +68 -16
- package/src/components/SecondaryStoryCardNew/styles.js +28 -4
- package/src/components/ShareButton/index.js +8 -3
- package/src/components/SlideshowStoryCard/styles.js +3 -2
- package/src/components/Story/index.js +14 -10
- package/src/components/StoryHeader/index.js +9 -7
- package/src/components/StoryHeader/styles.js +4 -2
- package/src/components/StoryImage/index.js +1 -1
- package/src/components/StoryImage/styles.js +2 -2
- package/src/components/StoryText/index.js +3 -1
- package/src/components/StoryText/styles.js +2 -0
- package/src/components/Table/index.js +1 -1
- package/src/components/Table/styles.js +5 -2
- package/src/components/TextBigFact/index.js +1 -2
- package/src/components/TextBigFact/styles.js +3 -0
- package/src/components/TextBlockQuote/index.js +5 -4
- package/src/components/TextBlockQuote/styles.js +8 -0
- package/src/components/TextBlurb/styles.js +2 -0
- package/src/components/TextQandA/styles.js +3 -3
- package/src/components/TextQuote/styles.js +5 -2
- package/src/components/TextSummary/styles.js +2 -0
- package/src/components/YouTubePlayer/index.js +1 -0
- package/src/constants/component-constants/content-constants/constants.js +7 -5
- package/src/constants/component-constants/general-constants/constants.js +25 -14
- package/src/constants/renderHTML.js +10 -0
- package/src/utils/story.js +7 -3
- package/src/utils/timeUtils.js +13 -4
|
@@ -2,20 +2,21 @@ import { throttle } from 'lodash';
|
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { useContext } from 'react';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from 'react-native';
|
|
8
|
-
|
|
5
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
6
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
9
7
|
import {
|
|
10
8
|
AppTheme,
|
|
11
9
|
getImageMetadata,
|
|
12
10
|
getImageSlug,
|
|
13
|
-
|
|
11
|
+
getTimeForStoryCards,
|
|
14
12
|
} from '../../utils';
|
|
15
13
|
import { getStoryHeadline } from '../../utils/story';
|
|
16
14
|
import { ResponsiveImage, Text } from '../index';
|
|
17
15
|
import { storyStyles } from './styles';
|
|
18
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
COMP_GENERAL_CONSTANTS,
|
|
18
|
+
COMP_CONTENT_CONSTANTS,
|
|
19
|
+
} from '../../constants/component-constants';
|
|
19
20
|
|
|
20
21
|
export const PrimaryStoryCard = (props) => {
|
|
21
22
|
const { story = {} } = props;
|
|
@@ -23,7 +24,13 @@ export const PrimaryStoryCard = (props) => {
|
|
|
23
24
|
|
|
24
25
|
const translate = get(theme, ['translate'], (word) => word);
|
|
25
26
|
|
|
26
|
-
const {
|
|
27
|
+
const {
|
|
28
|
+
COLORS,
|
|
29
|
+
FONT_SIZE,
|
|
30
|
+
locale,
|
|
31
|
+
reverseTimeAdverbPosition,
|
|
32
|
+
enableReadTimeOnStoryCards,
|
|
33
|
+
} = theme || {};
|
|
27
34
|
|
|
28
35
|
const DATE_FORMAT = 'd MMM, yyyy';
|
|
29
36
|
|
|
@@ -43,10 +50,39 @@ export const PrimaryStoryCard = (props) => {
|
|
|
43
50
|
|
|
44
51
|
const name = get(story.authors, [0, 'name']);
|
|
45
52
|
const authorName = name ? `${translate('By')} ${name} | ` : '';
|
|
46
|
-
const readTime =
|
|
53
|
+
const readTime = enableReadTimeOnStoryCards && story['read-time']
|
|
54
|
+
? `${story['read-time']} ${translate('min read')}`
|
|
55
|
+
: '';
|
|
47
56
|
|
|
48
57
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
49
58
|
|
|
59
|
+
const showIcon = (name) => (
|
|
60
|
+
<View style={styles.storyType}>
|
|
61
|
+
<Icon name={name} size={22} color={COLORS.MONO7} />
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const showLiveBlogIcon = () => (
|
|
66
|
+
<View style={styles.storyType}>
|
|
67
|
+
<View style={styles.liveBlogIcon} />
|
|
68
|
+
<Text style={styles.liveBlogText}>LIVE</Text>
|
|
69
|
+
</View>
|
|
70
|
+
);
|
|
71
|
+
const showStoryType = () => {
|
|
72
|
+
switch (story['story-template']) {
|
|
73
|
+
case 'text':
|
|
74
|
+
return null;
|
|
75
|
+
case 'photo':
|
|
76
|
+
return showIcon('photo');
|
|
77
|
+
case 'video':
|
|
78
|
+
return showIcon('play');
|
|
79
|
+
case 'live-blog':
|
|
80
|
+
return showLiveBlogIcon();
|
|
81
|
+
default:
|
|
82
|
+
null;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
50
86
|
return (
|
|
51
87
|
<TouchableOpacity
|
|
52
88
|
testID={COMP_GENERAL_CONSTANTS.primaryStoryCard}
|
|
@@ -61,29 +97,29 @@ export const PrimaryStoryCard = (props) => {
|
|
|
61
97
|
imageWidth={props.imageWidth}
|
|
62
98
|
>
|
|
63
99
|
<Text style={styles.xminContainer}>
|
|
64
|
-
{' '}
|
|
65
100
|
{readTime && (
|
|
66
101
|
<View style={styles.xmin}>
|
|
67
102
|
<Text style={styles.xminText}>{readTime}</Text>
|
|
68
103
|
</View>
|
|
69
104
|
)}
|
|
70
105
|
</Text>
|
|
106
|
+
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
71
107
|
</ResponsiveImage>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
</
|
|
108
|
+
<Text
|
|
109
|
+
style={autorStyle}
|
|
110
|
+
numberOfLines={2}
|
|
111
|
+
// TODO: Add corrected testID here
|
|
112
|
+
testID={COMP_CONTENT_CONSTANTS.authorName}
|
|
113
|
+
>
|
|
114
|
+
{authorName
|
|
115
|
+
+ getTimeForStoryCards(
|
|
116
|
+
story['published-at'],
|
|
117
|
+
DATE_FORMAT,
|
|
118
|
+
locale,
|
|
119
|
+
translate,
|
|
120
|
+
reverseTimeAdverbPosition,
|
|
121
|
+
)}
|
|
122
|
+
</Text>
|
|
87
123
|
<Text
|
|
88
124
|
primary
|
|
89
125
|
numberOfLines={3}
|
|
@@ -3,15 +3,11 @@ export const storyStyles = (COLORS = {}, FONT_SIZE = {}, DARK_MODE = {}) => ({
|
|
|
3
3
|
backgroundColor: COLORS.BRAND_WHITE,
|
|
4
4
|
marginTop: 12,
|
|
5
5
|
},
|
|
6
|
-
authorBlockContainer: {
|
|
7
|
-
alignItems: 'center',
|
|
8
|
-
flexDirection: 'row',
|
|
9
|
-
paddingVertical: 8,
|
|
10
|
-
},
|
|
11
6
|
autorText: {
|
|
12
7
|
color: COLORS?.BRAND_6,
|
|
13
8
|
fontSize: FONT_SIZE.h5,
|
|
14
9
|
lineHeight: FONT_SIZE.h5 * 1.3,
|
|
10
|
+
paddingVertical: 8,
|
|
15
11
|
},
|
|
16
12
|
divider: {
|
|
17
13
|
backgroundColor: COLORS.BRAND_6,
|
|
@@ -39,4 +35,32 @@ export const storyStyles = (COLORS = {}, FONT_SIZE = {}, DARK_MODE = {}) => ({
|
|
|
39
35
|
color: COLORS.BRAND_BLACK,
|
|
40
36
|
fontSize: FONT_SIZE.h5,
|
|
41
37
|
},
|
|
38
|
+
storyTypeContainer: {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
bottom: 0,
|
|
41
|
+
left: 0,
|
|
42
|
+
},
|
|
43
|
+
storyType: {
|
|
44
|
+
backgroundColor: COLORS.MONO1,
|
|
45
|
+
padding: 8,
|
|
46
|
+
justifyContent: 'space-between',
|
|
47
|
+
alignItems: 'space-between',
|
|
48
|
+
flexDirection: 'row',
|
|
49
|
+
},
|
|
50
|
+
storyTypeText: {
|
|
51
|
+
color: COLORS.MONO7,
|
|
52
|
+
fontSize: FONT_SIZE.h5,
|
|
53
|
+
},
|
|
54
|
+
liveBlogText: {
|
|
55
|
+
color: COLORS.MONO7,
|
|
56
|
+
fontSize: FONT_SIZE.h4,
|
|
57
|
+
marginLeft: 10,
|
|
58
|
+
fontWeight: 'bold',
|
|
59
|
+
},
|
|
60
|
+
liveBlogIcon: {
|
|
61
|
+
height: 15,
|
|
62
|
+
width: 15,
|
|
63
|
+
borderRadius: 50,
|
|
64
|
+
backgroundColor: COLORS.BRAND_3,
|
|
65
|
+
},
|
|
42
66
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { throttle } from 'lodash';
|
|
1
|
+
import { get, throttle } from 'lodash';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { useContext, memo } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
} from 'react-native';
|
|
4
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
5
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
7
6
|
import {
|
|
8
7
|
AppTheme,
|
|
9
8
|
getImageMetadata,
|
|
@@ -13,13 +12,26 @@ import {
|
|
|
13
12
|
import { getStoryHeadline } from '../../utils/story';
|
|
14
13
|
import { ResponsiveImage, Text } from '../index';
|
|
15
14
|
import { storyStyles } from './styles';
|
|
15
|
+
import {
|
|
16
|
+
COMP_GENERAL_CONSTANTS,
|
|
17
|
+
COMP_CONTENT_CONSTANTS,
|
|
18
|
+
} from '../../constants/component-constants';
|
|
16
19
|
|
|
17
20
|
const PrimaryStoryCardNewBase = (props) => {
|
|
18
21
|
const { story = {} } = props;
|
|
19
22
|
const { theme } = useContext(AppTheme);
|
|
20
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
COLORS,
|
|
25
|
+
FONT_SIZE,
|
|
26
|
+
locale,
|
|
27
|
+
DARK_MODE,
|
|
28
|
+
reverseTimeAdverbPosition,
|
|
29
|
+
enableReadTimeOnStoryCards,
|
|
30
|
+
} = theme || {};
|
|
31
|
+
|
|
32
|
+
const translate = get(theme, ['translate'], (word) => word);
|
|
21
33
|
|
|
22
|
-
const styles = storyStyles(COLORS, FONT_SIZE);
|
|
34
|
+
const styles = storyStyles(COLORS, FONT_SIZE, DARK_MODE);
|
|
23
35
|
const containerStyle = StyleSheet.flatten([
|
|
24
36
|
styles.container,
|
|
25
37
|
{ paddingHorizontal: props.horizontalPadding },
|
|
@@ -34,13 +46,42 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
34
46
|
]);
|
|
35
47
|
|
|
36
48
|
const DATE_FORMAT = 'd MMM, yyyy';
|
|
37
|
-
const readTime =
|
|
49
|
+
const readTime = enableReadTimeOnStoryCards && story['read-time']
|
|
50
|
+
? `${story['read-time']} ${translate('min read')} · `
|
|
51
|
+
: '';
|
|
38
52
|
|
|
39
53
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
40
54
|
|
|
55
|
+
const showIcon = (name) => (
|
|
56
|
+
<View style={styles.storyType}>
|
|
57
|
+
<Icon name={name} size={22} color={COLORS.MONO7} />
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const showLiveBlogIcon = () => (
|
|
62
|
+
<View style={styles.storyType}>
|
|
63
|
+
<View style={styles.liveBlogIcon} />
|
|
64
|
+
<Text style={styles.liveBlogText}>LIVE</Text>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
const showStoryType = () => {
|
|
68
|
+
switch (story['story-template']) {
|
|
69
|
+
case 'text':
|
|
70
|
+
return null;
|
|
71
|
+
case 'photo':
|
|
72
|
+
return showIcon('photo');
|
|
73
|
+
case 'video':
|
|
74
|
+
return showIcon('play');
|
|
75
|
+
case 'live-blog':
|
|
76
|
+
return showLiveBlogIcon();
|
|
77
|
+
default:
|
|
78
|
+
null;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
41
82
|
return (
|
|
42
83
|
<TouchableOpacity
|
|
43
|
-
testID=
|
|
84
|
+
testID={COMP_GENERAL_CONSTANTS.primaryStoryCard}
|
|
44
85
|
onPress={throttledOnpress}
|
|
45
86
|
activeOpacity={0.8}
|
|
46
87
|
style={containerStyle}
|
|
@@ -50,7 +91,9 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
50
91
|
slug={getImageSlug(story)}
|
|
51
92
|
cdn={props.cdn}
|
|
52
93
|
imageWidth={props.imageWidth}
|
|
53
|
-
|
|
94
|
+
>
|
|
95
|
+
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
96
|
+
</ResponsiveImage>
|
|
54
97
|
<View style={styles.contentContainer}>
|
|
55
98
|
<View style={styles.headlineAndTimestampContainer}>
|
|
56
99
|
<Text
|
|
@@ -58,18 +101,24 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
58
101
|
numberOfLines={3}
|
|
59
102
|
ellipsizeMode="tail"
|
|
60
103
|
style={headlineStyle}
|
|
61
|
-
testID=
|
|
104
|
+
testID={COMP_GENERAL_CONSTANTS.primaryStoryHeadline}
|
|
62
105
|
>
|
|
63
106
|
{getStoryHeadline(story)}
|
|
64
107
|
</Text>
|
|
65
|
-
<
|
|
66
|
-
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
108
|
+
<Text
|
|
109
|
+
style={timestampStyle}
|
|
110
|
+
numberOfLines={2}
|
|
111
|
+
testID={COMP_CONTENT_CONSTANTS.publishedDate}
|
|
112
|
+
>
|
|
113
|
+
{readTime
|
|
114
|
+
+ getTimeForStoryCards(
|
|
115
|
+
story['published-at'],
|
|
116
|
+
DATE_FORMAT,
|
|
117
|
+
locale,
|
|
118
|
+
translate,
|
|
119
|
+
reverseTimeAdverbPosition,
|
|
120
|
+
)}
|
|
121
|
+
</Text>
|
|
73
122
|
</View>
|
|
74
123
|
<View style={styles.icon}>{props.iconComponent}</View>
|
|
75
124
|
</View>
|
|
@@ -12,16 +12,12 @@ export const storyStyles = (COLORS = {}, FONT_SIZE = {}) => ({
|
|
|
12
12
|
flexShrink: 1,
|
|
13
13
|
flex: 1,
|
|
14
14
|
},
|
|
15
|
-
timestampContainer: {
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
flexDirection: 'row',
|
|
18
|
-
marginTop: 4,
|
|
19
|
-
},
|
|
20
15
|
timestamp: {
|
|
21
16
|
color: COLORS?.BRAND_BLACK,
|
|
22
17
|
fontSize: FONT_SIZE.h5,
|
|
23
18
|
lineHeight: FONT_SIZE.h5 * 1.2,
|
|
24
19
|
opacity: 0.6,
|
|
20
|
+
marginTop: 4,
|
|
25
21
|
},
|
|
26
22
|
headline: {
|
|
27
23
|
fontSize: FONT_SIZE.title,
|
|
@@ -33,4 +29,32 @@ export const storyStyles = (COLORS = {}, FONT_SIZE = {}) => ({
|
|
|
33
29
|
icon: {
|
|
34
30
|
marginLeft: 8,
|
|
35
31
|
},
|
|
32
|
+
storyTypeContainer: {
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
bottom: 0,
|
|
35
|
+
left: 0,
|
|
36
|
+
},
|
|
37
|
+
storyType: {
|
|
38
|
+
backgroundColor: COLORS.MONO1,
|
|
39
|
+
padding: 8,
|
|
40
|
+
justifyContent: 'space-between',
|
|
41
|
+
alignItems: 'space-between',
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
},
|
|
44
|
+
storyTypeText: {
|
|
45
|
+
color: COLORS.MONO7,
|
|
46
|
+
fontSize: FONT_SIZE.h5,
|
|
47
|
+
},
|
|
48
|
+
liveBlogText: {
|
|
49
|
+
color: COLORS.MONO7,
|
|
50
|
+
fontSize: FONT_SIZE.h4,
|
|
51
|
+
marginLeft: 10,
|
|
52
|
+
fontWeight: 'bold',
|
|
53
|
+
},
|
|
54
|
+
liveBlogIcon: {
|
|
55
|
+
height: 15,
|
|
56
|
+
width: 15,
|
|
57
|
+
borderRadius: 50,
|
|
58
|
+
backgroundColor: COLORS.BRAND_3,
|
|
59
|
+
},
|
|
36
60
|
});
|
|
@@ -1,22 +1,37 @@
|
|
|
1
|
-
import React, { useContext } from
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
2
|
import {
|
|
3
|
-
StyleSheet,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
StyleSheet,
|
|
4
|
+
View,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
ViewPropTypes,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
import PropTypes from "prop-types";
|
|
9
|
+
import { radioButtonStyles } from "./styles";
|
|
10
|
+
import { AppTheme } from "../../utils";
|
|
11
|
+
|
|
12
|
+
import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants";
|
|
8
13
|
|
|
9
14
|
export const RadioButton = ({
|
|
10
|
-
onPress,
|
|
15
|
+
onPress,
|
|
16
|
+
isChecked,
|
|
17
|
+
circleStyle,
|
|
18
|
+
checkedCircleStyle,
|
|
11
19
|
}) => {
|
|
12
20
|
const { theme } = useContext(AppTheme);
|
|
13
21
|
const styles = radioButtonStyles(theme);
|
|
14
22
|
const circleBorderStyle = StyleSheet.flatten([styles.circle, circleStyle]);
|
|
15
|
-
const checkedStyle = StyleSheet.flatten([
|
|
23
|
+
const checkedStyle = StyleSheet.flatten([
|
|
24
|
+
styles.checkedCircle,
|
|
25
|
+
checkedCircleStyle,
|
|
26
|
+
]);
|
|
16
27
|
|
|
17
28
|
return (
|
|
18
29
|
<View>
|
|
19
|
-
<TouchableOpacity
|
|
30
|
+
<TouchableOpacity
|
|
31
|
+
style={circleBorderStyle}
|
|
32
|
+
onPress={onPress}
|
|
33
|
+
testID={COMP_GENERAL_CONSTANTS.radioButtonTouch}
|
|
34
|
+
>
|
|
20
35
|
{isChecked && <View style={checkedStyle} />}
|
|
21
36
|
</TouchableOpacity>
|
|
22
37
|
</View>
|
|
@@ -10,22 +10,31 @@ import {
|
|
|
10
10
|
TextStyle,
|
|
11
11
|
TouchableOpacityProps,
|
|
12
12
|
} from 'react-native';
|
|
13
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
13
14
|
import {
|
|
14
15
|
AppTheme,
|
|
15
16
|
getImageMetadata,
|
|
16
17
|
getImageSlug,
|
|
17
|
-
|
|
18
|
+
getTimeForStoryCards,
|
|
18
19
|
} from '../../utils';
|
|
19
20
|
import { getStoryHeadline } from '../../utils/story';
|
|
20
21
|
import { ResponsiveImage, Text } from '../index';
|
|
21
22
|
import { secStoryCardStyles } from './styles';
|
|
22
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
COMP_GENERAL_CONSTANTS,
|
|
25
|
+
COMP_CONTENT_CONSTANTS,
|
|
26
|
+
} from '../../constants/component-constants';
|
|
23
27
|
|
|
24
28
|
export const SecondaryStoryCard = (props) => {
|
|
25
29
|
const { theme } = useContext(AppTheme);
|
|
26
30
|
const translate = get(theme, ['translate'], (word) => word);
|
|
27
31
|
|
|
28
|
-
const {
|
|
32
|
+
const {
|
|
33
|
+
locale,
|
|
34
|
+
COLORS,
|
|
35
|
+
reverseTimeAdverbPosition,
|
|
36
|
+
enableReadTimeOnStoryCards,
|
|
37
|
+
} = theme;
|
|
29
38
|
const styles = secStoryCardStyles(theme);
|
|
30
39
|
const { story = {} } = props;
|
|
31
40
|
|
|
@@ -44,15 +53,43 @@ export const SecondaryStoryCard = (props) => {
|
|
|
44
53
|
props.dateTextStyle,
|
|
45
54
|
]);
|
|
46
55
|
const iconStyles = StyleSheet.flatten([styles.iconStyles, props.iconStyle]);
|
|
47
|
-
|
|
48
|
-
styles.authorTextContainer,
|
|
49
|
-
props.authorTextContainer,
|
|
50
|
-
]);
|
|
56
|
+
|
|
51
57
|
const name = get(story.authors, [0, 'name']);
|
|
52
58
|
const authorName = name ? `${translate('By')} ${name} | ` : '';
|
|
53
|
-
const readTime =
|
|
59
|
+
const readTime = enableReadTimeOnStoryCards && story['read-time']
|
|
60
|
+
? `${story['read-time']} ${translate('min read')}`
|
|
61
|
+
: '';
|
|
54
62
|
|
|
55
63
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
64
|
+
|
|
65
|
+
const showIcon = (name) => (
|
|
66
|
+
<View style={styles.storyType}>
|
|
67
|
+
<Icon name={name} size={14} color={COLORS.MONO7} />
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const showLiveBlogIcon = () => (
|
|
72
|
+
<View style={styles.storyType}>
|
|
73
|
+
<View style={styles.liveBlogIcon} />
|
|
74
|
+
<Text style={styles.liveBlogText}>LIVE</Text>
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const showStoryType = () => {
|
|
79
|
+
switch (story['story-template']) {
|
|
80
|
+
case 'text':
|
|
81
|
+
return null;
|
|
82
|
+
case 'photo':
|
|
83
|
+
return showIcon('photo');
|
|
84
|
+
case 'video':
|
|
85
|
+
return showIcon('play');
|
|
86
|
+
case 'live-blog':
|
|
87
|
+
return showLiveBlogIcon();
|
|
88
|
+
default:
|
|
89
|
+
null;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
56
93
|
return (
|
|
57
94
|
<TouchableOpacity
|
|
58
95
|
testID={COMP_GENERAL_CONSTANTS.secondaryStoryCard}
|
|
@@ -73,6 +110,7 @@ export const SecondaryStoryCard = (props) => {
|
|
|
73
110
|
</View>
|
|
74
111
|
)}
|
|
75
112
|
</Text>
|
|
113
|
+
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
76
114
|
</ResponsiveImage>
|
|
77
115
|
<View style={styles.headlineAndAuthorBlockContainer}>
|
|
78
116
|
<Text
|
|
@@ -85,20 +123,20 @@ export const SecondaryStoryCard = (props) => {
|
|
|
85
123
|
{getStoryHeadline(story)?.trim()}
|
|
86
124
|
</Text>
|
|
87
125
|
<View style={styles.authorAndIconContainer}>
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</
|
|
126
|
+
<Text
|
|
127
|
+
style={authorTextStyle}
|
|
128
|
+
numberOfLines={2}
|
|
129
|
+
testID={COMP_CONTENT_CONSTANTS.authorName}
|
|
130
|
+
>
|
|
131
|
+
{authorName
|
|
132
|
+
+ getTimeForStoryCards(
|
|
133
|
+
story['published-at'],
|
|
134
|
+
DATE_FORMAT,
|
|
135
|
+
locale,
|
|
136
|
+
translate,
|
|
137
|
+
reverseTimeAdverbPosition,
|
|
138
|
+
)}
|
|
139
|
+
</Text>
|
|
102
140
|
<View style={iconStyles}>{props.iconComponent}</View>
|
|
103
141
|
</View>
|
|
104
142
|
</View>
|
|
@@ -22,10 +22,7 @@ export const secStoryCardStyles = ({ COLORS, FONT_SIZE, DARK_MODE }) => StyleShe
|
|
|
22
22
|
lineHeight: FONT_SIZE.h6 * 1.3,
|
|
23
23
|
opacity: 0.5,
|
|
24
24
|
fontWeight: '500',
|
|
25
|
-
|
|
26
|
-
authorTextContainer: {
|
|
27
|
-
alignItems: 'center',
|
|
28
|
-
flexDirection: 'row',
|
|
25
|
+
paddingTop: 8,
|
|
29
26
|
},
|
|
30
27
|
headline: {
|
|
31
28
|
color: COLORS.BRAND_BLACK,
|
|
@@ -51,4 +48,32 @@ export const secStoryCardStyles = ({ COLORS, FONT_SIZE, DARK_MODE }) => StyleShe
|
|
|
51
48
|
color: COLORS.BRAND_BLACK,
|
|
52
49
|
fontSize: FONT_SIZE.h5,
|
|
53
50
|
},
|
|
51
|
+
storyTypeContainer: {
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
backgroundColor: COLORS.MONO1,
|
|
54
|
+
bottom: 0,
|
|
55
|
+
left: 0,
|
|
56
|
+
},
|
|
57
|
+
storyType: {
|
|
58
|
+
padding: 5,
|
|
59
|
+
justifyContent: 'space-between',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
flexDirection: 'row',
|
|
62
|
+
},
|
|
63
|
+
storyTypeText: {
|
|
64
|
+
color: COLORS.MONO7,
|
|
65
|
+
fontSize: FONT_SIZE.h5,
|
|
66
|
+
},
|
|
67
|
+
liveBlogText: {
|
|
68
|
+
color: COLORS.MONO7,
|
|
69
|
+
fontSize: FONT_SIZE.h5,
|
|
70
|
+
marginLeft: 4,
|
|
71
|
+
fontWeight: 'bold',
|
|
72
|
+
},
|
|
73
|
+
liveBlogIcon: {
|
|
74
|
+
height: 12,
|
|
75
|
+
width: 12,
|
|
76
|
+
borderRadius: 50,
|
|
77
|
+
backgroundColor: COLORS.BRAND_3,
|
|
78
|
+
},
|
|
54
79
|
});
|