@quintype/native-components 2.19.7 → 2.19.12
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 +20 -0
- package/package.json +1 -1
- package/src/components/ActionText/ActionText.js +7 -9
- package/src/components/ActionText/ActionText.test.js +5 -12
- package/src/components/AuthorRow/AuthorRow.test.js +4 -9
- package/src/components/AuthorRow/index.js +23 -21
- package/src/components/Button/index.js +13 -9
- package/src/components/CustomSwitch/index.js +1 -2
- package/src/components/Header/index.js +13 -9
- package/src/components/PrimaryStoryCard/index.js +44 -42
- package/src/components/PrimaryStoryCard/styles.js +1 -5
- package/src/components/PrimaryStoryCardNew/index.js +33 -28
- package/src/components/PrimaryStoryCardNew/styles.js +1 -5
- package/src/components/RadioButton/index.js +24 -9
- package/src/components/SecondaryStoryCard/index.js +45 -41
- package/src/components/SecondaryStoryCard/styles.js +1 -4
- package/src/components/SecondaryStoryCardNew/index.js +30 -21
- package/src/components/SecondaryStoryCardNew/styles.js +0 -4
- package/src/components/ShareButton/index.js +18 -14
- package/src/constants/component-constants/content-constants/constants.js +7 -5
- package/src/constants/component-constants/general-constants/constants.js +7 -0
- package/src/utils/timeUtils.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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.12](https://github.com/quintype/native-components/compare/v2.19.11...v2.19.12) (2022-02-08)
|
|
6
|
+
|
|
7
|
+
### [2.19.11](https://github.com/quintype/native-components/compare/v2.19.9...v2.19.11) (2022-01-24)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **story-cards:** Adds missing translations, fixes text overflow issue by adding multiline ([#179](https://github.com/quintype/native-components/issues/179)) ([93ab137](https://github.com/quintype/native-components/commit/93ab1372fad312b653e5d6d6992d625d217c9455))
|
|
13
|
+
|
|
14
|
+
### [2.19.10](https://github.com/quintype/native-components/compare/v2.19.9...v2.19.10) (2022-01-24)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **story-cards:** Adds missing translations, fixes text overflow issue by adding multiline ([#179](https://github.com/quintype/native-components/issues/179)) ([93ab137](https://github.com/quintype/native-components/commit/93ab1372fad312b653e5d6d6992d625d217c9455))
|
|
20
|
+
|
|
21
|
+
### [2.19.9](https://github.com/quintype/native-components/compare/v2.19.8...v2.19.9) (2022-01-13)
|
|
22
|
+
|
|
23
|
+
### [2.19.8](https://github.com/quintype/native-components/compare/v2.19.7...v2.19.8) (2022-01-10)
|
|
24
|
+
|
|
5
25
|
### [2.19.7](https://github.com/quintype/native-components/compare/v2.19.0...v2.19.7) (2022-01-07)
|
|
6
26
|
|
|
7
27
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { throttle } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React from
|
|
4
|
-
import { TouchableOpacity } from
|
|
1
|
+
import { throttle } from "lodash";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { TouchableOpacity } from "react-native";
|
|
5
|
+
import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
|
|
5
6
|
|
|
6
|
-
export const ActionText = ({
|
|
7
|
-
onPress, endPoint, children, actionTextID, disablePress,
|
|
8
|
-
}) => {
|
|
7
|
+
export const ActionText = ({ onPress, endPoint, children, disablePress }) => {
|
|
9
8
|
const handleTagPress = () => onPress(endPoint);
|
|
10
9
|
const throttledOnpress = throttle(handleTagPress, 1000);
|
|
11
10
|
|
|
12
11
|
return (
|
|
13
12
|
<TouchableOpacity
|
|
14
13
|
onPress={throttledOnpress}
|
|
15
|
-
testID={
|
|
14
|
+
testID={COMP_GENERAL_CONSTANTS.actionTextTouch}
|
|
16
15
|
disabled={disablePress}
|
|
17
16
|
>
|
|
18
17
|
{children}
|
|
@@ -25,5 +24,4 @@ ActionText.propTypes = {
|
|
|
25
24
|
endPoint: PropTypes.object,
|
|
26
25
|
disablePress: PropTypes.bool,
|
|
27
26
|
children: PropTypes.any,
|
|
28
|
-
actionTextID: PropTypes.string,
|
|
29
27
|
};
|
|
@@ -4,22 +4,19 @@ import 'react-native';
|
|
|
4
4
|
import { mockContext } from '../../utils';
|
|
5
5
|
import { Text } from '../Text';
|
|
6
6
|
import { ActionText } from './ActionText';
|
|
7
|
+
import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants';
|
|
7
8
|
|
|
8
9
|
describe('Test Action Text :', () => {
|
|
9
10
|
test('should render properly :', () => {
|
|
10
11
|
const throttle = jest.fn();
|
|
11
12
|
const { getByTestId } = render(
|
|
12
13
|
mockContext(
|
|
13
|
-
<ActionText
|
|
14
|
-
onPress={throttle}
|
|
15
|
-
endPoint={{ slug: '/sample-data' }}
|
|
16
|
-
actionTextID="actionText"
|
|
17
|
-
>
|
|
14
|
+
<ActionText onPress={throttle} endPoint={{ slug: '/sample-data' }}>
|
|
18
15
|
<Text testID="sampleText">Sample Data</Text>
|
|
19
16
|
</ActionText>,
|
|
20
17
|
),
|
|
21
18
|
);
|
|
22
|
-
const element = getByTestId(
|
|
19
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.actionTextTouch);
|
|
23
20
|
expect(element.props.children).toBeDefined();
|
|
24
21
|
});
|
|
25
22
|
|
|
@@ -27,17 +24,13 @@ describe('Test Action Text :', () => {
|
|
|
27
24
|
const throttle = await jest.fn();
|
|
28
25
|
const { getByTestId } = render(
|
|
29
26
|
mockContext(
|
|
30
|
-
<ActionText
|
|
31
|
-
onPress={throttle}
|
|
32
|
-
endPoint={{ slug: '/sample-data' }}
|
|
33
|
-
actionTextID="actionText"
|
|
34
|
-
>
|
|
27
|
+
<ActionText onPress={throttle} endPoint={{ slug: '/sample-data' }}>
|
|
35
28
|
<Text testID="sampleText">Sample Data</Text>
|
|
36
29
|
</ActionText>,
|
|
37
30
|
),
|
|
38
31
|
);
|
|
39
32
|
|
|
40
|
-
const element = getByTestId(
|
|
33
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.actionTextTouch);
|
|
41
34
|
fireEvent(element, 'press');
|
|
42
35
|
expect(throttle).toHaveBeenCalled();
|
|
43
36
|
});
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import 'react-native';
|
|
4
4
|
import { mockContext } from '../../utils';
|
|
5
5
|
import { AuthorRow } from './index';
|
|
6
|
+
import { COMP_CONTENT_CONSTANTS } from '../../constants/component-constants';
|
|
6
7
|
|
|
7
8
|
const data = [
|
|
8
9
|
{
|
|
@@ -26,15 +27,9 @@ const data = [
|
|
|
26
27
|
describe('Test Author Row :', () => {
|
|
27
28
|
test('should render Author name properly', () => {
|
|
28
29
|
const { getByTestId } = render(
|
|
29
|
-
mockContext(
|
|
30
|
-
<AuthorRow
|
|
31
|
-
authors={data}
|
|
32
|
-
authorNameTestID="authorName"
|
|
33
|
-
cdn="gumlet.assettype.com"
|
|
34
|
-
/>,
|
|
35
|
-
),
|
|
30
|
+
mockContext(<AuthorRow authors={data} cdn="gumlet.assettype.com" />),
|
|
36
31
|
);
|
|
37
|
-
const element = getByTestId(
|
|
32
|
+
const element = getByTestId(COMP_CONTENT_CONSTANTS.authorName);
|
|
38
33
|
expect(element.props.children).toBe('Raghavendra Vaidya');
|
|
39
34
|
});
|
|
40
35
|
|
|
@@ -49,7 +44,7 @@ describe('Test Author Row :', () => {
|
|
|
49
44
|
/>,
|
|
50
45
|
),
|
|
51
46
|
);
|
|
52
|
-
const element = getByTestId(
|
|
47
|
+
const element = getByTestId(COMP_CONTENT_CONSTANTS.authorImage);
|
|
53
48
|
expect(element.props.children).toBeDefined();
|
|
54
49
|
});
|
|
55
50
|
});
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import PropTypes from
|
|
2
|
-
import React, { useContext } from
|
|
3
|
-
import { View } from
|
|
4
|
-
import Icon from
|
|
5
|
-
import { ResponsiveImage, Text } from
|
|
6
|
-
import { ActionText } from
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
import Icon from "react-native-vector-icons/FontAwesome";
|
|
5
|
+
import { ResponsiveImage, Text } from "../index";
|
|
6
|
+
import { ActionText } from "../ActionText/ActionText";
|
|
7
7
|
|
|
8
|
-
import { authorRowStyleSheet } from
|
|
9
|
-
import { AppTheme } from
|
|
8
|
+
import { authorRowStyleSheet } from "./styles";
|
|
9
|
+
import { AppTheme } from "../../utils";
|
|
10
|
+
import { COMP_CONTENT_CONSTANTS } from "../../constants/component-constants/content-constants/constants";
|
|
10
11
|
|
|
11
12
|
export const AuthorRow = ({
|
|
12
13
|
authors,
|
|
13
14
|
onPress,
|
|
14
15
|
cdn,
|
|
15
|
-
authorImageTestID,
|
|
16
|
-
actionTextID,
|
|
17
16
|
authorFallBackTestID,
|
|
18
|
-
authorNameTestID,
|
|
19
17
|
readtime,
|
|
20
18
|
disablePress,
|
|
21
19
|
}) => {
|
|
22
20
|
const { theme } = useContext(AppTheme);
|
|
23
|
-
const { COLORS
|
|
21
|
+
const { COLORS, translate } = theme;
|
|
24
22
|
const styles = authorRowStyleSheet(theme);
|
|
25
23
|
|
|
26
24
|
return (
|
|
@@ -31,11 +29,14 @@ export const AuthorRow = ({
|
|
|
31
29
|
}
|
|
32
30
|
return (
|
|
33
31
|
<View style={styles.container} key={author.id}>
|
|
34
|
-
<View
|
|
35
|
-
{
|
|
32
|
+
<View
|
|
33
|
+
style={styles.imageBlock}
|
|
34
|
+
testID={COMP_CONTENT_CONSTANTS.authorImage}
|
|
35
|
+
>
|
|
36
|
+
{author?.["avatar-s3-key"] ? (
|
|
36
37
|
<ResponsiveImage
|
|
37
38
|
source={{
|
|
38
|
-
uri: `${cdn}/${author?.[
|
|
39
|
+
uri: `${cdn}/${author?.["avatar-s3-key"]}`,
|
|
39
40
|
}}
|
|
40
41
|
style={styles.avatarImage}
|
|
41
42
|
imageWidth={50}
|
|
@@ -55,11 +56,13 @@ export const AuthorRow = ({
|
|
|
55
56
|
<ActionText
|
|
56
57
|
onPress={onPress}
|
|
57
58
|
endPoint={author}
|
|
58
|
-
testID={actionTextID}
|
|
59
59
|
disablePress={disablePress}
|
|
60
60
|
>
|
|
61
61
|
<View style={styles.descriptionBlock}>
|
|
62
|
-
<Text
|
|
62
|
+
<Text
|
|
63
|
+
style={styles.authorStyle}
|
|
64
|
+
testID={COMP_CONTENT_CONSTANTS.authorName}
|
|
65
|
+
>
|
|
63
66
|
{author.name}
|
|
64
67
|
</Text>
|
|
65
68
|
</View>
|
|
@@ -69,7 +72,9 @@ export const AuthorRow = ({
|
|
|
69
72
|
})}
|
|
70
73
|
{readtime ? (
|
|
71
74
|
<View style={styles.readtimeComponent}>
|
|
72
|
-
<Text style={styles.readtime}>{`| ${readtime} ${translate(
|
|
75
|
+
<Text style={styles.readtime}>{`| ${readtime} ${translate(
|
|
76
|
+
"min read"
|
|
77
|
+
)}`}</Text>
|
|
73
78
|
</View>
|
|
74
79
|
) : null}
|
|
75
80
|
</View>
|
|
@@ -82,8 +87,5 @@ AuthorRow.propTypes = {
|
|
|
82
87
|
cdn: PropTypes.string.isRequired,
|
|
83
88
|
disablePress: PropTypes.bool,
|
|
84
89
|
authorFallBackTestID: PropTypes.string,
|
|
85
|
-
authorImageTestID: PropTypes.string,
|
|
86
|
-
authorNameTestID: PropTypes.string,
|
|
87
|
-
actionTextID: PropTypes.string,
|
|
88
90
|
readtime: PropTypes.number,
|
|
89
91
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import PropTypes from
|
|
2
|
-
import React, { useContext } from
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
3
|
import {
|
|
4
|
-
StyleSheet,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
TouchableOpacity,
|
|
5
6
|
View,
|
|
6
|
-
|
|
7
7
|
ViewPropTypes,
|
|
8
|
-
} from
|
|
9
|
-
import { AppTheme } from
|
|
10
|
-
import { Text } from
|
|
11
|
-
import { styles } from
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import { AppTheme } from "../../utils";
|
|
10
|
+
import { Text } from "../Text";
|
|
11
|
+
import { styles } from "./styles";
|
|
12
|
+
import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
|
|
12
13
|
|
|
13
14
|
export const Button = (props) => {
|
|
14
15
|
const { icon, text, onPress } = props;
|
|
@@ -21,7 +22,10 @@ export const Button = (props) => {
|
|
|
21
22
|
|
|
22
23
|
return (
|
|
23
24
|
<View>
|
|
24
|
-
<TouchableOpacity
|
|
25
|
+
<TouchableOpacity
|
|
26
|
+
onPress={onPress}
|
|
27
|
+
testID={COMP_GENERAL_CONSTANTS.buttonTouch}
|
|
28
|
+
>
|
|
25
29
|
<View style={btnStyle}>
|
|
26
30
|
<Text style={textStyle}>{text}</Text>
|
|
27
31
|
{icon}
|
|
@@ -23,7 +23,7 @@ export const CustomSwitch = ({
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<View style={styles.container}>
|
|
26
|
+
<View style={styles.container} testID={COMP_GENERAL_CONSTANTS.customSwitch}>
|
|
27
27
|
<View style={styles.textContainer}>
|
|
28
28
|
{!iconName ? null : (
|
|
29
29
|
<View style={styles.iconStyle}>
|
|
@@ -40,7 +40,6 @@ export const CustomSwitch = ({
|
|
|
40
40
|
onValueChange={handleToggle}
|
|
41
41
|
value={isEnabled}
|
|
42
42
|
disabled={isSwitchDisabled}
|
|
43
|
-
testID={COMP_GENERAL_CONSTANTS.customSwitch}
|
|
44
43
|
/>
|
|
45
44
|
</View>
|
|
46
45
|
);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import PropTypes from
|
|
2
|
-
import React, { useContext } from
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
3
|
import {
|
|
4
4
|
StyleSheet,
|
|
5
5
|
TouchableOpacity,
|
|
6
6
|
View,
|
|
7
7
|
ViewPropTypes,
|
|
8
|
-
} from
|
|
8
|
+
} from "react-native";
|
|
9
9
|
|
|
10
|
-
import { headerStyles } from
|
|
11
|
-
import { AppTheme } from
|
|
10
|
+
import { headerStyles } from "./styles";
|
|
11
|
+
import { AppTheme } from "../../utils";
|
|
12
|
+
import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants";
|
|
12
13
|
|
|
13
14
|
export const Header = (props) => {
|
|
14
15
|
const { theme } = useContext(AppTheme);
|
|
@@ -19,11 +20,15 @@ export const Header = (props) => {
|
|
|
19
20
|
props.logoComponentStyle,
|
|
20
21
|
]);
|
|
21
22
|
return (
|
|
22
|
-
<View
|
|
23
|
+
<View style={headerStyle}>
|
|
23
24
|
<View>
|
|
24
25
|
{props.leftComponent && props.leftComponent}
|
|
25
26
|
{props.logoComponent && (
|
|
26
|
-
<TouchableOpacity
|
|
27
|
+
<TouchableOpacity
|
|
28
|
+
style={logoComponentStyle}
|
|
29
|
+
onPress={props.onPress}
|
|
30
|
+
testID={COMP_GENERAL_CONSTANTS.headerLogoTouch}
|
|
31
|
+
>
|
|
27
32
|
{props.logoComponent}
|
|
28
33
|
</TouchableOpacity>
|
|
29
34
|
)}
|
|
@@ -34,7 +39,7 @@ export const Header = (props) => {
|
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
Header.defaultProps = {
|
|
37
|
-
onPress: () => {
|
|
42
|
+
onPress: () => {},
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
Header.propTypes = {
|
|
@@ -43,7 +48,6 @@ Header.propTypes = {
|
|
|
43
48
|
logoComponent: PropTypes.element,
|
|
44
49
|
style: ViewPropTypes.style,
|
|
45
50
|
logoComponentStyle: PropTypes.object,
|
|
46
|
-
testID: PropTypes.string,
|
|
47
51
|
onPress: PropTypes.func,
|
|
48
52
|
noBorder: PropTypes.bool,
|
|
49
53
|
};
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import { throttle } from
|
|
2
|
-
import get from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import React, { useContext } from
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from 'react-native';
|
|
8
|
-
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
1
|
+
import { throttle } from "lodash";
|
|
2
|
+
import get from "lodash/get";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import React, { useContext } from "react";
|
|
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
|
-
|
|
14
|
-
} from
|
|
15
|
-
import { getStoryHeadline } from
|
|
16
|
-
import { ResponsiveImage, Text } from
|
|
17
|
-
import { storyStyles } from
|
|
18
|
-
import {
|
|
11
|
+
getTimeForStoryCards,
|
|
12
|
+
} from "../../utils";
|
|
13
|
+
import { getStoryHeadline } from "../../utils/story";
|
|
14
|
+
import { ResponsiveImage, Text } from "../index";
|
|
15
|
+
import { storyStyles } from "./styles";
|
|
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;
|
|
22
23
|
const { theme } = useContext(AppTheme);
|
|
23
24
|
|
|
24
|
-
const translate = get(theme, [
|
|
25
|
+
const translate = get(theme, ["translate"], (word) => word);
|
|
25
26
|
|
|
26
27
|
const { COLORS, FONT_SIZE, locale } = theme || {};
|
|
27
28
|
|
|
28
|
-
const DATE_FORMAT =
|
|
29
|
+
const DATE_FORMAT = "d MMM, yyyy";
|
|
29
30
|
|
|
30
31
|
const styles = storyStyles(COLORS, FONT_SIZE);
|
|
31
32
|
const containerStyle = StyleSheet.flatten([
|
|
@@ -41,9 +42,11 @@ export const PrimaryStoryCard = (props) => {
|
|
|
41
42
|
props.authorTextStyle,
|
|
42
43
|
]);
|
|
43
44
|
|
|
44
|
-
const name = get(story.authors, [0,
|
|
45
|
-
const authorName = name ? `${translate(
|
|
46
|
-
const readTime = story[
|
|
45
|
+
const name = get(story.authors, [0, "name"]);
|
|
46
|
+
const authorName = name ? `${translate("By")} ${name} | ` : "";
|
|
47
|
+
const readTime = story["read-time"]
|
|
48
|
+
? `${story["read-time"]} ${translate("min read")}`
|
|
49
|
+
: "";
|
|
47
50
|
|
|
48
51
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
49
52
|
|
|
@@ -60,14 +63,14 @@ export const PrimaryStoryCard = (props) => {
|
|
|
60
63
|
</View>
|
|
61
64
|
);
|
|
62
65
|
const showStoryType = () => {
|
|
63
|
-
switch (story[
|
|
64
|
-
case
|
|
66
|
+
switch (story["story-template"]) {
|
|
67
|
+
case "text":
|
|
65
68
|
return null;
|
|
66
|
-
case
|
|
67
|
-
return showIcon(
|
|
68
|
-
case
|
|
69
|
-
return showIcon(
|
|
70
|
-
case
|
|
69
|
+
case "photo":
|
|
70
|
+
return showIcon("photo");
|
|
71
|
+
case "video":
|
|
72
|
+
return showIcon("play");
|
|
73
|
+
case "live-blog":
|
|
71
74
|
return showLiveBlogIcon();
|
|
72
75
|
default:
|
|
73
76
|
null;
|
|
@@ -96,21 +99,20 @@ export const PrimaryStoryCard = (props) => {
|
|
|
96
99
|
</Text>
|
|
97
100
|
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
98
101
|
</ResponsiveImage>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
</View>
|
|
102
|
+
<Text
|
|
103
|
+
style={autorStyle}
|
|
104
|
+
numberOfLines={2}
|
|
105
|
+
// TODO: Add corrected testID here
|
|
106
|
+
testID={COMP_CONTENT_CONSTANTS.authorName}
|
|
107
|
+
>
|
|
108
|
+
{authorName +
|
|
109
|
+
getTimeForStoryCards(
|
|
110
|
+
story["published-at"],
|
|
111
|
+
DATE_FORMAT,
|
|
112
|
+
locale,
|
|
113
|
+
translate
|
|
114
|
+
)}
|
|
115
|
+
</Text>
|
|
114
116
|
<Text
|
|
115
117
|
primary
|
|
116
118
|
numberOfLines={3}
|
|
@@ -135,6 +137,6 @@ PrimaryStoryCard.propTypes = {
|
|
|
135
137
|
};
|
|
136
138
|
|
|
137
139
|
PrimaryStoryCard.defaultProps = {
|
|
138
|
-
cdn:
|
|
140
|
+
cdn: "",
|
|
139
141
|
horizontalPadding: 12,
|
|
140
142
|
};
|
|
@@ -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,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { get, throttle } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React, { useContext, memo } from
|
|
4
|
-
import { StyleSheet, TouchableOpacity, View } from
|
|
5
|
-
import Icon from
|
|
1
|
+
import { get, throttle } from "lodash";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React, { useContext, memo } from "react";
|
|
4
|
+
import { StyleSheet, TouchableOpacity, View } from "react-native";
|
|
5
|
+
import Icon from "react-native-vector-icons/FontAwesome";
|
|
6
6
|
import {
|
|
7
7
|
AppTheme,
|
|
8
8
|
getImageMetadata,
|
|
@@ -12,15 +12,15 @@ import {
|
|
|
12
12
|
import { getStoryHeadline } from "../../utils/story";
|
|
13
13
|
import { ResponsiveImage, Text } from "../index";
|
|
14
14
|
import { storyStyles } from "./styles";
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import {
|
|
16
|
+
COMP_GENERAL_CONSTANTS,
|
|
17
|
+
COMP_CONTENT_CONSTANTS,
|
|
18
|
+
} from "../../constants/component-constants";
|
|
17
19
|
|
|
18
20
|
const PrimaryStoryCardNewBase = (props) => {
|
|
19
21
|
const { story = {} } = props;
|
|
20
22
|
const { theme } = useContext(AppTheme);
|
|
21
|
-
const {
|
|
22
|
-
COLORS, FONT_SIZE, locale, DARK_MODE,
|
|
23
|
-
} = theme || {};
|
|
23
|
+
const { COLORS, FONT_SIZE, locale, DARK_MODE } = theme || {};
|
|
24
24
|
|
|
25
25
|
const translate = get(theme, ["translate"], (word) => word);
|
|
26
26
|
|
|
@@ -40,7 +40,7 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
40
40
|
|
|
41
41
|
const DATE_FORMAT = "d MMM, yyyy";
|
|
42
42
|
const readTime = story["read-time"]
|
|
43
|
-
? `${story["read-time"]} ${translate("min read")}`
|
|
43
|
+
? `${story["read-time"]} ${translate("min read")} · `
|
|
44
44
|
: "";
|
|
45
45
|
|
|
46
46
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
@@ -58,14 +58,14 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
58
58
|
</View>
|
|
59
59
|
);
|
|
60
60
|
const showStoryType = () => {
|
|
61
|
-
switch (story[
|
|
62
|
-
case
|
|
61
|
+
switch (story["story-template"]) {
|
|
62
|
+
case "text":
|
|
63
63
|
return null;
|
|
64
|
-
case
|
|
65
|
-
return showIcon(
|
|
66
|
-
case
|
|
67
|
-
return showIcon(
|
|
68
|
-
case
|
|
64
|
+
case "photo":
|
|
65
|
+
return showIcon("photo");
|
|
66
|
+
case "video":
|
|
67
|
+
return showIcon("play");
|
|
68
|
+
case "live-blog":
|
|
69
69
|
return showLiveBlogIcon();
|
|
70
70
|
default:
|
|
71
71
|
null;
|
|
@@ -74,7 +74,7 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
74
74
|
|
|
75
75
|
return (
|
|
76
76
|
<TouchableOpacity
|
|
77
|
-
testID=
|
|
77
|
+
testID={COMP_GENERAL_CONSTANTS.primaryStoryCard}
|
|
78
78
|
onPress={throttledOnpress}
|
|
79
79
|
activeOpacity={0.8}
|
|
80
80
|
style={containerStyle}
|
|
@@ -94,18 +94,23 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
94
94
|
numberOfLines={3}
|
|
95
95
|
ellipsizeMode="tail"
|
|
96
96
|
style={headlineStyle}
|
|
97
|
-
testID=
|
|
97
|
+
testID={COMP_GENERAL_CONSTANTS.primaryStoryHeadline}
|
|
98
98
|
>
|
|
99
99
|
{getStoryHeadline(story)}
|
|
100
100
|
</Text>
|
|
101
|
-
<
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
<Text
|
|
102
|
+
style={timestampStyle}
|
|
103
|
+
numberOfLines={2}
|
|
104
|
+
testID={COMP_CONTENT_CONSTANTS.publishedDate}
|
|
105
|
+
>
|
|
106
|
+
{readTime +
|
|
107
|
+
getTimeForStoryCards(
|
|
108
|
+
story["published-at"],
|
|
109
|
+
DATE_FORMAT,
|
|
110
|
+
locale,
|
|
111
|
+
translate
|
|
112
|
+
)}
|
|
113
|
+
</Text>
|
|
109
114
|
</View>
|
|
110
115
|
<View style={styles.icon}>{props.iconComponent}</View>
|
|
111
116
|
</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,
|
|
@@ -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>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { throttle } from
|
|
2
|
-
import get from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import React, { useContext } from
|
|
1
|
+
import { throttle } from "lodash";
|
|
2
|
+
import get from "lodash/get";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import React, { useContext } from "react";
|
|
5
5
|
import {
|
|
6
6
|
Image,
|
|
7
7
|
StyleSheet,
|
|
@@ -9,28 +9,31 @@ import {
|
|
|
9
9
|
View,
|
|
10
10
|
TextStyle,
|
|
11
11
|
TouchableOpacityProps,
|
|
12
|
-
} from
|
|
13
|
-
import Icon from
|
|
12
|
+
} from "react-native";
|
|
13
|
+
import Icon from "react-native-vector-icons/FontAwesome";
|
|
14
14
|
import {
|
|
15
15
|
AppTheme,
|
|
16
16
|
getImageMetadata,
|
|
17
17
|
getImageSlug,
|
|
18
|
-
|
|
19
|
-
} from
|
|
20
|
-
import { getStoryHeadline } from
|
|
21
|
-
import { ResponsiveImage, Text } from
|
|
22
|
-
import { secStoryCardStyles } from
|
|
23
|
-
import {
|
|
18
|
+
getTimeForStoryCards,
|
|
19
|
+
} from "../../utils";
|
|
20
|
+
import { getStoryHeadline } from "../../utils/story";
|
|
21
|
+
import { ResponsiveImage, Text } from "../index";
|
|
22
|
+
import { secStoryCardStyles } from "./styles";
|
|
23
|
+
import {
|
|
24
|
+
COMP_GENERAL_CONSTANTS,
|
|
25
|
+
COMP_CONTENT_CONSTANTS,
|
|
26
|
+
} from "../../constants/component-constants";
|
|
24
27
|
|
|
25
28
|
export const SecondaryStoryCard = (props) => {
|
|
26
29
|
const { theme } = useContext(AppTheme);
|
|
27
|
-
const translate = get(theme, [
|
|
30
|
+
const translate = get(theme, ["translate"], (word) => word);
|
|
28
31
|
|
|
29
32
|
const { locale, COLORS } = theme;
|
|
30
33
|
const styles = secStoryCardStyles(theme);
|
|
31
34
|
const { story = {} } = props;
|
|
32
35
|
|
|
33
|
-
const DATE_FORMAT =
|
|
36
|
+
const DATE_FORMAT = "d MMM, yyyy";
|
|
34
37
|
|
|
35
38
|
const containerStyle = StyleSheet.flatten([
|
|
36
39
|
styles.container,
|
|
@@ -49,9 +52,11 @@ export const SecondaryStoryCard = (props) => {
|
|
|
49
52
|
styles.authorTextContainer,
|
|
50
53
|
props.authorTextContainer,
|
|
51
54
|
]);
|
|
52
|
-
const name = get(story.authors, [0,
|
|
53
|
-
const authorName = name ? `${translate(
|
|
54
|
-
const readTime = story[
|
|
55
|
+
const name = get(story.authors, [0, "name"]);
|
|
56
|
+
const authorName = name ? `${translate("By")} ${name} | ` : "";
|
|
57
|
+
const readTime = story["read-time"]
|
|
58
|
+
? `${story["read-time"]} ${translate("min read")}`
|
|
59
|
+
: "";
|
|
55
60
|
|
|
56
61
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
57
62
|
|
|
@@ -69,14 +74,14 @@ export const SecondaryStoryCard = (props) => {
|
|
|
69
74
|
);
|
|
70
75
|
|
|
71
76
|
const showStoryType = () => {
|
|
72
|
-
switch (story[
|
|
73
|
-
case
|
|
77
|
+
switch (story["story-template"]) {
|
|
78
|
+
case "text":
|
|
74
79
|
return null;
|
|
75
|
-
case
|
|
76
|
-
return showIcon(
|
|
77
|
-
case
|
|
78
|
-
return showIcon(
|
|
79
|
-
case
|
|
80
|
+
case "photo":
|
|
81
|
+
return showIcon("photo");
|
|
82
|
+
case "video":
|
|
83
|
+
return showIcon("play");
|
|
84
|
+
case "live-blog":
|
|
80
85
|
return showLiveBlogIcon();
|
|
81
86
|
default:
|
|
82
87
|
null;
|
|
@@ -92,8 +97,8 @@ export const SecondaryStoryCard = (props) => {
|
|
|
92
97
|
>
|
|
93
98
|
<ResponsiveImage
|
|
94
99
|
metaData={getImageMetadata(story)}
|
|
95
|
-
slug={getImageSlug(story) ||
|
|
96
|
-
cdn={props.cdn ||
|
|
100
|
+
slug={getImageSlug(story) || ""}
|
|
101
|
+
cdn={props.cdn || ""}
|
|
97
102
|
imageWidth={props.imageWidth}
|
|
98
103
|
>
|
|
99
104
|
<Text style={styles.xminContainer}>
|
|
@@ -116,20 +121,19 @@ export const SecondaryStoryCard = (props) => {
|
|
|
116
121
|
{getStoryHeadline(story)?.trim()}
|
|
117
122
|
</Text>
|
|
118
123
|
<View style={styles.authorAndIconContainer}>
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
</View>
|
|
124
|
+
<Text
|
|
125
|
+
style={authorTextStyle}
|
|
126
|
+
numberOfLines={2}
|
|
127
|
+
testID={COMP_CONTENT_CONSTANTS.authorName}
|
|
128
|
+
>
|
|
129
|
+
{authorName +
|
|
130
|
+
getTimeForStoryCards(
|
|
131
|
+
story["published-at"],
|
|
132
|
+
DATE_FORMAT,
|
|
133
|
+
locale,
|
|
134
|
+
translate
|
|
135
|
+
)}
|
|
136
|
+
</Text>
|
|
133
137
|
<View style={iconStyles}>{props.iconComponent}</View>
|
|
134
138
|
</View>
|
|
135
139
|
</View>
|
|
@@ -149,6 +153,6 @@ SecondaryStoryCard.propTypes = TouchableOpacityProps && {
|
|
|
149
153
|
};
|
|
150
154
|
|
|
151
155
|
SecondaryStoryCard.defaultProps = {
|
|
152
|
-
cdn:
|
|
156
|
+
cdn: "",
|
|
153
157
|
horizontalPadding: 12,
|
|
154
158
|
};
|
|
@@ -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,
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
View,
|
|
9
9
|
TextStyle,
|
|
10
10
|
TouchableOpacityProps,
|
|
11
|
-
} from
|
|
12
|
-
import Icon from
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import Icon from "react-native-vector-icons/FontAwesome";
|
|
13
13
|
import {
|
|
14
14
|
AppTheme,
|
|
15
15
|
getImageMetadata,
|
|
@@ -19,6 +19,10 @@ import {
|
|
|
19
19
|
import { getStoryHeadline } from "../../utils/story";
|
|
20
20
|
import { ResponsiveImage, Text } from "../index";
|
|
21
21
|
import { storyStyles } from "./styles";
|
|
22
|
+
import {
|
|
23
|
+
COMP_GENERAL_CONSTANTS,
|
|
24
|
+
COMP_CONTENT_CONSTANTS,
|
|
25
|
+
} from "../../constants/component-constants";
|
|
22
26
|
|
|
23
27
|
const SecondaryStoryCardNewBase = (props) => {
|
|
24
28
|
const { story = {} } = props;
|
|
@@ -43,7 +47,7 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
43
47
|
|
|
44
48
|
const DATE_FORMAT = "d MMM, yyyy";
|
|
45
49
|
const readTime = story["read-time"]
|
|
46
|
-
? `${story["read-time"]} ${translate("min read")}`
|
|
50
|
+
? `${story["read-time"]} ${translate("min read")} · `
|
|
47
51
|
: "";
|
|
48
52
|
|
|
49
53
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
@@ -62,14 +66,14 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
62
66
|
);
|
|
63
67
|
|
|
64
68
|
const showStoryType = () => {
|
|
65
|
-
switch (story[
|
|
66
|
-
case
|
|
69
|
+
switch (story["story-template"]) {
|
|
70
|
+
case "text":
|
|
67
71
|
return null;
|
|
68
|
-
case
|
|
69
|
-
return showIcon(
|
|
70
|
-
case
|
|
71
|
-
return showIcon(
|
|
72
|
-
case
|
|
72
|
+
case "photo":
|
|
73
|
+
return showIcon("photo");
|
|
74
|
+
case "video":
|
|
75
|
+
return showIcon("play");
|
|
76
|
+
case "live-blog":
|
|
73
77
|
return showLiveBlogIcon();
|
|
74
78
|
default:
|
|
75
79
|
null;
|
|
@@ -78,7 +82,7 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
78
82
|
|
|
79
83
|
return (
|
|
80
84
|
<TouchableOpacity
|
|
81
|
-
testID={
|
|
85
|
+
testID={COMP_GENERAL_CONSTANTS.secondaryStoryCard}
|
|
82
86
|
onPress={throttledOnpress}
|
|
83
87
|
activeOpacity={0.8}
|
|
84
88
|
style={containerStyle}
|
|
@@ -97,18 +101,24 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
97
101
|
numberOfLines={2}
|
|
98
102
|
ellipsizeMode="tail"
|
|
99
103
|
style={headlineStyle}
|
|
100
|
-
testID=
|
|
104
|
+
testID={COMP_GENERAL_CONSTANTS.secondaryStoryHeadline}
|
|
101
105
|
>
|
|
102
106
|
{getStoryHeadline(story)?.trim()}
|
|
103
107
|
</Text>
|
|
104
|
-
<
|
|
105
|
-
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
<Text
|
|
109
|
+
style={timestampStyle}
|
|
110
|
+
numberOfLines={2}
|
|
111
|
+
// TODO: Add corrected testID here
|
|
112
|
+
testID={COMP_CONTENT_CONSTANTS.publishedDate}
|
|
113
|
+
>
|
|
114
|
+
{readTime +
|
|
115
|
+
getTimeForStoryCards(
|
|
116
|
+
story["published-at"],
|
|
117
|
+
DATE_FORMAT,
|
|
118
|
+
locale,
|
|
119
|
+
translate
|
|
120
|
+
)}
|
|
121
|
+
</Text>
|
|
112
122
|
</View>
|
|
113
123
|
<View style={styles.icon}>{props.iconComponent}</View>
|
|
114
124
|
</TouchableOpacity>
|
|
@@ -121,7 +131,6 @@ SecondaryStoryCardNewBase.propTypes = TouchableOpacityProps && {
|
|
|
121
131
|
headlineStyle: TextStyle,
|
|
122
132
|
timestampStyle: TextStyle,
|
|
123
133
|
story: PropTypes.any.isRequired,
|
|
124
|
-
collectionTestID: PropTypes.string,
|
|
125
134
|
iconComponent: PropTypes.element,
|
|
126
135
|
horizontalPadding: PropTypes.number,
|
|
127
136
|
};
|
|
@@ -18,10 +18,6 @@ export const storyStyles = ({ COLORS, FONT_SIZE }) => StyleSheet.create({
|
|
|
18
18
|
fontSize: FONT_SIZE.h5,
|
|
19
19
|
lineHeight: FONT_SIZE.h5 * 1.2,
|
|
20
20
|
opacity: 0.6,
|
|
21
|
-
},
|
|
22
|
-
timestampContainer: {
|
|
23
|
-
alignItems: 'center',
|
|
24
|
-
flexDirection: 'row',
|
|
25
21
|
marginTop: 4,
|
|
26
22
|
},
|
|
27
23
|
headline: {
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import React, { useContext, memo } from
|
|
2
|
-
import { TouchableOpacity } from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import Icon from
|
|
5
|
-
import Share from
|
|
6
|
-
import { AppTheme } from
|
|
7
|
-
import { shareButtonStyles } from
|
|
8
|
-
import { getStoryHeadline } from
|
|
1
|
+
import React, { useContext, memo } from "react";
|
|
2
|
+
import { TouchableOpacity } from "react-native";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import Icon from "react-native-vector-icons/Ionicons";
|
|
5
|
+
import Share from "react-native-share";
|
|
6
|
+
import { AppTheme } from "../../utils";
|
|
7
|
+
import { shareButtonStyles } from "./styles";
|
|
8
|
+
import { getStoryHeadline } from "../../utils/story";
|
|
9
|
+
import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants";
|
|
9
10
|
|
|
10
11
|
const ShareButtonBase = (props) => {
|
|
11
12
|
const { theme } = useContext(AppTheme);
|
|
12
13
|
const styles = shareButtonStyles(theme);
|
|
13
|
-
const { story, type =
|
|
14
|
+
const { story, type = "story", slug } = props;
|
|
14
15
|
|
|
15
16
|
const getShareURL = () => {
|
|
16
17
|
const { url } = story || {};
|
|
17
18
|
switch (type) {
|
|
18
|
-
case
|
|
19
|
+
case "story":
|
|
19
20
|
return url;
|
|
20
|
-
case
|
|
21
|
+
case "card":
|
|
21
22
|
return `${url}${slug}`;
|
|
22
|
-
case
|
|
23
|
+
case "image":
|
|
23
24
|
return `${url}${slug}`;
|
|
24
|
-
case
|
|
25
|
+
case "attachment":
|
|
25
26
|
return slug;
|
|
26
27
|
default:
|
|
27
28
|
return url || slug;
|
|
@@ -43,7 +44,10 @@ const ShareButtonBase = (props) => {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
return (
|
|
46
|
-
<TouchableOpacity
|
|
47
|
+
<TouchableOpacity
|
|
48
|
+
onPress={share}
|
|
49
|
+
testID={COMP_GENERAL_CONSTANTS.shareButtonTouch}
|
|
50
|
+
>
|
|
47
51
|
<Icon style={styles.iconStyle} name="share-social-outline" size={20} />
|
|
48
52
|
</TouchableOpacity>
|
|
49
53
|
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export const COMP_CONTENT_CONSTANTS = {
|
|
2
|
-
storyTitle:
|
|
3
|
-
storySubTitle:
|
|
4
|
-
sectionName:
|
|
5
|
-
publishedDate:
|
|
6
|
-
relatedStoriesLabel:
|
|
2
|
+
storyTitle: "COMP_STORY_TITLE",
|
|
3
|
+
storySubTitle: "COMP_STORY_SUBTITLE",
|
|
4
|
+
sectionName: "COMP_STORY_SECTION_NAME",
|
|
5
|
+
publishedDate: "COMP_STORY_PUBLISHED_DATE",
|
|
6
|
+
relatedStoriesLabel: "COMP_STORY_RELATEDSTORIES_LABEL",
|
|
7
|
+
authorName: "COMP_STORY_AUTHOR_NAME",
|
|
8
|
+
authorImage: "COMP_STORY_AUTHOR_IMAGE",
|
|
7
9
|
};
|
|
@@ -14,4 +14,11 @@ export const COMP_GENERAL_CONSTANTS = {
|
|
|
14
14
|
backNavigatorText: "COMP_GENERAL_BACK_NAVIGATOR_TEXT",
|
|
15
15
|
backNavigatorTouch: "COMP_GENERAL_BACK_NAVIGATOR_TOUCH",
|
|
16
16
|
customSwitch: "COMP_GENERAL_CUSTOM_SWITCH",
|
|
17
|
+
primaryStoryReadTime: "COMP_GENERAL_PRIMARY_STORY_READTIME",
|
|
18
|
+
secondaryStoryReadTime: "COMP_GENERAL_SECONDARY_STORY_READTIME",
|
|
19
|
+
actionTextTouch: "COMP_GENERAL_ACTION_TEXT_TOUCH",
|
|
20
|
+
buttonTouch: "COMP_GENERAL_BUTTON_TOUCH",
|
|
21
|
+
headerLogoTouch: "COMP_GENERAL_HEADER_LOGO_TOUCH",
|
|
22
|
+
radioButtonTouch: "COMP_GENERAL_RADIO",
|
|
23
|
+
shareButtonTouch: "COMP_GENERAL_SHARE",
|
|
17
24
|
};
|
package/src/utils/timeUtils.js
CHANGED
|
@@ -15,14 +15,14 @@ export function getTimeInFormat(date, format, localTime) {
|
|
|
15
15
|
return '';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const getTimeForStoryCards = (date, format, localTime) => {
|
|
18
|
+
export const getTimeForStoryCards = (date, format, localTime, translate) => {
|
|
19
19
|
if (date) {
|
|
20
20
|
const currentDate = new Date();
|
|
21
21
|
const dateToFormat = new Date(date);
|
|
22
22
|
const locale = dateFNSlocale[localTime];
|
|
23
23
|
const distanceInMinutes = differenceInMinutes(currentDate, dateToFormat);
|
|
24
24
|
if (distanceInMinutes <= 1440) {
|
|
25
|
-
return
|
|
25
|
+
return `${translate("published")} ${formatDistanceToNow(dateToFormat, { locale })} ${translate("ago")}`;
|
|
26
26
|
}
|
|
27
27
|
return dateFormat(dateToFormat, format, { locale });
|
|
28
28
|
}
|