@quintype/native-components 2.19.1 → 2.19.6

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 CHANGED
@@ -2,6 +2,31 @@
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.6](https://github.com/quintype/native-components/compare/v2.19.5...v2.19.6) (2021-12-30)
6
+
7
+ ### [2.19.5](https://github.com/quintype/native-components/compare/v2.19.3...v2.19.5) (2021-12-29)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **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))
13
+
14
+ ### [2.19.3](https://github.com/quintype/native-components/compare/v2.18.4...v2.19.3) (2021-10-28)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **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))
20
+ * **AlsoRead:** Fixed card height :hammer: ([#174](https://github.com/quintype/native-components/issues/174)) ([6ce7a60](https://github.com/quintype/native-components/commit/6ce7a6078ec699f0f3df74d8136fc64070921caa))
21
+ * **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))
22
+
23
+ ### [2.19.2](https://github.com/quintype/native-components/compare/v2.19.1...v2.19.2) (2021-10-19)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **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))
29
+
5
30
  ### [2.19.1](https://github.com/quintype/native-components/compare/v2.19.0...v2.19.1) (2021-10-07)
6
31
 
7
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.19.1",
3
+ "version": "2.19.6",
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
- "rn-fetch-blob": ">=0.12.0",
37
- "@react-navigation/native": ">=5.7.3",
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,11 +1,15 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import Svg, { Path } from 'react-native-svg';
3
+ import { AppTheme } from "../../utils/context";
3
4
 
4
- export const ClockIcon = (props) => (
5
- <Svg width={24} height={24} {...props}>
5
+ export const ClockIcon = (props) => {
6
+ const { theme } = useContext(AppTheme);
7
+ const { COLORS } = theme;
8
+ const color = COLORS.BRAND_BLACK;
9
+ return <Svg width={24} height={24} {...props}>
6
10
  <Path
7
- fill="#333"
11
+ fill={color}
8
12
  d="M12 4.25c1.396 0 2.687.349 3.875 1.047a7.831 7.831 0 012.828 2.828A7.513 7.513 0 0119.75 12a7.513 7.513 0 01-1.047 3.875 7.831 7.831 0 01-2.828 2.828A7.513 7.513 0 0112 19.75a7.513 7.513 0 01-3.875-1.047 7.831 7.831 0 01-2.828-2.828A7.513 7.513 0 014.25 12c0-1.396.349-2.687 1.047-3.875a7.831 7.831 0 012.828-2.828A7.513 7.513 0 0112 4.25zM18.75 12a6.58 6.58 0 00-.906-3.39 6.72 6.72 0 00-2.469-2.454 6.641 6.641 0 00-3.39-.906 6.558 6.558 0 00-3.376.906 6.72 6.72 0 00-2.453 2.469 6.641 6.641 0 00-.906 3.39c0 1.22.302 2.344.906 3.376a6.72 6.72 0 002.469 2.453 6.641 6.641 0 003.39.906 6.558 6.558 0 003.376-.906 6.72 6.72 0 002.453-2.469A6.613 6.613 0 0018.75 12zm-4.656 2.75l-2.532-1.844a.307.307 0 01-.156-.281v-5c0-.104.037-.193.11-.266a.362.362 0 01.265-.109h.438c.104 0 .192.036.265.11.073.072.11.16.11.265v4.563l2.218 1.625a.33.33 0 01.141.234.349.349 0 01-.038.202l-.29.439a.342.342 0 01-.25.14.389.389 0 01-.281-.078z"
9
13
  />
10
14
  </Svg>
11
- );
15
+ }
@@ -1,6 +1,6 @@
1
1
  import React, { useContext } from 'react';
2
2
  import get from 'lodash/get';
3
- import { View, TouchableOpacity, StyleSheet } from 'react-native';
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={3} style={styles.alsoReadText}>
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
- color: COLORS.BRAND_1,
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
  };
@@ -1,19 +1,25 @@
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';
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 = '', callback, isEnabled = true, iconSize = 20, iconName, isSwitchDisabled = false,
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 === 'function' && callback(!isEnabled);
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
- I18nManager, StyleSheet, TouchableOpacity, View,
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,7 +25,7 @@ export const PrimaryStoryCard = (props) => {
25
25
 
26
26
  const { COLORS, FONT_SIZE, locale } = theme || {};
27
27
 
28
- const DATE_FORMAT = I18nManager.isRTL ? 'yyyy , MMM d' : 'd MMM, yyyy';
28
+ const DATE_FORMAT = 'd MMM, yyyy';
29
29
 
30
30
  const styles = storyStyles(COLORS, FONT_SIZE);
31
31
  const containerStyle = StyleSheet.flatten([
@@ -43,10 +43,37 @@ export const PrimaryStoryCard = (props) => {
43
43
 
44
44
  const name = get(story.authors, [0, 'name']);
45
45
  const authorName = name ? `${translate('By')} ${name} | ` : '';
46
- const readTime = story['read-time'] ? `${story['read-time']} min read` : '';
46
+ const readTime = story['read-time'] ? `${story['read-time']} ${translate('min read')}` : '';
47
47
 
48
48
  const throttledOnpress = throttle(props.onPress, 1000);
49
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
+
50
77
  return (
51
78
  <TouchableOpacity
52
79
  testID={COMP_GENERAL_CONSTANTS.primaryStoryCard}
@@ -61,13 +88,13 @@ export const PrimaryStoryCard = (props) => {
61
88
  imageWidth={props.imageWidth}
62
89
  >
63
90
  <Text style={styles.xminContainer}>
64
- {' '}
65
91
  {readTime && (
66
92
  <View style={styles.xmin}>
67
93
  <Text style={styles.xminText}>{readTime}</Text>
68
94
  </View>
69
95
  )}
70
96
  </Text>
97
+ <View style={styles.storyTypeContainer}>{showStoryType()}</View>
71
98
  </ResponsiveImage>
72
99
 
73
100
  <View style={styles.authorBlockContainer}>
@@ -39,4 +39,32 @@ export const storyStyles = (COLORS = {}, FONT_SIZE = {}, DARK_MODE = {}) => ({
39
39
  color: COLORS.BRAND_BLACK,
40
40
  fontSize: FONT_SIZE.h5,
41
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
+ },
42
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
- I18nManager, StyleSheet, TouchableOpacity, View,
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 '../../utils';
13
- import { getStoryHeadline } from '../../utils/story';
14
- import { ResponsiveImage, Text } from '../index';
15
- import { storyStyles } from './styles';
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 { COLORS, FONT_SIZE, locale } = theme || {};
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 = I18nManager.isRTL ? 'yyyy , MMM d' : 'd MMM, yyyy';
37
- const readTime = story['read-time'] ? `${story['read-time']} min read` : '';
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['published-at'], DATE_FORMAT, locale)}
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
- switchToNewDesign,
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
- switchToNewDesign: PropTypes.bool,
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
- paddingHorizontal: 4,
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,11 +26,11 @@ 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 = I18nManager.isRTL ? 'yyyy ,MMM d' : 'd MMM, yyyy';
33
+ const DATE_FORMAT = 'd MMM, yyyy';
34
34
 
35
35
  const containerStyle = StyleSheet.flatten([
36
36
  styles.container,
@@ -51,9 +51,38 @@ export const SecondaryStoryCard = (props) => {
51
51
  ]);
52
52
  const name = get(story.authors, [0, 'name']);
53
53
  const authorName = name ? `${translate('By')} ${name} | ` : '';
54
- const readTime = story['read-time'] ? `${story['read-time']} min read` : '';
54
+ const readTime = story['read-time'] ? `${story['read-time']} ${translate('min read')}` : '';
55
55
 
56
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
+
57
86
  return (
58
87
  <TouchableOpacity
59
88
  testID={COMP_GENERAL_CONSTANTS.secondaryStoryCard}
@@ -68,13 +97,13 @@ export const SecondaryStoryCard = (props) => {
68
97
  imageWidth={props.imageWidth}
69
98
  >
70
99
  <Text style={styles.xminContainer}>
71
- {' '}
72
100
  {readTime && (
73
101
  <View style={styles.xmin}>
74
102
  <Text style={styles.xminText}>{readTime}</Text>
75
103
  </View>
76
104
  )}
77
105
  </Text>
106
+ <View style={styles.storyTypeContainer}>{showStoryType()}</View>
78
107
  </ResponsiveImage>
79
108
  <View style={styles.headlineAndAuthorBlockContainer}>
80
109
  <Text
@@ -51,4 +51,32 @@ export const secStoryCardStyles = ({ COLORS, FONT_SIZE, DARK_MODE }) => StyleShe
51
51
  color: COLORS.BRAND_BLACK,
52
52
  fontSize: FONT_SIZE.h5,
53
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
+ },
54
82
  });
@@ -1,6 +1,6 @@
1
- import { throttle } from 'lodash';
2
- import PropTypes from 'prop-types';
3
- import React, { useContext, memo } from 'react';
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 '../../utils';
18
- import { getStoryHeadline } from '../../utils/story';
19
- import { ResponsiveImage, Text } from '../index';
20
- import { storyStyles } from './styles';
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 styles = storyStyles(theme);
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 = I18nManager.isRTL ? 'yyyy ,MMM d' : 'd MMM, yyyy';
42
- const readTime = story['read-time'] ? `${story['read-time']} min read` : '';
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['published-at'], DATE_FORMAT, locale)}
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, I18nManager,
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
- /* import {DailyMotionPlayer} from "../DailyMotionPlayer"; */
22
+ import { DailyMotionPlayer } from '../DailyMotionPlayer';
23
23
 
24
- const DATE_FORMAT = I18nManager.isRTL
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
- /* case "jsembed":{
50
- return <DailyMotionPlayer element={firstVideoElement} />;
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 (
@@ -27,7 +27,7 @@ export const Table = ({ card }) => {
27
27
  <View style={styles.tableRow}>
28
28
  {headerFields.map((headerField) => (
29
29
  <View style={styles.tableHeaderTitle}>
30
- <Text>{data[headerField]}</Text>
30
+ <Text style={styles.tableContect}>{data[headerField]}</Text>
31
31
  </View>
32
32
  ))}
33
33
  </View>
@@ -1,5 +1,4 @@
1
1
  import { StyleSheet } from 'react-native';
2
-
3
2
  export const tableStyles = ({ COLORS }) => StyleSheet.create({
4
3
  container: {
5
4
  flexDirection: 'row',
@@ -15,6 +14,7 @@ export const tableStyles = ({ COLORS }) => StyleSheet.create({
15
14
  justifyContent: 'center',
16
15
  borderWidth: 0.5,
17
16
  borderColor: COLORS.BRAND_4,
17
+ color: COLORS.BRAND_4,
18
18
  },
19
19
  tableBody: {
20
20
  flexDirection: 'column',
@@ -22,4 +22,7 @@ export const tableStyles = ({ COLORS }) => StyleSheet.create({
22
22
  tableRow: {
23
23
  flexDirection: 'row',
24
24
  },
25
- });
25
+ tableContect: {
26
+ color: COLORS.BRAND_BLACK,
27
+ },
28
+ });
@@ -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.BRAND_8,
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: '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',
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
  };