@quintype/native-components 2.20.9 → 2.20.11

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,15 @@
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.20.11](https://github.com/quintype/native-components/compare/v2.20.10...v2.20.11) (2023-08-10)
6
+
7
+ ### [2.20.10](https://github.com/quintype/native-components/compare/v2.20.9...v2.20.10) (2023-08-08)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **rich-text:** Changes html-render to strip-html to fix rtl :hamer: ([#208](https://github.com/quintype/native-components/issues/208)) ([1c6a1fd](https://github.com/quintype/native-components/commit/1c6a1fdafaa2833d846120e62c631fcb04c218ae))
13
+
5
14
  ### [2.20.9](https://github.com/quintype/native-components/compare/v2.20.8...v2.20.9) (2023-07-10)
6
15
 
7
16
  ### [2.20.8](https://github.com/quintype/native-components/compare/v2.20.7...v2.20.8) (2023-06-30)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.20.9",
3
+ "version": "2.20.11",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -30,9 +30,10 @@ export const PrimaryStoryCard = (props) => {
30
30
  locale,
31
31
  reverseTimeAdverbPosition,
32
32
  enableReadTimeOnStoryCards,
33
+ DATE_TIME_FORMAT,
33
34
  } = theme || {};
34
35
 
35
- const DATE_FORMAT = 'd MMM, yyyy';
36
+ const DATE_FORMAT = DATE_TIME_FORMAT.dateFormat;
36
37
 
37
38
  const styles = storyStyles(COLORS, FONT_SIZE);
38
39
  const containerStyle = StyleSheet.flatten([
@@ -27,6 +27,7 @@ const PrimaryStoryCardNewBase = (props) => {
27
27
  DARK_MODE,
28
28
  reverseTimeAdverbPosition,
29
29
  enableReadTimeOnStoryCards,
30
+ DATE_TIME_FORMAT,
30
31
  } = theme || {};
31
32
 
32
33
  const translate = get(theme, ['translate'], (word) => word);
@@ -45,7 +46,7 @@ const PrimaryStoryCardNewBase = (props) => {
45
46
  props.timestampStyle,
46
47
  ]);
47
48
 
48
- const DATE_FORMAT = 'd MMM, yyyy';
49
+ const DATE_FORMAT = DATE_TIME_FORMAT.dateFormat;
49
50
  const readTime = enableReadTimeOnStoryCards && story['read-time']
50
51
  ? `${story['read-time']} ${translate('min read')} · `
51
52
  : '';
@@ -34,11 +34,12 @@ export const SecondaryStoryCard = (props) => {
34
34
  COLORS,
35
35
  reverseTimeAdverbPosition,
36
36
  enableReadTimeOnStoryCards,
37
+ DATE_TIME_FORMAT,
37
38
  } = theme;
38
39
  const styles = secStoryCardStyles(theme);
39
40
  const { story = {} } = props;
40
41
 
41
- const DATE_FORMAT = 'd MMM, yyyy';
42
+ const DATE_FORMAT = DATE_TIME_FORMAT.dateFormat;
42
43
 
43
44
  const containerStyle = StyleSheet.flatten([
44
45
  styles.container,
@@ -32,6 +32,7 @@ const SecondaryStoryCardNewBase = (props) => {
32
32
  COLORS,
33
33
  reverseTimeAdverbPosition,
34
34
  enableReadTimeOnStoryCards,
35
+ DATE_TIME_FORMAT,
35
36
  } = theme;
36
37
 
37
38
  const translate = get(theme, ['translate'], (word) => word);
@@ -50,7 +51,7 @@ const SecondaryStoryCardNewBase = (props) => {
50
51
  props.timestampStyle,
51
52
  ]);
52
53
 
53
- const DATE_FORMAT = 'd MMM, yyyy';
54
+ const DATE_FORMAT = DATE_TIME_FORMAT.dateFormat;
54
55
  const readTime = enableReadTimeOnStoryCards && story['read-time']
55
56
  ? `${story['read-time']} ${translate('min read')} · `
56
57
  : '';
@@ -1,8 +1,12 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import { View, Linking } from 'react-native';
4
- import HTML from 'react-native-render-html';
5
- import { AppTheme, getScreenPercentageWidth } from '../../utils/index';
3
+ import { View } from 'react-native';
4
+ import {
5
+ AppTheme,
6
+ getScreenPercentageWidth,
7
+ stripHTML,
8
+ } from '../../utils/index';
9
+ import { Text } from '../index';
6
10
  import { LightBoxImage } from '../LightBoxImage';
7
11
  import { slideshowStoryCardStyles } from './styles';
8
12
 
@@ -10,7 +14,6 @@ export const SlideshowStoryCard = ({ card, cdn }) => {
10
14
  const attribution = card['image-attribution'];
11
15
  const { title } = card;
12
16
  const { theme } = useContext(AppTheme);
13
- const { CAN_COPY_TEXT } = theme;
14
17
  const styles = slideshowStoryCardStyles(theme);
15
18
  const imgData = {
16
19
  cdn,
@@ -23,24 +26,8 @@ export const SlideshowStoryCard = ({ card, cdn }) => {
23
26
  <View style={styles.container}>
24
27
  <LightBoxImage data={imgData} />
25
28
  <View style={styles.textContainer}>
26
- <HTML
27
- html={title}
28
- textSelectable={CAN_COPY_TEXT}
29
- key={Math.random()}
30
- baseFontStyle={styles.cardTitleText}
31
- onLinkPress={(e, href) => {
32
- Linking.openURL(href);
33
- }}
34
- />
35
- <HTML
36
- html={attribution}
37
- textSelectable={CAN_COPY_TEXT}
38
- key={Math.random()}
39
- baseFontStyle={styles.attributionText}
40
- onLinkPress={(e, href) => {
41
- Linking.openURL(href);
42
- }}
43
- />
29
+ <Text style={styles.cardTitleText}>{stripHTML(title)}</Text>
30
+ <Text style={styles.attributionText}>{stripHTML(attribution)}</Text>
44
31
  </View>
45
32
  </View>
46
33
  );
@@ -6,13 +6,13 @@ export const slideshowStoryCardStyles = ({ COLORS, FONT_FAMILY }) => StyleSheet.
6
6
  textContainer: {
7
7
  paddingHorizontal: 10,
8
8
  flexDirection: 'column',
9
- flexWrap: 'wrap',
10
- marginTop: 10,
9
+ marginVertical: 10,
11
10
  },
12
11
  cardTitleText: {
13
12
  opacity: 0.7,
14
13
  color: COLORS.BRAND_BLACK,
15
14
  fontFamily: FONT_FAMILY.secondary,
15
+ marginBottom: 5,
16
16
  },
17
17
  container: {
18
18
  flexDirection: 'column',
@@ -3,7 +3,6 @@ import React, { useContext, useState, useRef } from 'react';
3
3
  import {
4
4
  View,
5
5
  Modal,
6
- Linking,
7
6
  SafeAreaView,
8
7
  FlatList,
9
8
  TouchableOpacity,
@@ -11,15 +10,14 @@ import {
11
10
  } from 'react-native';
12
11
  import Icon from 'react-native-vector-icons/FontAwesome';
13
12
  import FastImage from 'react-native-fast-image';
14
- import HTML from 'react-native-render-html';
15
13
  import { styles } from './styles';
16
14
  import { Text } from '../index';
17
- import { AppTheme } from '../../utils/index';
15
+ import { AppTheme, stripHTML } from '../../utils/index';
18
16
  import { LightBoxImage } from '../LightBoxImage';
19
17
 
20
18
  export const StoryGallery = ({ cdn, card }) => {
21
19
  const { theme } = useContext(AppTheme);
22
- const { COLORS, DARK_MODE, CAN_COPY_TEXT } = theme;
20
+ const { COLORS, DARK_MODE } = theme;
23
21
  const galleryStyles = styles(theme);
24
22
  const storyElements = card['story-elements'];
25
23
  const [showModal, setShowModal] = useState(false);
@@ -111,24 +109,8 @@ export const StoryGallery = ({ cdn, card }) => {
111
109
  resizeMode={FastImage.resizeMode.contain}
112
110
  style={galleryStyles.carouselImage}
113
111
  />
114
- <HTML
115
- html={title}
116
- textSelectable={CAN_COPY_TEXT}
117
- key={Math.random()}
118
- baseFontStyle={galleryStyles.titleText}
119
- onLinkPress={(e, href) => {
120
- Linking.openURL(href);
121
- }}
122
- />
123
- <HTML
124
- html={attribution}
125
- textSelectable={CAN_COPY_TEXT}
126
- key={Math.random()}
127
- baseFontStyle={galleryStyles.attributionText}
128
- onLinkPress={(e, href) => {
129
- Linking.openURL(href);
130
- }}
131
- />
112
+ <Text style={galleryStyles.titleText}>{stripHTML(title)}</Text>
113
+ <Text style={galleryStyles.attributionText}>{stripHTML(attribution)}</Text>
132
114
  </ScrollView>
133
115
  );
134
116
  };
@@ -58,7 +58,6 @@ export const styles = ({ FONT_SIZE }) => {
58
58
  height: '80%',
59
59
  },
60
60
  wrapper: {
61
- paddingHorizontal: 10,
62
61
  flex: 1,
63
62
  backgroundColor: 'black',
64
63
  width: '100%',
@@ -69,7 +68,8 @@ export const styles = ({ FONT_SIZE }) => {
69
68
  opacity: 0.8,
70
69
  color: 'white',
71
70
  marginTop: 10,
72
- marginHorizontal: 10,
71
+ paddingHorizontal: 10,
72
+ marginBottom: 5,
73
73
  fontFamily: FONT_FAMILY.secondary,
74
74
  },
75
75
  attributionText: {
@@ -78,7 +78,7 @@ export const styles = ({ FONT_SIZE }) => {
78
78
  fontSize: FONT_SIZE.h3,
79
79
  opacity: 0.8,
80
80
  color: 'white',
81
- marginHorizontal: 10,
81
+ paddingHorizontal: 10,
82
82
  fontFamily: FONT_FAMILY.secondary,
83
83
  },
84
84
  leftArrow: {
@@ -108,11 +108,11 @@ export const styles = ({ FONT_SIZE }) => {
108
108
  justifyContent: 'center',
109
109
  },
110
110
  carouselImage: {
111
- width: '100%',
112
- height: 2*deviceHeight/3,
111
+ width: deviceWidth - 20,
112
+ height: (2 * deviceHeight) / 3,
113
113
  },
114
114
  carouselContainer: {
115
- width: deviceWidth - 10,
115
+ width: deviceWidth - 20,
116
116
  margin: 10,
117
117
  },
118
118
  showMoreImageContainer: {
@@ -1,15 +1,13 @@
1
1
  import get from 'lodash/get';
2
2
  import PropTypes from 'prop-types';
3
3
  import React, { useContext } from 'react';
4
- import {
5
- TouchableOpacity, View, Linking,
6
- } from 'react-native';
7
- import HTML from 'react-native-render-html';
4
+ import { TouchableOpacity, View } from 'react-native';
8
5
  import {
9
6
  getImageMetadata,
10
7
  getScreenPercentageWidth,
11
8
  getTimeInFormat,
12
9
  AppTheme,
10
+ stripHTML,
13
11
  } from '../../utils';
14
12
  import { STORY_TYPES } from '../../utils/story-types';
15
13
  import {
@@ -21,8 +19,6 @@ import { COMP_CONTENT_CONSTANTS } from '../../constants/component-constants/cont
21
19
 
22
20
  import { DailyMotionPlayer } from '../DailyMotionPlayer';
23
21
 
24
- const DATE_FORMAT = 'd MMMM yyyy h:mm a';
25
-
26
22
  const getHeroImage = (cdn, story) => {
27
23
  const imageSlug = story['hero-image-s3-key'];
28
24
  if (!imageSlug) return null;
@@ -68,38 +64,25 @@ export const StoryHeader = (props) => {
68
64
  const { story } = props;
69
65
  const sectionData = get(story, ['sections', 0], {});
70
66
  const { theme } = useContext(AppTheme);
67
+
71
68
  const {
72
- COLORS, CAN_COPY_TEXT, locale, FONT_FAMILY,
69
+ COLORS, locale, FONT_FAMILY, DATE_TIME_FORMAT,
73
70
  } = theme;
71
+
72
+ const DATE_FORMAT = `${DATE_TIME_FORMAT.dateFormat} ${DATE_TIME_FORMAT.timeFormat}`;
74
73
  const styles = storyHeaderStyles(COLORS, FONT_FAMILY);
75
- const imgCaption = story['hero-image-caption'];
76
- const attri = story['hero-image-attribution'];
77
- const imgAttribution = imgCaption && attri ? ` | ${attri}` : attri;
74
+ const caption = story['hero-image-caption'];
75
+ const attribution = story['hero-image-attribution'];
76
+
78
77
 
79
78
  const showAttribution = () => {
80
- if (!imgCaption && !imgAttribution) {
79
+ if (!caption && !attribution) {
81
80
  return null;
82
81
  }
83
82
  return (
84
83
  <View style={styles.captionContainerStyle}>
85
- <HTML
86
- html={imgCaption}
87
- textSelectable={CAN_COPY_TEXT}
88
- key={Math.random()}
89
- baseFontStyle={styles.captionStyle}
90
- onLinkPress={(evt, href) => {
91
- Linking.openURL(href);
92
- }}
93
- />
94
- <HTML
95
- html={attri}
96
- textSelectable={CAN_COPY_TEXT}
97
- key={Math.random()}
98
- baseFontStyle={styles.attributionStyle}
99
- onLinkPress={(evt, href) => {
100
- Linking.openURL(href);
101
- }}
102
- />
84
+ <Text style={styles.captionStyle}>{stripHTML(caption)}</Text>
85
+ <Text style={styles.attributionStyle}>{stripHTML(attribution)}</Text>
103
86
  </View>
104
87
  );
105
88
  };
@@ -26,11 +26,10 @@ export const storyHeaderStyles = (COLORS, FONT_FAMILY) => StyleSheet.create({
26
26
  opacity: 0.8,
27
27
  },
28
28
  captionStyle: {
29
- padding: 10,
30
- paddingBottom: 0,
31
29
  color: COLORS.BRAND_BLACK,
32
30
  fontFamily: FONT_FAMILY.secondary,
33
31
  opacity: 0.8,
32
+ marginBottom: 5,
34
33
  },
35
34
  attributionStyle: {
36
35
  color: COLORS.BRAND_BLACK,
@@ -38,10 +37,8 @@ export const storyHeaderStyles = (COLORS, FONT_FAMILY) => StyleSheet.create({
38
37
  opacity: 0.8,
39
38
  },
40
39
  captionContainerStyle: {
41
- paddingHorizontal: 5,
40
+ padding: 10,
42
41
  flexDirection: 'column',
43
- flexWrap: 'wrap',
44
- marginTop: 10,
45
42
  },
46
43
  sectionText: {
47
44
  color: COLORS.BRAND_1,
@@ -24,24 +24,15 @@ export const StoryImage = ({
24
24
 
25
25
  const styles = storyImageStyles(theme, imageData.metaData);
26
26
 
27
- const getAttributionElement = () => {
28
- if (!card['image-attribution']) return null;
29
- return (
30
- <Text style={styles.attributionText}>
31
- {` | ${stripHTML(card['image-attribution'])}`}
32
- </Text>
33
- );
34
- };
35
-
36
27
  return (
37
28
  <>
38
29
  <LightBoxImage data={imageData} currentLayout={currentLayout} />
39
30
 
40
31
  <View style={styles.titleContainer}>
41
32
  <View style={styles.imageMeta}>
42
- <Text style={styles.cardTitleText}>
43
- {stripHTML(card.title)}
44
- {getAttributionElement()}
33
+ <Text style={styles.cardTitleText}>{stripHTML(card.title)}</Text>
34
+ <Text style={styles.attributionText}>
35
+ {stripHTML(card['image-attribution'])}
45
36
  </Text>
46
37
  </View>
47
38
  {sharePhotoCard && (
@@ -59,4 +50,5 @@ StoryImage.propTypes = {
59
50
  cdn: PropTypes.string.isRequired,
60
51
  share: PropTypes.func.isRequired,
61
52
  currentLayout: PropTypes.object,
53
+ storyType: PropTypes.string,
62
54
  };
@@ -20,15 +20,15 @@ export const storyImageStyles = ({ COLORS, FONT_SIZE }, metadata = {}) => {
20
20
  fontSize: FONT_SIZE.h5,
21
21
  lineHeight: FONT_SIZE.h5 * 1.3,
22
22
  color: COLORS.BRAND_BLACK,
23
+ marginBottom: 5,
23
24
  },
24
25
  attributionText: {
25
26
  fontSize: FONT_SIZE.h5,
26
27
  lineHeight: FONT_SIZE.h5 * 1.3,
27
28
  color: COLORS.IMAGE_LIGHTGREY,
29
+ marginBottom: 5,
28
30
  },
29
31
  imageMeta: {
30
- flexDirection: 'row',
31
- alignItems: 'center',
32
32
  width: '85%',
33
33
  },
34
34
  });
@@ -45,3 +45,8 @@ export const FONT_FAMILY = {
45
45
  export const CAN_COPY_TEXT = false;
46
46
  export const NETWORK_TYPE = '3g';
47
47
  export const IMAGE_QUALITY = '30';
48
+
49
+ export const DATE_TIME_FORMAT = {
50
+ dateFormat: 'dd MMM yyyy',
51
+ timeFormat: 'h:mm aa',
52
+ };
@@ -6,6 +6,7 @@ import {
6
6
  CAN_COPY_TEXT,
7
7
  NETWORK_TYPE,
8
8
  IMAGE_QUALITY,
9
+ DATE_TIME_FORMAT,
9
10
  } from '../themes/theme';
10
11
 
11
12
  export const THEME_CONFIG = {
@@ -16,5 +17,6 @@ export const THEME_CONFIG = {
16
17
  NETWORK_TYPE,
17
18
  locale: 'enIN',
18
19
  IMAGE_QUALITY,
20
+ DATE_TIME_FORMAT,
19
21
  };
20
22
  export const AppTheme = createContext(THEME_CONFIG);