@quintype/native-components 2.20.31 → 2.20.32-beta.2

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,12 +2,6 @@
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.31](https://github.com/quintype/native-components/compare/v2.20.30...v2.20.31) (2024-06-04)
6
-
7
- ### [2.20.30](https://github.com/quintype/native-components/compare/v2.20.29...v2.20.30) (2024-06-04)
8
-
9
- ### [2.20.29](https://github.com/quintype/native-components/compare/v2.20.28...v2.20.29) (2024-06-04)
10
-
11
5
  ### [2.20.28](https://github.com/quintype/native-components/compare/v2.20.27...v2.20.28) (2024-05-17)
12
6
 
13
7
  ### [2.20.27](https://github.com/quintype/native-components/compare/v2.20.26...v2.20.27) (2024-05-17)
@@ -1,15 +1,15 @@
1
- #!/bin/bash -e
1
+ # #!/bin/bash -e
2
2
 
3
- npm install
4
- git diff --quiet
3
+ # npm install
4
+ # git diff --quiet
5
5
 
6
- BRANCH=$(git symbolic-ref --short HEAD)
6
+ # BRANCH=$(git symbolic-ref --short HEAD)
7
7
 
8
- if [ "$BRANCH" == 'master' ]
9
- then
10
- npx standard-version
11
- else
12
- npx standard-version --prerelease "$(git symbolic-ref --short HEAD | sed s:/:-:g )" --skip.changelog=true
13
- fi
8
+ # if [ "$BRANCH" == 'master' ]
9
+ # then
10
+ # npx standard-version
11
+ # else
12
+ # npx standard-version --prerelease "$(git symbolic-ref --short HEAD | sed s:/:-:g )" --skip.changelog=true
13
+ # fi
14
14
 
15
- git push --follow-tags origin "$BRANCH"
15
+ # git push --follow-tags origin "$BRANCH"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.20.31",
3
+ "version": "2.20.32-beta.2",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -23,8 +23,7 @@
23
23
  "react-native-pdf": "^5.1.4",
24
24
  "react-native-render-html": "^4.2.3",
25
25
  "react-native-share": "^8.1.0",
26
- "rn-fetch-blob": "^0.10.16",
27
- "react-native-star-rating-widget": "^1.7.3"
26
+ "rn-fetch-blob": "^0.10.16"
28
27
  },
29
28
  "peerDependencies": {
30
29
  "@react-navigation/native": ">=5.7.3",
@@ -1,10 +1,18 @@
1
- import React, { useContext } from "react";
2
- import Icon from "react-native-vector-icons/FontAwesome";
3
- import { AppTheme } from "../../utils";
1
+ import React from "react";
2
+ import Icon from "react-native-vector-icons/Ionicons";
3
+ import PropTypes from "prop-types";
4
4
 
5
- export const FallbackIcon = () => {
6
- const { theme } = useContext(AppTheme);
7
- const { COLORS } = theme;
5
+ const DEFAULT_FALLBACK_SIZE = 25;
8
6
 
9
- return <Icon name="image" size={25} color={COLORS.MONO4} />;
7
+ export const FallbackIcon = ({ size = DEFAULT_FALLBACK_SIZE, color }) => (
8
+ <Icon
9
+ name="images"
10
+ size={size}
11
+ color={color}
12
+ />
13
+ );
14
+
15
+ FallbackIcon.propTypes = {
16
+ size: PropTypes.number,
17
+ color: PropTypes.string,
10
18
  };
@@ -1,20 +1,22 @@
1
1
  import get from 'lodash/get';
2
2
  import isEmpty from 'lodash/isEmpty';
3
3
  import PropTypes from 'prop-types';
4
- import React from 'react';
4
+ import React, { memo } from 'react';
5
5
  import { getScreenPercentageWidth } from '../../utils/index';
6
6
  import {
7
7
  CollectionTitle,
8
8
  PrimaryStoryCard,
9
9
  SecondaryStoryCard,
10
+ ShareButton,
10
11
  } from '../index';
11
12
 
12
- export const CollectionCard = ({
13
+ const CollectionCardNewBase = ({
13
14
  cdn,
14
15
  collectionName,
15
16
  stories,
16
17
  onCollectionPress,
17
18
  onStoryPress,
19
+ collectionTestID,
18
20
  offset,
19
21
  horizontalPadding,
20
22
  initialOffset, /* Number of items to load on first load */
@@ -22,10 +24,10 @@ export const CollectionCard = ({
22
24
  }) => {
23
25
  const sliceLimit = offset || initialOffset || 5;
24
26
  const primaryStory = !isEmpty(stories) && get(stories, [0, 'story'], stories[0]);
27
+
25
28
  return (
26
29
  <>
27
- {!hideCollectionTitle
28
- && (
30
+ {!hideCollectionTitle && (
29
31
  <CollectionTitle
30
32
  title={collectionName}
31
33
  onPress={onCollectionPress}
@@ -33,11 +35,13 @@ export const CollectionCard = ({
33
35
  />
34
36
  )}
35
37
  <PrimaryStoryCard
38
+ collectionTestID={collectionTestID}
36
39
  onPress={() => {
37
40
  !isEmpty(stories) && onStoryPress(primaryStory);
38
41
  }}
39
42
  cdn={cdn}
40
43
  story={!isEmpty(stories) ? primaryStory : {}}
44
+ iconComponent={<ShareButton story={primaryStory} />}
41
45
  imageWidth={getScreenPercentageWidth(100) - 2 * horizontalPadding}
42
46
  horizontalPadding={horizontalPadding}
43
47
  />
@@ -45,11 +49,13 @@ export const CollectionCard = ({
45
49
  const secondaryStory = get(currentStory, ['story'], currentStory);
46
50
  return (
47
51
  <SecondaryStoryCard
52
+ collectionTestID={collectionTestID}
48
53
  onPress={() => onStoryPress(secondaryStory)}
49
- key={`${secondaryStory?.id}`}
54
+ key={secondaryStory?.id}
50
55
  cdn={cdn}
51
56
  story={secondaryStory}
52
- imageWidth={getScreenPercentageWidth(40)}
57
+ iconComponent={<ShareButton story={secondaryStory} />}
58
+ imageWidth={getScreenPercentageWidth(25)}
53
59
  horizontalPadding={horizontalPadding}
54
60
  />
55
61
  );
@@ -57,18 +63,22 @@ export const CollectionCard = ({
57
63
  </>
58
64
  );
59
65
  };
60
- CollectionCard.propTypes = {
66
+
67
+ CollectionCardNewBase.propTypes = {
68
+ offset: PropTypes.number,
61
69
  initialOffset: PropTypes.number,
62
70
  cdn: PropTypes.string.isRequired,
63
- collectionName: PropTypes.string.isRequired,
71
+ collectionName: PropTypes.string,
64
72
  stories: PropTypes.array.isRequired,
65
73
  onCollectionPress: PropTypes.func,
66
74
  onStoryPress: PropTypes.func,
67
- offset: PropTypes.number,
75
+ collectionTestID: PropTypes.string,
68
76
  horizontalPadding: PropTypes.number,
69
77
  hideCollectionTitle: PropTypes.bool,
70
78
  };
71
79
 
72
- CollectionCard.defaultProps = {
80
+ CollectionCardNewBase.defaultProps = {
73
81
  horizontalPadding: 12,
74
82
  };
83
+
84
+ export const CollectionCard = memo(CollectionCardNewBase);
@@ -1,61 +1,44 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { useContext } from 'react';
2
+ import React, { useContext, memo } from 'react';
3
3
  import {
4
4
  TextStyle,
5
5
  TouchableOpacity,
6
6
  TouchableOpacityProps,
7
- View,
8
- ViewStyle,
9
7
  StyleSheet,
10
8
  } from 'react-native';
11
-
12
9
  import { Text } from '../index';
13
-
14
- import { collectionStyles } from './styles';
10
+ import { collectionTitleStyles } from './styles';
15
11
  import { AppTheme } from '../../utils';
16
- import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
17
12
 
18
- export const CollectionTitle = (props) => {
13
+ const CollectionTitleNewBase = (props) => {
19
14
  const { theme } = useContext(AppTheme);
20
- const styles = collectionStyles(theme);
15
+ const styles = collectionTitleStyles(theme);
21
16
  const containerStyle = StyleSheet.flatten([
22
- styles.titleContainer,
17
+ styles.container,
23
18
  { paddingHorizontal: props.horizontalPadding },
24
19
  ]);
25
- const titleStyle = StyleSheet.flatten([styles.titleStyle, props.titleStyle]);
26
- const indicatorStyle = StyleSheet.flatten([
27
- styles.indicatorStyle,
28
- props.indicatorStyle,
29
- ]);
20
+ const titleStyle = StyleSheet.flatten([styles.title, props.titleStyle]);
30
21
 
31
22
  if (!props.title) {
32
23
  return null;
33
24
  }
34
25
 
35
26
  return (
36
- <TouchableOpacity
37
- style={containerStyle}
38
- onPress={props.onPress}
39
- testID={COMP_GENERAL_CONSTANTS.collectionTitleTouch}
40
- >
41
- <Text
42
- style={titleStyle}
43
- testID={COMP_GENERAL_CONSTANTS.collectionTitleText}
44
- >
45
- {props.title}
46
- </Text>
47
- <View style={indicatorStyle} />
27
+ <TouchableOpacity style={containerStyle} onPress={props.onPress}>
28
+ <Text style={titleStyle}>{props.title}</Text>
48
29
  </TouchableOpacity>
49
30
  );
50
31
  };
51
32
 
52
- CollectionTitle.propTypes = TouchableOpacityProps && {
53
- title: PropTypes.string,
54
- titleStyle: TextStyle,
55
- indicatorStyle: ViewStyle,
56
- horizontalPadding: PropTypes.number,
57
- };
33
+ CollectionTitleNewBase.propTypes = TouchableOpacityProps
34
+ && {
35
+ title: PropTypes.string,
36
+ titleStyle: TextStyle,
37
+ horizontalPadding: PropTypes.number,
38
+ };
58
39
 
59
- CollectionTitle.defaultProps = {
40
+ CollectionTitleNewBase.defaultProps = {
60
41
  horizontalPadding: 12,
61
42
  };
43
+
44
+ export const CollectionTitle = memo(CollectionTitleNewBase);
@@ -1,22 +1,19 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- export const collectionStyles = (appThemeContext) => {
3
+ export const collectionTitleStyles = (appThemeContext) => {
4
4
  const { COLORS, FONT_SIZE } = appThemeContext;
5
+
5
6
  return StyleSheet.create({
6
- titleContainer: {
7
- backgroundColor: COLORS.BRAND_WHITE,
8
- paddingVertical: 12,
7
+ container: {
9
8
  justifyContent: 'center',
9
+ backgroundColor: COLORS.BRAND_WHITE,
10
+ paddingHorizontal: 12,
11
+ paddingVertical: 8,
12
+ marginTop: 8,
10
13
  },
11
- titleStyle: {
12
- fontSize: FONT_SIZE.h1,
14
+ title: {
15
+ fontSize: FONT_SIZE.h3,
13
16
  color: COLORS.BRAND_5,
14
17
  },
15
- indicatorStyle: {
16
- marginTop: 8,
17
- width: 30,
18
- height: 3,
19
- backgroundColor: COLORS.BRAND_1,
20
- },
21
18
  });
22
19
  };
@@ -1,7 +1,6 @@
1
- import { throttle } from 'lodash';
2
- import get from 'lodash/get';
1
+ import { get, throttle } from 'lodash';
3
2
  import PropTypes from 'prop-types';
4
- import React, { useContext } from 'react';
3
+ import React, { useContext, memo } from 'react';
5
4
  import { StyleSheet, TouchableOpacity, View } from 'react-native';
6
5
  import Icon from 'react-native-vector-icons/FontAwesome';
7
6
  import {
@@ -17,25 +16,25 @@ import {
17
16
  COMP_GENERAL_CONSTANTS,
18
17
  COMP_CONTENT_CONSTANTS,
19
18
  } from '../../constants/component-constants';
19
+ import PremiumIcons from '../../Icons/PremiumIcons/index';
20
20
 
21
- export const PrimaryStoryCard = (props) => {
21
+ const PrimaryStoryCardNewBase = (props) => {
22
22
  const { story = {} } = props;
23
23
  const { theme } = useContext(AppTheme);
24
-
25
- const translate = get(theme, ['translate'], (word) => word);
26
-
27
24
  const {
28
25
  COLORS,
29
26
  FONT_SIZE,
30
27
  locale,
28
+ DARK_MODE,
31
29
  reverseTimeAdverbPosition,
32
30
  enableReadTimeOnStoryCards,
33
31
  DATE_TIME_FORMAT,
32
+ premiumIcon
34
33
  } = theme || {};
35
34
 
36
- const DATE_FORMAT = DATE_TIME_FORMAT.dateFormat;
35
+ const translate = get(theme, ['translate'], (word) => word);
37
36
 
38
- const styles = storyStyles(COLORS, FONT_SIZE);
37
+ const styles = storyStyles(COLORS, FONT_SIZE, DARK_MODE);
39
38
  const containerStyle = StyleSheet.flatten([
40
39
  styles.container,
41
40
  { paddingHorizontal: props.horizontalPadding },
@@ -44,16 +43,16 @@ export const PrimaryStoryCard = (props) => {
44
43
  styles.headline,
45
44
  props.headlineStyle,
46
45
  ]);
47
- const autorStyle = StyleSheet.flatten([
48
- styles.autorText,
49
- props.authorTextStyle,
46
+ const timestampStyle = StyleSheet.flatten([
47
+ styles.timestamp,
48
+ props.timestampStyle,
50
49
  ]);
51
50
 
52
- const name = get(story.authors, [0, 'name']);
53
- const authorName = name ? `${translate('By')} ${name} | ` : '';
51
+ const DATE_FORMAT = DATE_TIME_FORMAT.dateFormat;
54
52
  const readTime = enableReadTimeOnStoryCards && story['read-time']
55
- ? `${story['read-time']} ${translate('min read')}`
53
+ ? `${story['read-time']} ${translate('min read')} · `
56
54
  : '';
55
+ const isPremiumStory = story['access'] === 'subscription';
57
56
 
58
57
  const throttledOnpress = throttle(props.onPress, 1000);
59
58
 
@@ -97,54 +96,60 @@ export const PrimaryStoryCard = (props) => {
97
96
  cdn={props.cdn}
98
97
  imageWidth={props.imageWidth}
99
98
  >
100
- <Text style={styles.xminContainer}>
101
- {readTime && (
102
- <View style={styles.xmin}>
103
- <Text style={styles.xminText}>{readTime}</Text>
104
- </View>
105
- )}
106
- </Text>
107
99
  <View style={styles.storyTypeContainer}>{showStoryType()}</View>
108
100
  </ResponsiveImage>
109
- <Text
110
- style={autorStyle}
111
- numberOfLines={2}
112
- // TODO: Add corrected testID here
113
- testID={COMP_CONTENT_CONSTANTS.authorName}
114
- >
115
- {authorName
116
- + getTimeForStoryCards(
117
- story['published-at'],
118
- DATE_FORMAT,
119
- locale,
120
- translate,
121
- reverseTimeAdverbPosition,
122
- )}
123
- </Text>
124
- <Text
125
- primary
126
- numberOfLines={3}
127
- ellipsizeMode="tail"
128
- style={headlineStyle}
129
- testID={COMP_GENERAL_CONSTANTS.primaryStoryHeadline}
130
- >
131
- {getStoryHeadline(story)}
132
- </Text>
101
+ <View style={styles.contentContainer}>
102
+ <View style={styles.headlineAndTimestampContainer}>
103
+ <View style={{display:'flex', flexDirection:'row'}}>
104
+
105
+
106
+ <Text
107
+ primary
108
+ numberOfLines={3}
109
+ ellipsizeMode="tail"
110
+ style={headlineStyle}
111
+ testID={COMP_GENERAL_CONSTANTS.primaryStoryHeadline}
112
+ >
113
+ {isPremiumStory && premiumIcon !=='none' && <PremiumIcons style={styles.premiumIcon} name={premiumIcon} color={COLORS.primary} size={FONT_SIZE.h2} /> }
114
+ {isPremiumStory && premiumIcon !=='none' && ' '}
115
+ {getStoryHeadline(story)}
116
+ </Text>
117
+ </View>
118
+ <Text
119
+ style={timestampStyle}
120
+ numberOfLines={2}
121
+ testID={COMP_CONTENT_CONSTANTS.publishedDate}
122
+ >
123
+ {readTime
124
+ + getTimeForStoryCards(
125
+ story['published-at'],
126
+ DATE_FORMAT,
127
+ locale,
128
+ translate,
129
+ reverseTimeAdverbPosition,
130
+ )}
131
+ </Text>
132
+ </View>
133
+ <View style={styles.icon}>{props.iconComponent}</View>
134
+ </View>
133
135
  </TouchableOpacity>
134
136
  );
135
137
  };
136
138
 
137
- PrimaryStoryCard.propTypes = {
139
+ PrimaryStoryCardNewBase.propTypes = {
138
140
  cdn: PropTypes.string,
139
141
  imageWidth: PropTypes.number,
140
142
  headlineStyle: PropTypes.func,
141
- authorTextStyle: PropTypes.func,
143
+ timestampStyle: PropTypes.func,
142
144
  story: PropTypes.object.isRequired,
143
145
  onPress: PropTypes.func,
144
146
  horizontalPadding: PropTypes.number,
147
+ iconComponent: PropTypes.element,
145
148
  };
146
149
 
147
- PrimaryStoryCard.defaultProps = {
150
+ PrimaryStoryCardNewBase.defaultProps = {
148
151
  cdn: '',
149
152
  horizontalPadding: 12,
150
153
  };
154
+
155
+ export const PrimaryStoryCard = memo(PrimaryStoryCardNewBase);
@@ -1,39 +1,32 @@
1
- export const storyStyles = (COLORS = {}, FONT_SIZE = {}, DARK_MODE = {}) => ({
1
+ export const storyStyles = (COLORS = {}, FONT_SIZE = {}) => ({
2
2
  container: {
3
3
  backgroundColor: COLORS.BRAND_WHITE,
4
- marginTop: 12,
4
+ padding: 8,
5
5
  },
6
- autorText: {
7
- color: COLORS?.BRAND_6,
8
- fontSize: FONT_SIZE.h5,
9
- lineHeight: FONT_SIZE.h5 * 1.3,
10
- paddingVertical: 8,
6
+ contentContainer: {
7
+ flexDirection: 'row',
8
+ justifyContent: 'space-between',
9
+ alignItems: 'center',
10
+ },
11
+ headlineAndTimestampContainer: {
12
+ flexShrink: 1,
13
+ flex: 1,
11
14
  },
12
- divider: {
13
- backgroundColor: COLORS.BRAND_6,
14
- height: 12,
15
- marginHorizontal: 5,
16
- width: 1,
15
+ timestamp: {
16
+ color: COLORS?.BRAND_BLACK,
17
+ fontSize: FONT_SIZE.h5,
18
+ lineHeight: FONT_SIZE.h5 * 1.5,
19
+ opacity: 0.6,
20
+ marginTop: 4,
17
21
  },
18
22
  headline: {
19
23
  fontSize: FONT_SIZE.title,
20
- lineHeight: FONT_SIZE.title * 1.5,
24
+ lineHeight: FONT_SIZE.title * 1.6,
21
25
  color: COLORS.BRAND_BLACK,
22
- opacity: 0.9,
26
+ marginTop: 4,
23
27
  },
24
- xminContainer: {
25
- position: 'absolute',
26
- bottom: 8,
27
- right: 8,
28
- },
29
- xmin: {
30
- backgroundColor: DARK_MODE ? COLORS.MONO6 : COLORS.BRAND_WHITE,
31
- paddingLeft: 8,
32
- paddingRight: 8,
33
- },
34
- xminText: {
35
- color: COLORS.BRAND_BLACK,
36
- fontSize: FONT_SIZE.h5,
28
+ icon: {
29
+ marginLeft: 8,
37
30
  },
38
31
  storyTypeContainer: {
39
32
  position: 'absolute',
@@ -63,4 +56,8 @@ export const storyStyles = (COLORS = {}, FONT_SIZE = {}, DARK_MODE = {}) => ({
63
56
  borderRadius: 50,
64
57
  backgroundColor: COLORS.BRAND_3,
65
58
  },
59
+ premiumIcon: {
60
+ marginTop: FONT_SIZE.h3 * 0.92,
61
+ marginRight: 5,
62
+ },
66
63
  });
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import React, { useContext } from 'react';
4
4
  import { Text, View ,I18nManager} from 'react-native';
5
5
  import { getScreenPercentageWidth, AppTheme } from '../../utils/index';
6
- import { SecondaryStoryCard, SecondaryStoryCardNew, ShareButton } from '../index';
6
+ import { SecondaryStoryCard, ShareButton } from '../index';
7
7
 
8
8
  import { relatedStoriesStyles } from './styles';
9
9
 
@@ -15,8 +15,7 @@ export const RelatedStoriesCard = ({
15
15
  onStoryPress,
16
16
  collectionTestID,
17
17
  RelatedCardID,
18
- title,
19
- switchToNewDesign,
18
+ title
20
19
  }) => {
21
20
  const sliceLimit = 5;
22
21
 
@@ -41,19 +40,12 @@ export const RelatedStoriesCard = ({
41
40
  onPress: () => onStoryPress(secondaryStory),
42
41
  key: secondaryStory?.id,
43
42
  };
44
- return switchToNewDesign ? (
45
- <SecondaryStoryCardNew
43
+ return <SecondaryStoryCard
46
44
  {...storyCardProps}
47
45
  iconComponent={<ShareButton story={secondaryStory} />}
48
46
  imageWidth={getScreenPercentageWidth(25)}
49
47
  horizontalPadding={4}
50
48
  />
51
- ) : (
52
- <SecondaryStoryCard
53
- {...storyCardProps}
54
- imageWidth={getScreenPercentageWidth(40)}
55
- />
56
- );
57
49
  })}
58
50
  </View>
59
51
  </>
@@ -65,6 +57,5 @@ RelatedStoriesCard.propTypes = {
65
57
  onStoryPress: PropTypes.func,
66
58
  collectionTestID: PropTypes.string,
67
59
  RelatedCardID: PropTypes.string,
68
- title:PropTypes.string,
69
- switchToNewDesign: PropTypes.bool,
60
+ title:PropTypes.string
70
61
  };
@@ -33,7 +33,7 @@ const ResponsiveImageBase = (props) => {
33
33
 
34
34
  const placeholderStyle = {
35
35
  ...StyleSheet.absoluteFillObject,
36
- backgroundColor: (CustomFallBackIcon && CustomFallBackBackground) ?? COLORS.MONO6,
36
+ backgroundColor: CustomFallBackBackground || COLORS.MONO6,
37
37
  justifyContent: 'center',
38
38
  alignItems: 'center',
39
39
  };