@quintype/native-components 2.19.0 → 2.19.5
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 +30 -0
- package/package.json +5 -5
- package/src/components/AlsoRead/index.js +5 -5
- package/src/components/AlsoRead/styles.js +4 -2
- package/src/components/AuthorRow/index.js +2 -2
- package/src/components/BackNavigator/styles.js +2 -0
- package/src/components/CollectionCard/index.js +14 -2
- package/src/components/CollectionTitle/index.js +10 -1
- package/src/components/CollectionTitle/styles.js +3 -5
- package/src/components/CustomSwitch/index.js +16 -9
- package/src/components/PrimaryStoryCard/index.js +39 -7
- package/src/components/PrimaryStoryCard/styles.js +32 -0
- package/src/components/PrimaryStoryCardNew/index.js +51 -15
- package/src/components/PrimaryStoryCardNew/styles.js +28 -0
- package/src/components/RelatedStoriesCard/index.js +9 -6
- package/src/components/RelatedStoriesCard/styles.js +3 -2
- package/src/components/SecondaryStoryCard/index.js +45 -6
- package/src/components/SecondaryStoryCard/styles.js +33 -4
- package/src/components/SecondaryStoryCardNew/index.js +52 -16
- package/src/components/SecondaryStoryCardNew/styles.js +28 -0
- package/src/components/StoryHeader/index.js +8 -10
- package/src/components/StoryText/index.js +3 -1
- package/src/components/Table/styles.js +4 -0
- package/src/components/TextQandA/styles.js +3 -4
- package/src/constants/component-constants/general-constants/constants.js +15 -14
- package/src/constants/renderHTML.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.19.5](https://github.com/quintype/native-components/compare/v2.19.3...v2.19.5) (2021-12-29)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **Navigator:** Fixed Section title text overflow :hammer: ([#176](https://github.com/quintype/native-components/issues/176)) ([249672b](https://github.com/quintype/native-components/commit/249672b44f6559190e930fc78a11d83a8e94c009))
|
|
11
|
+
|
|
12
|
+
### [2.19.3](https://github.com/quintype/native-components/compare/v2.18.4...v2.19.3) (2021-10-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **AlsoRead:** Changed dark-mode color for the text :hammer: ([#170](https://github.com/quintype/native-components/issues/170)) ([67f1e61](https://github.com/quintype/native-components/commit/67f1e61fd4b76ea6fa65f565006214981d0bb8a8))
|
|
18
|
+
* **AlsoRead:** Fixed card height :hammer: ([#174](https://github.com/quintype/native-components/issues/174)) ([6ce7a60](https://github.com/quintype/native-components/commit/6ce7a6078ec699f0f3df74d8136fc64070921caa))
|
|
19
|
+
* **old-UI:** Fixes all padding/image-aspect-ratio inconsistencies 🔨 ([#169](https://github.com/quintype/native-components/issues/169)) ([f3b8850](https://github.com/quintype/native-components/commit/f3b88507c02985ff83aadd266e0dbd04438fd441))
|
|
20
|
+
|
|
21
|
+
### [2.19.2](https://github.com/quintype/native-components/compare/v2.19.1...v2.19.2) (2021-10-19)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **AlsoRead:** Changed dark-mode color for the text :hammer: ([#170](https://github.com/quintype/native-components/issues/170)) ([67f1e61](https://github.com/quintype/native-components/commit/67f1e61fd4b76ea6fa65f565006214981d0bb8a8))
|
|
27
|
+
|
|
28
|
+
### [2.19.1](https://github.com/quintype/native-components/compare/v2.19.0...v2.19.1) (2021-10-07)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **old-UI:** Fixes all padding/image-aspect-ratio inconsistencies 🔨 ([#169](https://github.com/quintype/native-components/issues/169)) ([f3b8850](https://github.com/quintype/native-components/commit/f3b88507c02985ff83aadd266e0dbd04438fd441))
|
|
34
|
+
|
|
5
35
|
## [2.19.0](https://github.com/quintype/native-components/compare/v2.17.3...v2.19.0) (2021-10-06)
|
|
6
36
|
|
|
7
37
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/native-components",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"rn-fetch-blob": "^0.10.16"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
+
"@react-navigation/native": ">=5.7.3",
|
|
32
|
+
"lodash": ">=4.17.20",
|
|
31
33
|
"react": ">=16.13.1",
|
|
32
34
|
"react-native": ">=0.63.2",
|
|
33
35
|
"react-native-fast-image": ">=8.3.2",
|
|
34
|
-
"react-native-webview": ">=10.6.0",
|
|
35
36
|
"react-native-pdf": ">=6.2.0",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"lodash": ">=4.17.20"
|
|
37
|
+
"react-native-webview": ">=10.6.0",
|
|
38
|
+
"rn-fetch-blob": ">=0.12.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/core": "^7.11.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
-
import { View, TouchableOpacity
|
|
3
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
4
4
|
import { ResponsiveImage, Text } from '../index';
|
|
5
5
|
import { alsoReadStyles } from './styles';
|
|
6
6
|
import { FallbackIcon } from '../../Icons/FallBackIcon';
|
|
@@ -25,8 +25,8 @@ export const AlsoRead = (props) => {
|
|
|
25
25
|
const linkedImage = get(linkedStories, [linkedStoryId, 'hero-image-s3-key']);
|
|
26
26
|
|
|
27
27
|
const { theme } = useContext(AppTheme);
|
|
28
|
-
const { COLORS, FONT_SIZE, CustomFallBackIcon } = theme;
|
|
29
|
-
const styles = alsoReadStyles(COLORS, FONT_SIZE);
|
|
28
|
+
const { COLORS, FONT_SIZE, DARK_MODE, CustomFallBackIcon ,translate} = theme;
|
|
29
|
+
const styles = alsoReadStyles(COLORS, FONT_SIZE, DARK_MODE);
|
|
30
30
|
|
|
31
31
|
const fallBackIcon = CustomFallBackIcon ? <CustomFallBackIcon /> : <FallbackIcon />;
|
|
32
32
|
|
|
@@ -57,8 +57,8 @@ export const AlsoRead = (props) => {
|
|
|
57
57
|
<View style={styles.container}>
|
|
58
58
|
{getImageComponent()}
|
|
59
59
|
<View style={styles.alsoReadContentWrapper}>
|
|
60
|
-
<Text style={styles.alsoReadText}>Also Read</Text>
|
|
61
|
-
<Text primary numberOfLines={
|
|
60
|
+
<Text style={styles.alsoReadText}>{translate("Also Read")}</Text>
|
|
61
|
+
<Text primary numberOfLines={2} style={styles.alsoReadTitle}>
|
|
62
62
|
{text}
|
|
63
63
|
</Text>
|
|
64
64
|
</View>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
|
-
export const alsoReadStyles = (COLORS, FONT_SIZE) => StyleSheet.create({
|
|
3
|
+
export const alsoReadStyles = (COLORS, FONT_SIZE, DARK_MODE) => StyleSheet.create({
|
|
4
4
|
wrapper: {
|
|
5
5
|
padding: 10,
|
|
6
6
|
},
|
|
@@ -13,10 +13,12 @@ export const alsoReadStyles = (COLORS, FONT_SIZE) => StyleSheet.create({
|
|
|
13
13
|
},
|
|
14
14
|
alsoReadText: {
|
|
15
15
|
fontSize: FONT_SIZE.h2,
|
|
16
|
-
|
|
16
|
+
fontWeight: 'bold',
|
|
17
|
+
color: DARK_MODE ? COLORS.BRAND_BLACK : COLORS.BRAND_1,
|
|
17
18
|
},
|
|
18
19
|
alsoReadTitle: {
|
|
19
20
|
fontSize: FONT_SIZE.h2,
|
|
21
|
+
color: DARK_MODE ? COLORS.BRAND_BLACK : COLORS.BRAND_1,
|
|
20
22
|
},
|
|
21
23
|
fallBackImageWrapper: {
|
|
22
24
|
backgroundColor: COLORS.BRAND_WHITE,
|
|
@@ -20,7 +20,7 @@ export const AuthorRow = ({
|
|
|
20
20
|
disablePress,
|
|
21
21
|
}) => {
|
|
22
22
|
const { theme } = useContext(AppTheme);
|
|
23
|
-
const { COLORS } = theme;
|
|
23
|
+
const { COLORS ,translate} = theme;
|
|
24
24
|
const styles = authorRowStyleSheet(theme);
|
|
25
25
|
|
|
26
26
|
return (
|
|
@@ -69,7 +69,7 @@ export const AuthorRow = ({
|
|
|
69
69
|
})}
|
|
70
70
|
{readtime ? (
|
|
71
71
|
<View style={styles.readtimeComponent}>
|
|
72
|
-
<Text style={styles.readtime}>{`| ${readtime} min read`}</Text>
|
|
72
|
+
<Text style={styles.readtime}>{`| ${readtime} ${translate("min read")}`}</Text>
|
|
73
73
|
</View>
|
|
74
74
|
) : null}
|
|
75
75
|
</View>
|
|
@@ -6,6 +6,7 @@ export const backNavigatorStyles = (appThemeContext) => {
|
|
|
6
6
|
container: {
|
|
7
7
|
flexDirection: 'row',
|
|
8
8
|
justifyContent: 'flex-start',
|
|
9
|
+
marginRight: 20,
|
|
9
10
|
alignItems: 'center',
|
|
10
11
|
backgroundColor: DARK_MODE ? COLORS.MONO6 : COLORS.BRAND_WHITE,
|
|
11
12
|
},
|
|
@@ -29,6 +30,7 @@ export const backNavigatorStyles = (appThemeContext) => {
|
|
|
29
30
|
text: {
|
|
30
31
|
marginLeft: 10,
|
|
31
32
|
opacity: 0.9,
|
|
33
|
+
flexShrink: 1,
|
|
32
34
|
},
|
|
33
35
|
});
|
|
34
36
|
};
|
|
@@ -16,20 +16,26 @@ export const CollectionCard = ({
|
|
|
16
16
|
onCollectionPress,
|
|
17
17
|
onStoryPress,
|
|
18
18
|
offset,
|
|
19
|
+
horizontalPadding,
|
|
19
20
|
initialOffset /* Number of items to load on first load */,
|
|
20
21
|
}) => {
|
|
21
22
|
const sliceLimit = offset || initialOffset || 5;
|
|
22
23
|
const primaryStory = !isEmpty(stories) && get(stories, [0, 'story'], stories[0]);
|
|
23
24
|
return (
|
|
24
25
|
<>
|
|
25
|
-
<CollectionTitle
|
|
26
|
+
<CollectionTitle
|
|
27
|
+
title={collectionName}
|
|
28
|
+
onPress={onCollectionPress}
|
|
29
|
+
horizontalPadding={horizontalPadding}
|
|
30
|
+
/>
|
|
26
31
|
<PrimaryStoryCard
|
|
27
32
|
onPress={() => {
|
|
28
33
|
!isEmpty(stories) && onStoryPress(primaryStory);
|
|
29
34
|
}}
|
|
30
35
|
cdn={cdn}
|
|
31
36
|
story={!isEmpty(stories) ? primaryStory : {}}
|
|
32
|
-
imageWidth={getScreenPercentageWidth(100)}
|
|
37
|
+
imageWidth={getScreenPercentageWidth(100) - 2 * horizontalPadding}
|
|
38
|
+
horizontalPadding={horizontalPadding}
|
|
33
39
|
/>
|
|
34
40
|
{stories.slice(1, sliceLimit).map((currentStory) => {
|
|
35
41
|
const secondaryStory = get(currentStory, ['story'], currentStory);
|
|
@@ -40,6 +46,7 @@ export const CollectionCard = ({
|
|
|
40
46
|
cdn={cdn}
|
|
41
47
|
story={secondaryStory}
|
|
42
48
|
imageWidth={getScreenPercentageWidth(40)}
|
|
49
|
+
horizontalPadding={horizontalPadding}
|
|
43
50
|
/>
|
|
44
51
|
);
|
|
45
52
|
})}
|
|
@@ -54,4 +61,9 @@ CollectionCard.propTypes = {
|
|
|
54
61
|
onCollectionPress: PropTypes.func,
|
|
55
62
|
onStoryPress: PropTypes.func,
|
|
56
63
|
offset: PropTypes.number,
|
|
64
|
+
horizontalPadding: PropTypes.number,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
CollectionCard.defaultProps = {
|
|
68
|
+
horizontalPadding: 12,
|
|
57
69
|
};
|
|
@@ -18,6 +18,10 @@ import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/gene
|
|
|
18
18
|
export const CollectionTitle = (props) => {
|
|
19
19
|
const { theme } = useContext(AppTheme);
|
|
20
20
|
const styles = collectionStyles(theme);
|
|
21
|
+
const containerStyle = StyleSheet.flatten([
|
|
22
|
+
styles.titleContainer,
|
|
23
|
+
{ paddingHorizontal: props.horizontalPadding },
|
|
24
|
+
]);
|
|
21
25
|
const titleStyle = StyleSheet.flatten([styles.titleStyle, props.titleStyle]);
|
|
22
26
|
const indicatorStyle = StyleSheet.flatten([
|
|
23
27
|
styles.indicatorStyle,
|
|
@@ -30,7 +34,7 @@ export const CollectionTitle = (props) => {
|
|
|
30
34
|
|
|
31
35
|
return (
|
|
32
36
|
<TouchableOpacity
|
|
33
|
-
style={
|
|
37
|
+
style={containerStyle}
|
|
34
38
|
onPress={props.onPress}
|
|
35
39
|
testID={COMP_GENERAL_CONSTANTS.collectionTitleTouch}
|
|
36
40
|
>
|
|
@@ -49,4 +53,9 @@ CollectionTitle.propTypes = TouchableOpacityProps && {
|
|
|
49
53
|
title: PropTypes.string,
|
|
50
54
|
titleStyle: TextStyle,
|
|
51
55
|
indicatorStyle: ViewStyle,
|
|
56
|
+
horizontalPadding: PropTypes.number,
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
CollectionTitle.defaultProps = {
|
|
60
|
+
horizontalPadding: 12,
|
|
52
61
|
};
|
|
@@ -4,18 +4,16 @@ export const collectionStyles = (appThemeContext) => {
|
|
|
4
4
|
const { COLORS, FONT_SIZE } = appThemeContext;
|
|
5
5
|
return StyleSheet.create({
|
|
6
6
|
titleContainer: {
|
|
7
|
-
|
|
7
|
+
backgroundColor: COLORS.BRAND_WHITE,
|
|
8
|
+
paddingVertical: 12,
|
|
8
9
|
justifyContent: 'center',
|
|
9
|
-
marginBottom: 10,
|
|
10
10
|
},
|
|
11
11
|
titleStyle: {
|
|
12
12
|
fontSize: FONT_SIZE.h1,
|
|
13
13
|
color: COLORS.BRAND_5,
|
|
14
14
|
},
|
|
15
15
|
indicatorStyle: {
|
|
16
|
-
|
|
17
|
-
left: 0,
|
|
18
|
-
bottom: 0,
|
|
16
|
+
marginTop: 8,
|
|
19
17
|
width: 30,
|
|
20
18
|
height: 3,
|
|
21
19
|
backgroundColor: COLORS.BRAND_1,
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import React, { useContext, useState } from
|
|
2
|
-
import { Switch, View } from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import Icon from
|
|
5
|
-
import { Text } from
|
|
6
|
-
import { AppTheme } from
|
|
7
|
-
import { customSwitchStyles } from
|
|
1
|
+
import React, { useContext, useState } from "react";
|
|
2
|
+
import { Switch, View } from "react-native";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import Icon from "react-native-vector-icons/FontAwesome";
|
|
5
|
+
import { Text } from "../Text";
|
|
6
|
+
import { AppTheme } from "../../utils";
|
|
7
|
+
import { customSwitchStyles } from "./styles";
|
|
8
|
+
import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
|
|
8
9
|
|
|
9
10
|
export const CustomSwitch = ({
|
|
10
|
-
label =
|
|
11
|
+
label = "",
|
|
12
|
+
callback,
|
|
13
|
+
isEnabled = true,
|
|
14
|
+
iconSize = 20,
|
|
15
|
+
iconName,
|
|
16
|
+
isSwitchDisabled = false,
|
|
11
17
|
}) => {
|
|
12
18
|
const { theme } = useContext(AppTheme);
|
|
13
19
|
const { COLORS } = theme;
|
|
14
20
|
const styles = customSwitchStyles();
|
|
15
21
|
const handleToggle = () => {
|
|
16
|
-
typeof callback ===
|
|
22
|
+
typeof callback === "function" && callback(!isEnabled);
|
|
17
23
|
};
|
|
18
24
|
|
|
19
25
|
return (
|
|
@@ -34,6 +40,7 @@ export const CustomSwitch = ({
|
|
|
34
40
|
onValueChange={handleToggle}
|
|
35
41
|
value={isEnabled}
|
|
36
42
|
disabled={isSwitchDisabled}
|
|
43
|
+
testID={COMP_GENERAL_CONSTANTS.customSwitch}
|
|
37
44
|
/>
|
|
38
45
|
</View>
|
|
39
46
|
);
|
|
@@ -3,9 +3,9 @@ import get from 'lodash/get';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { useContext } from 'react';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
StyleSheet, TouchableOpacity, View,
|
|
7
7
|
} from 'react-native';
|
|
8
|
-
|
|
8
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
9
9
|
import {
|
|
10
10
|
AppTheme,
|
|
11
11
|
getImageMetadata,
|
|
@@ -25,10 +25,13 @@ export const PrimaryStoryCard = (props) => {
|
|
|
25
25
|
|
|
26
26
|
const { COLORS, FONT_SIZE, locale } = theme || {};
|
|
27
27
|
|
|
28
|
-
const DATE_FORMAT =
|
|
28
|
+
const DATE_FORMAT = 'd MMM, yyyy';
|
|
29
29
|
|
|
30
30
|
const styles = storyStyles(COLORS, FONT_SIZE);
|
|
31
|
-
|
|
31
|
+
const containerStyle = StyleSheet.flatten([
|
|
32
|
+
styles.container,
|
|
33
|
+
{ paddingHorizontal: props.horizontalPadding },
|
|
34
|
+
]);
|
|
32
35
|
const headlineStyle = StyleSheet.flatten([
|
|
33
36
|
styles.headline,
|
|
34
37
|
props.headlineStyle,
|
|
@@ -40,31 +43,58 @@ export const PrimaryStoryCard = (props) => {
|
|
|
40
43
|
|
|
41
44
|
const name = get(story.authors, [0, 'name']);
|
|
42
45
|
const authorName = name ? `${translate('By')} ${name} | ` : '';
|
|
43
|
-
const readTime = story['read-time'] ? `${story['read-time']} min read` : '';
|
|
46
|
+
const readTime = story['read-time'] ? `${story['read-time']} ${translate('min read')}` : '';
|
|
44
47
|
|
|
45
48
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
46
49
|
|
|
50
|
+
const showIcon = (name) => (
|
|
51
|
+
<View style={styles.storyType}>
|
|
52
|
+
<Icon name={name} size={22} color={COLORS.MONO7} />
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const showLiveBlogIcon = () => (
|
|
57
|
+
<View style={styles.storyType}>
|
|
58
|
+
<View style={styles.liveBlogIcon} />
|
|
59
|
+
<Text style={styles.liveBlogText}>LIVE</Text>
|
|
60
|
+
</View>
|
|
61
|
+
);
|
|
62
|
+
const showStoryType = () => {
|
|
63
|
+
switch (story['story-template']) {
|
|
64
|
+
case 'text':
|
|
65
|
+
return null;
|
|
66
|
+
case 'photo':
|
|
67
|
+
return showIcon('photo');
|
|
68
|
+
case 'video':
|
|
69
|
+
return showIcon('play');
|
|
70
|
+
case 'live-blog':
|
|
71
|
+
return showLiveBlogIcon();
|
|
72
|
+
default:
|
|
73
|
+
null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
47
77
|
return (
|
|
48
78
|
<TouchableOpacity
|
|
49
79
|
testID={COMP_GENERAL_CONSTANTS.primaryStoryCard}
|
|
50
80
|
onPress={throttledOnpress}
|
|
51
81
|
activeOpacity={0.8}
|
|
82
|
+
style={containerStyle}
|
|
52
83
|
>
|
|
53
84
|
<ResponsiveImage
|
|
54
85
|
metaData={getImageMetadata(story)}
|
|
55
86
|
slug={getImageSlug(story)}
|
|
56
87
|
cdn={props.cdn}
|
|
57
88
|
imageWidth={props.imageWidth}
|
|
58
|
-
hero
|
|
59
89
|
>
|
|
60
90
|
<Text style={styles.xminContainer}>
|
|
61
|
-
{' '}
|
|
62
91
|
{readTime && (
|
|
63
92
|
<View style={styles.xmin}>
|
|
64
93
|
<Text style={styles.xminText}>{readTime}</Text>
|
|
65
94
|
</View>
|
|
66
95
|
)}
|
|
67
96
|
</Text>
|
|
97
|
+
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
68
98
|
</ResponsiveImage>
|
|
69
99
|
|
|
70
100
|
<View style={styles.authorBlockContainer}>
|
|
@@ -101,8 +131,10 @@ PrimaryStoryCard.propTypes = {
|
|
|
101
131
|
authorTextStyle: PropTypes.func,
|
|
102
132
|
story: PropTypes.object.isRequired,
|
|
103
133
|
onPress: PropTypes.func,
|
|
134
|
+
horizontalPadding: PropTypes.number,
|
|
104
135
|
};
|
|
105
136
|
|
|
106
137
|
PrimaryStoryCard.defaultProps = {
|
|
107
138
|
cdn: '',
|
|
139
|
+
horizontalPadding: 12,
|
|
108
140
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const storyStyles = (COLORS = {}, FONT_SIZE = {}, DARK_MODE = {}) => ({
|
|
2
|
+
container: {
|
|
3
|
+
backgroundColor: COLORS.BRAND_WHITE,
|
|
4
|
+
marginTop: 12,
|
|
5
|
+
},
|
|
2
6
|
authorBlockContainer: {
|
|
3
7
|
alignItems: 'center',
|
|
4
8
|
flexDirection: 'row',
|
|
@@ -35,4 +39,32 @@ export const storyStyles = (COLORS = {}, FONT_SIZE = {}, DARK_MODE = {}) => ({
|
|
|
35
39
|
color: COLORS.BRAND_BLACK,
|
|
36
40
|
fontSize: FONT_SIZE.h5,
|
|
37
41
|
},
|
|
42
|
+
storyTypeContainer: {
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
bottom: 0,
|
|
45
|
+
left: 0,
|
|
46
|
+
},
|
|
47
|
+
storyType: {
|
|
48
|
+
backgroundColor: COLORS.MONO1,
|
|
49
|
+
padding: 8,
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
alignItems: 'space-between',
|
|
52
|
+
flexDirection: 'row',
|
|
53
|
+
},
|
|
54
|
+
storyTypeText: {
|
|
55
|
+
color: COLORS.MONO7,
|
|
56
|
+
fontSize: FONT_SIZE.h5,
|
|
57
|
+
},
|
|
58
|
+
liveBlogText: {
|
|
59
|
+
color: COLORS.MONO7,
|
|
60
|
+
fontSize: FONT_SIZE.h4,
|
|
61
|
+
marginLeft: 10,
|
|
62
|
+
fontWeight: 'bold',
|
|
63
|
+
},
|
|
64
|
+
liveBlogIcon: {
|
|
65
|
+
height: 15,
|
|
66
|
+
width: 15,
|
|
67
|
+
borderRadius: 50,
|
|
68
|
+
backgroundColor: COLORS.BRAND_3,
|
|
69
|
+
},
|
|
38
70
|
});
|
|
@@ -1,25 +1,30 @@
|
|
|
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,
|
|
10
9
|
getImageSlug,
|
|
11
10
|
getTimeForStoryCards,
|
|
12
|
-
} from
|
|
13
|
-
import { getStoryHeadline } from
|
|
14
|
-
import { ResponsiveImage, Text } from
|
|
15
|
-
import { storyStyles } from
|
|
11
|
+
} from "../../utils";
|
|
12
|
+
import { getStoryHeadline } from "../../utils/story";
|
|
13
|
+
import { ResponsiveImage, Text } from "../index";
|
|
14
|
+
import { storyStyles } from "./styles";
|
|
15
|
+
|
|
16
|
+
|
|
16
17
|
|
|
17
18
|
const PrimaryStoryCardNewBase = (props) => {
|
|
18
19
|
const { story = {} } = props;
|
|
19
20
|
const { theme } = useContext(AppTheme);
|
|
20
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
COLORS, FONT_SIZE, locale, DARK_MODE,
|
|
23
|
+
} = theme || {};
|
|
24
|
+
|
|
25
|
+
const translate = get(theme, ["translate"], (word) => word);
|
|
21
26
|
|
|
22
|
-
const styles = storyStyles(COLORS, FONT_SIZE);
|
|
27
|
+
const styles = storyStyles(COLORS, FONT_SIZE, DARK_MODE);
|
|
23
28
|
const containerStyle = StyleSheet.flatten([
|
|
24
29
|
styles.container,
|
|
25
30
|
{ paddingHorizontal: props.horizontalPadding },
|
|
@@ -33,11 +38,40 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
33
38
|
props.timestampStyle,
|
|
34
39
|
]);
|
|
35
40
|
|
|
36
|
-
const DATE_FORMAT =
|
|
37
|
-
const readTime = story[
|
|
41
|
+
const DATE_FORMAT = "d MMM, yyyy";
|
|
42
|
+
const readTime = story["read-time"]
|
|
43
|
+
? `${story["read-time"]} ${translate("min read")}`
|
|
44
|
+
: "";
|
|
38
45
|
|
|
39
46
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
40
47
|
|
|
48
|
+
const showIcon = (name) => (
|
|
49
|
+
<View style={styles.storyType}>
|
|
50
|
+
<Icon name={name} size={22} color={COLORS.BRAND_BLACK} />
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const showLiveBlogIcon = () => (
|
|
55
|
+
<View style={styles.storyType}>
|
|
56
|
+
<View style={styles.liveBlogIcon} />
|
|
57
|
+
<Text style={styles.liveBlogText}>LIVE</Text>
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
const showStoryType = () => {
|
|
61
|
+
switch (story['story-template']) {
|
|
62
|
+
case 'text':
|
|
63
|
+
return null;
|
|
64
|
+
case 'photo':
|
|
65
|
+
return showIcon('photo');
|
|
66
|
+
case 'video':
|
|
67
|
+
return showIcon('play');
|
|
68
|
+
case 'live-blog':
|
|
69
|
+
return showLiveBlogIcon();
|
|
70
|
+
default:
|
|
71
|
+
null;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
41
75
|
return (
|
|
42
76
|
<TouchableOpacity
|
|
43
77
|
testID="primaryStoryCardView"
|
|
@@ -50,7 +84,9 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
50
84
|
slug={getImageSlug(story)}
|
|
51
85
|
cdn={props.cdn}
|
|
52
86
|
imageWidth={props.imageWidth}
|
|
53
|
-
|
|
87
|
+
>
|
|
88
|
+
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
89
|
+
</ResponsiveImage>
|
|
54
90
|
<View style={styles.contentContainer}>
|
|
55
91
|
<View style={styles.headlineAndTimestampContainer}>
|
|
56
92
|
<Text
|
|
@@ -67,7 +103,7 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
67
103
|
<Text style={timestampStyle}>{`${readTime} · `}</Text>
|
|
68
104
|
) : null}
|
|
69
105
|
<Text style={timestampStyle} testID="primaryStoryCardDate">
|
|
70
|
-
{getTimeForStoryCards(story[
|
|
106
|
+
{getTimeForStoryCards(story["published-at"], DATE_FORMAT, locale)}
|
|
71
107
|
</Text>
|
|
72
108
|
</View>
|
|
73
109
|
</View>
|
|
@@ -89,7 +125,7 @@ PrimaryStoryCardNewBase.propTypes = {
|
|
|
89
125
|
};
|
|
90
126
|
|
|
91
127
|
PrimaryStoryCardNewBase.defaultProps = {
|
|
92
|
-
cdn:
|
|
128
|
+
cdn: "",
|
|
93
129
|
horizontalPadding: 12,
|
|
94
130
|
};
|
|
95
131
|
|
|
@@ -33,4 +33,32 @@ export const storyStyles = (COLORS = {}, FONT_SIZE = {}) => ({
|
|
|
33
33
|
icon: {
|
|
34
34
|
marginLeft: 8,
|
|
35
35
|
},
|
|
36
|
+
storyTypeContainer: {
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
bottom: 0,
|
|
39
|
+
left: 0,
|
|
40
|
+
},
|
|
41
|
+
storyType: {
|
|
42
|
+
backgroundColor: COLORS.MONO1,
|
|
43
|
+
padding: 8,
|
|
44
|
+
justifyContent: 'space-between',
|
|
45
|
+
alignItems: 'space-between',
|
|
46
|
+
flexDirection: 'row',
|
|
47
|
+
},
|
|
48
|
+
storyTypeText: {
|
|
49
|
+
color: COLORS.MONO7,
|
|
50
|
+
fontSize: FONT_SIZE.h5,
|
|
51
|
+
},
|
|
52
|
+
liveBlogText: {
|
|
53
|
+
color: COLORS.MONO7,
|
|
54
|
+
fontSize: FONT_SIZE.h4,
|
|
55
|
+
marginLeft: 10,
|
|
56
|
+
fontWeight: 'bold',
|
|
57
|
+
},
|
|
58
|
+
liveBlogIcon: {
|
|
59
|
+
height: 15,
|
|
60
|
+
width: 15,
|
|
61
|
+
borderRadius: 50,
|
|
62
|
+
backgroundColor: COLORS.BRAND_3,
|
|
63
|
+
},
|
|
36
64
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { useContext } from 'react';
|
|
4
|
-
import { Text, View } from 'react-native';
|
|
4
|
+
import { Text, View ,I18nManager} from 'react-native';
|
|
5
5
|
import { getScreenPercentageWidth, AppTheme } from '../../utils/index';
|
|
6
6
|
import { SecondaryStoryCard, SecondaryStoryCardNew, ShareButton } from '../index';
|
|
7
7
|
|
|
@@ -13,13 +13,16 @@ export const RelatedStoriesCard = ({
|
|
|
13
13
|
cdn,
|
|
14
14
|
stories,
|
|
15
15
|
onStoryPress,
|
|
16
|
-
|
|
16
|
+
collectionTestID,
|
|
17
17
|
RelatedCardID,
|
|
18
|
+
title,
|
|
19
|
+
switchToNewDesign,
|
|
18
20
|
}) => {
|
|
19
21
|
const sliceLimit = 5;
|
|
20
22
|
|
|
21
23
|
const { theme } = useContext(AppTheme);
|
|
22
24
|
const styles = relatedStoriesStyles(theme);
|
|
25
|
+
const titleText = I18nManager.isRTL ? `\u200F${title}` : title;
|
|
23
26
|
|
|
24
27
|
return (
|
|
25
28
|
<>
|
|
@@ -27,9 +30,7 @@ export const RelatedStoriesCard = ({
|
|
|
27
30
|
style={styles.titleStyle}
|
|
28
31
|
testID={COMP_CONTENT_CONSTANTS.relatedStoriesLabel}
|
|
29
32
|
>
|
|
30
|
-
{
|
|
31
|
-
Related Stories
|
|
32
|
-
{' '}
|
|
33
|
+
{titleText}
|
|
33
34
|
</Text>
|
|
34
35
|
<View style={styles.relatedStoriesContainer} testID={RelatedCardID}>
|
|
35
36
|
{stories.slice(0, sliceLimit).map((currentStory) => {
|
|
@@ -62,6 +63,8 @@ RelatedStoriesCard.propTypes = {
|
|
|
62
63
|
cdn: PropTypes.string.isRequired,
|
|
63
64
|
stories: PropTypes.array.isRequired,
|
|
64
65
|
onStoryPress: PropTypes.func,
|
|
65
|
-
|
|
66
|
+
collectionTestID: PropTypes.string,
|
|
66
67
|
RelatedCardID: PropTypes.string,
|
|
68
|
+
title:PropTypes.string,
|
|
69
|
+
switchToNewDesign: PropTypes.bool,
|
|
67
70
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
1
|
+
import { StyleSheet,I18nManager } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export const relatedStoriesStyles = (appThemeContext) => {
|
|
4
4
|
const { COLORS, FONT_SIZE } = appThemeContext;
|
|
@@ -7,7 +7,8 @@ export const relatedStoriesStyles = (appThemeContext) => {
|
|
|
7
7
|
fontSize: FONT_SIZE.title,
|
|
8
8
|
fontWeight: 'bold',
|
|
9
9
|
color: COLORS.BRAND_BLACK,
|
|
10
|
-
|
|
10
|
+
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
11
|
+
paddingHorizontal:5,
|
|
11
12
|
marginVertical: 8,
|
|
12
13
|
},
|
|
13
14
|
relatedStoriesContainer: {
|
|
@@ -3,7 +3,6 @@ import get from 'lodash/get';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React, { useContext } from 'react';
|
|
5
5
|
import {
|
|
6
|
-
I18nManager,
|
|
7
6
|
Image,
|
|
8
7
|
StyleSheet,
|
|
9
8
|
TouchableOpacity,
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
TextStyle,
|
|
12
11
|
TouchableOpacityProps,
|
|
13
12
|
} from 'react-native';
|
|
13
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
14
14
|
import {
|
|
15
15
|
AppTheme,
|
|
16
16
|
getImageMetadata,
|
|
@@ -26,12 +26,16 @@ export const SecondaryStoryCard = (props) => {
|
|
|
26
26
|
const { theme } = useContext(AppTheme);
|
|
27
27
|
const translate = get(theme, ['translate'], (word) => word);
|
|
28
28
|
|
|
29
|
-
const { locale } = theme;
|
|
29
|
+
const { locale, COLORS } = theme;
|
|
30
30
|
const styles = secStoryCardStyles(theme);
|
|
31
31
|
const { story = {} } = props;
|
|
32
32
|
|
|
33
|
-
const DATE_FORMAT =
|
|
33
|
+
const DATE_FORMAT = 'd MMM, yyyy';
|
|
34
34
|
|
|
35
|
+
const containerStyle = StyleSheet.flatten([
|
|
36
|
+
styles.container,
|
|
37
|
+
{ paddingHorizontal: props.horizontalPadding },
|
|
38
|
+
]);
|
|
35
39
|
const headlineStyle = StyleSheet.flatten([
|
|
36
40
|
styles.headline,
|
|
37
41
|
props.headlineStyle,
|
|
@@ -47,15 +51,44 @@ export const SecondaryStoryCard = (props) => {
|
|
|
47
51
|
]);
|
|
48
52
|
const name = get(story.authors, [0, 'name']);
|
|
49
53
|
const authorName = name ? `${translate('By')} ${name} | ` : '';
|
|
50
|
-
const readTime = story['read-time'] ? `${story['read-time']} min read` : '';
|
|
54
|
+
const readTime = story['read-time'] ? `${story['read-time']} ${translate('min read')}` : '';
|
|
51
55
|
|
|
52
56
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
57
|
+
|
|
58
|
+
const showIcon = (name) => (
|
|
59
|
+
<View style={styles.storyType}>
|
|
60
|
+
<Icon name={name} size={14} color={COLORS.MONO7} />
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const showLiveBlogIcon = () => (
|
|
65
|
+
<View style={styles.storyType}>
|
|
66
|
+
<View style={styles.liveBlogIcon} />
|
|
67
|
+
<Text style={styles.liveBlogText}>LIVE</Text>
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
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
|
+
|
|
53
86
|
return (
|
|
54
87
|
<TouchableOpacity
|
|
55
88
|
testID={COMP_GENERAL_CONSTANTS.secondaryStoryCard}
|
|
56
89
|
onPress={throttledOnpress}
|
|
57
90
|
activeOpacity={0.8}
|
|
58
|
-
style={
|
|
91
|
+
style={containerStyle}
|
|
59
92
|
>
|
|
60
93
|
<ResponsiveImage
|
|
61
94
|
metaData={getImageMetadata(story)}
|
|
@@ -64,13 +97,13 @@ export const SecondaryStoryCard = (props) => {
|
|
|
64
97
|
imageWidth={props.imageWidth}
|
|
65
98
|
>
|
|
66
99
|
<Text style={styles.xminContainer}>
|
|
67
|
-
{' '}
|
|
68
100
|
{readTime && (
|
|
69
101
|
<View style={styles.xmin}>
|
|
70
102
|
<Text style={styles.xminText}>{readTime}</Text>
|
|
71
103
|
</View>
|
|
72
104
|
)}
|
|
73
105
|
</Text>
|
|
106
|
+
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
74
107
|
</ResponsiveImage>
|
|
75
108
|
<View style={styles.headlineAndAuthorBlockContainer}>
|
|
76
109
|
<Text
|
|
@@ -112,4 +145,10 @@ SecondaryStoryCard.propTypes = TouchableOpacityProps && {
|
|
|
112
145
|
dateTextStyle: TextStyle,
|
|
113
146
|
story: PropTypes.any.isRequired,
|
|
114
147
|
iconComponent: PropTypes.element,
|
|
148
|
+
horizontalPadding: PropTypes.number,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
SecondaryStoryCard.defaultProps = {
|
|
152
|
+
cdn: '',
|
|
153
|
+
horizontalPadding: 12,
|
|
115
154
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export const secStoryCardStyles = ({ COLORS, FONT_SIZE, DARK_MODE }) => StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
backgroundColor: COLORS.BRAND_WHITE,
|
|
7
|
+
paddingVertical: 15,
|
|
8
|
+
},
|
|
4
9
|
headlineAndAuthorBlockContainer: {
|
|
5
10
|
flexShrink: 1,
|
|
6
11
|
flex: 1,
|
|
@@ -22,10 +27,6 @@ export const secStoryCardStyles = ({ COLORS, FONT_SIZE, DARK_MODE }) => StyleShe
|
|
|
22
27
|
alignItems: 'center',
|
|
23
28
|
flexDirection: 'row',
|
|
24
29
|
},
|
|
25
|
-
blockContainer: {
|
|
26
|
-
flexDirection: 'row',
|
|
27
|
-
paddingVertical: 15,
|
|
28
|
-
},
|
|
29
30
|
headline: {
|
|
30
31
|
color: COLORS.BRAND_BLACK,
|
|
31
32
|
opacity: 0.9,
|
|
@@ -50,4 +51,32 @@ export const secStoryCardStyles = ({ COLORS, FONT_SIZE, DARK_MODE }) => StyleShe
|
|
|
50
51
|
color: COLORS.BRAND_BLACK,
|
|
51
52
|
fontSize: FONT_SIZE.h5,
|
|
52
53
|
},
|
|
54
|
+
storyTypeContainer: {
|
|
55
|
+
position: 'absolute',
|
|
56
|
+
backgroundColor: COLORS.MONO1,
|
|
57
|
+
bottom: 0,
|
|
58
|
+
left: 0,
|
|
59
|
+
},
|
|
60
|
+
storyType: {
|
|
61
|
+
padding: 5,
|
|
62
|
+
justifyContent: 'space-between',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
flexDirection: 'row',
|
|
65
|
+
},
|
|
66
|
+
storyTypeText: {
|
|
67
|
+
color: COLORS.MONO7,
|
|
68
|
+
fontSize: FONT_SIZE.h5,
|
|
69
|
+
},
|
|
70
|
+
liveBlogText: {
|
|
71
|
+
color: COLORS.MONO7,
|
|
72
|
+
fontSize: FONT_SIZE.h5,
|
|
73
|
+
marginLeft: 4,
|
|
74
|
+
fontWeight: 'bold',
|
|
75
|
+
},
|
|
76
|
+
liveBlogIcon: {
|
|
77
|
+
height: 12,
|
|
78
|
+
width: 12,
|
|
79
|
+
borderRadius: 50,
|
|
80
|
+
backgroundColor: COLORS.BRAND_3,
|
|
81
|
+
},
|
|
53
82
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { throttle } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React, { useContext, memo } from
|
|
1
|
+
import { get, throttle } from "lodash";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React, { useContext, memo } from "react";
|
|
4
4
|
import {
|
|
5
5
|
I18nManager,
|
|
6
6
|
StyleSheet,
|
|
@@ -9,22 +9,25 @@ import {
|
|
|
9
9
|
TextStyle,
|
|
10
10
|
TouchableOpacityProps,
|
|
11
11
|
} from 'react-native';
|
|
12
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
12
13
|
import {
|
|
13
14
|
AppTheme,
|
|
14
15
|
getImageMetadata,
|
|
15
16
|
getImageSlug,
|
|
16
17
|
getTimeForStoryCards,
|
|
17
|
-
} from
|
|
18
|
-
import { getStoryHeadline } from
|
|
19
|
-
import { ResponsiveImage, Text } from
|
|
20
|
-
import { storyStyles } from
|
|
18
|
+
} from "../../utils";
|
|
19
|
+
import { getStoryHeadline } from "../../utils/story";
|
|
20
|
+
import { ResponsiveImage, Text } from "../index";
|
|
21
|
+
import { storyStyles } from "./styles";
|
|
21
22
|
|
|
22
23
|
const SecondaryStoryCardNewBase = (props) => {
|
|
23
24
|
const { story = {} } = props;
|
|
24
25
|
const { theme } = useContext(AppTheme);
|
|
25
|
-
const { locale } = theme;
|
|
26
|
+
const { locale, DARK_MODE, COLORS } = theme;
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
+
const translate = get(theme, ["translate"], (word) => word);
|
|
29
|
+
|
|
30
|
+
const styles = storyStyles(theme, DARK_MODE);
|
|
28
31
|
const containerStyle = StyleSheet.flatten([
|
|
29
32
|
styles.container,
|
|
30
33
|
{ paddingHorizontal: props.horizontalPadding },
|
|
@@ -38,10 +41,41 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
38
41
|
props.timestampStyle,
|
|
39
42
|
]);
|
|
40
43
|
|
|
41
|
-
const DATE_FORMAT =
|
|
42
|
-
const readTime = story[
|
|
44
|
+
const DATE_FORMAT = "d MMM, yyyy";
|
|
45
|
+
const readTime = story["read-time"]
|
|
46
|
+
? `${story["read-time"]} ${translate("min read")}`
|
|
47
|
+
: "";
|
|
43
48
|
|
|
44
49
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
50
|
+
|
|
51
|
+
const showIcon = (name) => (
|
|
52
|
+
<View style={styles.storyType}>
|
|
53
|
+
<Icon name={name} size={14} color={COLORS.MONO7} />
|
|
54
|
+
</View>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const showLiveBlogIcon = () => (
|
|
58
|
+
<View style={styles.storyType}>
|
|
59
|
+
<View style={styles.liveBlogIcon} />
|
|
60
|
+
<Text style={styles.liveBlogText}>LIVE</Text>
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const showStoryType = () => {
|
|
65
|
+
switch (story['story-template']) {
|
|
66
|
+
case 'text':
|
|
67
|
+
return null;
|
|
68
|
+
case 'photo':
|
|
69
|
+
return showIcon('photo');
|
|
70
|
+
case 'video':
|
|
71
|
+
return showIcon('play');
|
|
72
|
+
case 'live-blog':
|
|
73
|
+
return showLiveBlogIcon();
|
|
74
|
+
default:
|
|
75
|
+
null;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
45
79
|
return (
|
|
46
80
|
<TouchableOpacity
|
|
47
81
|
testID={props.collectionTestID}
|
|
@@ -51,10 +85,12 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
51
85
|
>
|
|
52
86
|
<ResponsiveImage
|
|
53
87
|
metaData={getImageMetadata(story)}
|
|
54
|
-
slug={getImageSlug(story) ||
|
|
55
|
-
cdn={props.cdn ||
|
|
88
|
+
slug={getImageSlug(story) || ""}
|
|
89
|
+
cdn={props.cdn || ""}
|
|
56
90
|
imageWidth={props.imageWidth}
|
|
57
|
-
|
|
91
|
+
>
|
|
92
|
+
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
93
|
+
</ResponsiveImage>
|
|
58
94
|
<View style={styles.headlineAndTimestampBlockContainer}>
|
|
59
95
|
<Text
|
|
60
96
|
primary
|
|
@@ -70,7 +106,7 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
70
106
|
<Text style={timestampStyle}>{`${readTime} · `}</Text>
|
|
71
107
|
) : null}
|
|
72
108
|
<Text style={timestampStyle} testID="secondaryStoryCardDate">
|
|
73
|
-
{getTimeForStoryCards(story[
|
|
109
|
+
{getTimeForStoryCards(story["published-at"], DATE_FORMAT, locale)}
|
|
74
110
|
</Text>
|
|
75
111
|
</View>
|
|
76
112
|
</View>
|
|
@@ -91,7 +127,7 @@ SecondaryStoryCardNewBase.propTypes = TouchableOpacityProps && {
|
|
|
91
127
|
};
|
|
92
128
|
|
|
93
129
|
SecondaryStoryCardNewBase.defaultProps = {
|
|
94
|
-
cdn:
|
|
130
|
+
cdn: "",
|
|
95
131
|
horizontalPadding: 12,
|
|
96
132
|
};
|
|
97
133
|
|
|
@@ -33,4 +33,32 @@ export const storyStyles = ({ COLORS, FONT_SIZE }) => StyleSheet.create({
|
|
|
33
33
|
icon: {
|
|
34
34
|
marginLeft: 8,
|
|
35
35
|
},
|
|
36
|
+
storyTypeContainer: {
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
backgroundColor: COLORS.MONO1,
|
|
39
|
+
bottom: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
},
|
|
42
|
+
storyType: {
|
|
43
|
+
padding: 5,
|
|
44
|
+
justifyContent: 'space-between',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
flexDirection: 'row',
|
|
47
|
+
},
|
|
48
|
+
storyTypeText: {
|
|
49
|
+
color: COLORS.MONO7,
|
|
50
|
+
fontSize: FONT_SIZE.h5,
|
|
51
|
+
},
|
|
52
|
+
liveBlogText: {
|
|
53
|
+
color: COLORS.MONO7,
|
|
54
|
+
fontSize: FONT_SIZE.h5,
|
|
55
|
+
marginLeft: 4,
|
|
56
|
+
fontWeight: 'bold',
|
|
57
|
+
},
|
|
58
|
+
liveBlogIcon: {
|
|
59
|
+
height: 12,
|
|
60
|
+
width: 12,
|
|
61
|
+
borderRadius: 50,
|
|
62
|
+
backgroundColor: COLORS.BRAND_3,
|
|
63
|
+
},
|
|
36
64
|
});
|
|
@@ -2,7 +2,7 @@ import get from 'lodash/get';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { useContext } from 'react';
|
|
4
4
|
import {
|
|
5
|
-
TouchableOpacity, View, Linking,
|
|
5
|
+
TouchableOpacity, View, Linking,
|
|
6
6
|
} from 'react-native';
|
|
7
7
|
import HTML from 'react-native-render-html';
|
|
8
8
|
import {
|
|
@@ -19,11 +19,9 @@ import { YouTubePlayer } from '../YouTubePlayer';
|
|
|
19
19
|
import { storyHeaderStyles } from './styles';
|
|
20
20
|
import { COMP_CONTENT_CONSTANTS } from '../../constants/component-constants/content-constants/constants';
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
import { DailyMotionPlayer } from '../DailyMotionPlayer';
|
|
23
23
|
|
|
24
|
-
const DATE_FORMAT =
|
|
25
|
-
? 'a h:mm ,yyyy d MMMM'
|
|
26
|
-
: 'MMMM d yyyy, h:mm a';
|
|
24
|
+
const DATE_FORMAT = 'd MMMM yyyy h:mm a';
|
|
27
25
|
|
|
28
26
|
const getHeroImage = (cdn, story) => {
|
|
29
27
|
const imageSlug = story['hero-image-s3-key'];
|
|
@@ -46,9 +44,9 @@ const getHeroComponent = (props) => {
|
|
|
46
44
|
case STORY_TYPES.VIDEO_STORY: {
|
|
47
45
|
if (!firstVideoElement) return null;
|
|
48
46
|
switch (firstVideoElement.type) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
case 'jsembed': {
|
|
48
|
+
return <DailyMotionPlayer element={firstVideoElement} />;
|
|
49
|
+
}
|
|
52
50
|
case 'youtube-video': {
|
|
53
51
|
return (
|
|
54
52
|
<YouTubePlayer
|
|
@@ -71,7 +69,7 @@ export const StoryHeader = (props) => {
|
|
|
71
69
|
const { story } = props;
|
|
72
70
|
const sectionData = get(story, ['sections', 0], {});
|
|
73
71
|
const { theme } = useContext(AppTheme);
|
|
74
|
-
const { COLORS, CAN_COPY_TEXT } = theme;
|
|
72
|
+
const { COLORS, CAN_COPY_TEXT, locale } = theme;
|
|
75
73
|
const styles = storyHeaderStyles(COLORS);
|
|
76
74
|
const imgCaption = story['hero-image-caption'];
|
|
77
75
|
const attri = story['hero-image-attribution'];
|
|
@@ -136,7 +134,7 @@ export const StoryHeader = (props) => {
|
|
|
136
134
|
style={styles.dateText}
|
|
137
135
|
testID={COMP_CONTENT_CONSTANTS.publishedDate}
|
|
138
136
|
>
|
|
139
|
-
{getTimeInFormat(story['published-at'], DATE_FORMAT)}
|
|
137
|
+
{getTimeInFormat(story['published-at'], DATE_FORMAT, locale)}
|
|
140
138
|
</Text>
|
|
141
139
|
</View>
|
|
142
140
|
<StoryTitle title={story.headline} subTitle={story.subheadline} />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import {
|
|
4
|
-
View, StyleSheet, Linking, Text,
|
|
4
|
+
View, StyleSheet, Linking, Text, I18nManager,
|
|
5
5
|
} from 'react-native';
|
|
6
6
|
import HTML from 'react-native-render-html';
|
|
7
7
|
import { AppTheme } from '../../utils/context';
|
|
@@ -21,8 +21,10 @@ export const StoryText = (props) => {
|
|
|
21
21
|
{
|
|
22
22
|
fontFamily: FONT_FAMILY.secondary,
|
|
23
23
|
fontWeight: props.question ? '600' : 'normal',
|
|
24
|
+
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
24
25
|
},
|
|
25
26
|
]);
|
|
27
|
+
|
|
26
28
|
const customTagsStyles = customHTMLStyles();
|
|
27
29
|
|
|
28
30
|
return (
|
|
@@ -15,6 +15,7 @@ export const tableStyles = ({ COLORS }) => StyleSheet.create({
|
|
|
15
15
|
justifyContent: 'center',
|
|
16
16
|
borderWidth: 0.5,
|
|
17
17
|
borderColor: COLORS.BRAND_4,
|
|
18
|
+
color: COLORS.BRAND_4,
|
|
18
19
|
},
|
|
19
20
|
tableBody: {
|
|
20
21
|
flexDirection: 'column',
|
|
@@ -22,4 +23,7 @@ export const tableStyles = ({ COLORS }) => StyleSheet.create({
|
|
|
22
23
|
tableRow: {
|
|
23
24
|
flexDirection: 'row',
|
|
24
25
|
},
|
|
26
|
+
tableContect: {
|
|
27
|
+
color: COLORS.BRAND_BLACK,
|
|
28
|
+
},
|
|
25
29
|
});
|
|
@@ -8,14 +8,13 @@ export const textQandAStyles = (COLORS, FONT_SIZE) => StyleSheet.create({
|
|
|
8
8
|
fontSize: FONT_SIZE.h2,
|
|
9
9
|
fontWeight: '600',
|
|
10
10
|
lineHeight: FONT_SIZE.h2 * 1.3,
|
|
11
|
-
color: COLORS.
|
|
12
|
-
opacity: 0.8
|
|
11
|
+
color: COLORS.BRAND_BLACK,
|
|
12
|
+
opacity: 0.8,
|
|
13
13
|
},
|
|
14
14
|
answerText: {
|
|
15
15
|
fontSize: FONT_SIZE.h2,
|
|
16
16
|
lineHeight: FONT_SIZE.h2 * 1.3,
|
|
17
|
-
color: COLORS.BRAND_8,
|
|
18
17
|
color: COLORS.BRAND_BLACK,
|
|
19
|
-
opacity: 0.8
|
|
18
|
+
opacity: 0.8,
|
|
20
19
|
},
|
|
21
20
|
});
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
export const COMP_GENERAL_CONSTANTS = {
|
|
2
|
-
secondaryStoryCard:
|
|
3
|
-
primaryStoryCard:
|
|
4
|
-
secondaryStoryAuthor:
|
|
5
|
-
secondaryStoryPubishedAt:
|
|
6
|
-
primaryStoryAuthor:
|
|
7
|
-
primaryStoryPubishedAt:
|
|
8
|
-
secondaryStoryHeadline:
|
|
9
|
-
primaryStoryHeadline:
|
|
10
|
-
iconTextTouch:
|
|
11
|
-
iconTextLabel:
|
|
12
|
-
collectionTitleTouch:
|
|
13
|
-
collectionTitleText:
|
|
14
|
-
backNavigatorText:
|
|
15
|
-
backNavigatorTouch:
|
|
2
|
+
secondaryStoryCard: "COMP_GENERAL_SECONDARY_STORY",
|
|
3
|
+
primaryStoryCard: "COMP_GENERAL_PRIMARY_STORY",
|
|
4
|
+
secondaryStoryAuthor: "COMP_GENERAL_SECONDARY_STORY_AUTHOR",
|
|
5
|
+
secondaryStoryPubishedAt: "COMP_GENERAL_SECONDARY_STORY_PUBLISHEDATE",
|
|
6
|
+
primaryStoryAuthor: "COMP_GENERAL_PRIMARY_STORY_AUTHOR",
|
|
7
|
+
primaryStoryPubishedAt: "COMP_GENERAL_PRIMARY_STORY_PUBLISHEDATE",
|
|
8
|
+
secondaryStoryHeadline: "COMP_GENERAL_SECONDARY_STORY_HEADLINE",
|
|
9
|
+
primaryStoryHeadline: "COMP_GENERAL_PRIMARY_STORY_HEADLINE",
|
|
10
|
+
iconTextTouch: "COMP_GENERAL_ICON_TEXT_TOUCH",
|
|
11
|
+
iconTextLabel: "COMP_GENERAL_ICON_TEXT_LABEL",
|
|
12
|
+
collectionTitleTouch: "COMP_GENERAL_COLLECTION_TITLE",
|
|
13
|
+
collectionTitleText: "COMP_GENERAL_COLLECTION_TITLE_TEXT",
|
|
14
|
+
backNavigatorText: "COMP_GENERAL_BACK_NAVIGATOR_TEXT",
|
|
15
|
+
backNavigatorTouch: "COMP_GENERAL_BACK_NAVIGATOR_TOUCH",
|
|
16
|
+
customSwitch: "COMP_GENERAL_CUSTOM_SWITCH",
|
|
16
17
|
};
|
|
@@ -59,5 +59,15 @@ export const customHTMLStyles = () => {
|
|
|
59
59
|
color: COLORS.BRAND_BLACK,
|
|
60
60
|
opacity: 0.85,
|
|
61
61
|
},
|
|
62
|
+
sup: {
|
|
63
|
+
marginBottom: 16,
|
|
64
|
+
lineHeight: FONT_SIZE.p1 * 0.3,
|
|
65
|
+
fontSize: FONT_SIZE.p1 * 0.5,
|
|
66
|
+
},
|
|
67
|
+
sub: {
|
|
68
|
+
marginBottom: 16,
|
|
69
|
+
lineHeight: FONT_SIZE.p1 * 0.3,
|
|
70
|
+
fontSize: FONT_SIZE.p1 * 0.5,
|
|
71
|
+
},
|
|
62
72
|
};
|
|
63
73
|
};
|