@quintype/native-components 2.22.5-beta.0 → 2.22.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/package.json +1 -1
- package/src/components/AlsoRead/index.js +4 -4
- package/src/components/AuthorRow/index.js +3 -3
- package/src/components/BackNavigator/index.js +6 -6
- package/src/components/Button/index.js +1 -1
- package/src/components/CollectionCard/index.js +10 -20
- package/src/components/CollectionCardNew/index.js +84 -0
- package/src/components/CollectionTitle/CollectionTitle.test.js +12 -0
- package/src/components/CollectionTitle/__snapshots__/CollectionTitle.test.js.snap +3 -0
- package/src/components/CollectionTitle/index.js +38 -19
- package/src/components/CollectionTitle/styles.js +13 -11
- package/src/components/CollectionTitleNew/index.js +44 -0
- package/src/components/CollectionTitleNew/styles.js +20 -0
- package/src/components/CustomSwitch/index.js +4 -4
- package/src/components/DailyMotionPlayer/index.js +2 -2
- package/src/components/Header/index.js +2 -2
- package/src/components/Html/index.js +4 -4
- package/src/components/IconText/index.js +4 -4
- package/src/components/JSEmbedElement/index.js +35 -6
- package/src/components/LightBoxImage/index.js +2 -2
- package/src/components/PDFReader/index.js +8 -7
- package/src/components/PrimaryStoryCard/PrimaryStoryCard.test.js +43 -0
- package/src/components/PrimaryStoryCard/index.js +63 -44
- package/src/components/PrimaryStoryCard/styles.js +28 -32
- package/src/components/PrimaryStoryCardNew/index.js +134 -0
- package/src/components/PrimaryStoryCardNew/styles.js +70 -0
- package/src/components/RadioButton/index.js +3 -3
- package/src/components/Rating/index.js +1 -1
- package/src/components/RelatedStoriesCard/index.js +12 -2
- package/src/components/SecondaryStoryCard/SecondaryStoryCard.test.js +51 -0
- package/src/components/SecondaryStoryCard/index.js +62 -37
- package/src/components/SecondaryStoryCard/styles.js +34 -37
- package/src/components/SecondaryStoryCardNew/index.js +140 -0
- package/src/components/SecondaryStoryCardNew/styles.js +82 -0
- package/src/components/Story/index.js +13 -12
- package/src/components/StoryHeader/index.js +8 -8
- package/src/components/StoryText/index.js +2 -5
- package/src/components/Text/index.js +1 -3
- package/src/components/TextA/index.js +4 -4
- package/src/components/TextBigFact/index.js +4 -4
- package/src/components/TextBlockQuote/index.js +5 -5
- package/src/components/TextBlurb/index.js +3 -3
- package/src/components/TextQandA/index.js +3 -2
- package/src/components/index.js +4 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { cleanup, render, fireEvent } from '@testing-library/react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import 'react-native';
|
|
4
|
+
import { mockContext } from '../../utils';
|
|
5
|
+
import { PrimaryStoryCard } from './index';
|
|
6
|
+
import { data } from '../../constants/test-data/story.json';
|
|
7
|
+
import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
|
|
8
|
+
|
|
9
|
+
const storyData = data.story;
|
|
10
|
+
const onPress = jest.fn();
|
|
11
|
+
|
|
12
|
+
describe('Test Primary Story Card :', () => {
|
|
13
|
+
afterEach(cleanup);
|
|
14
|
+
test('renders author name properly', () => {
|
|
15
|
+
const { getByTestId } = render(
|
|
16
|
+
mockContext(<PrimaryStoryCard story={storyData} />),
|
|
17
|
+
);
|
|
18
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.primaryStoryAuthor);
|
|
19
|
+
expect(element.props.children).toBe('By Raghavendra Vaidya | ');
|
|
20
|
+
});
|
|
21
|
+
test('renders story headline properly', () => {
|
|
22
|
+
const { getByTestId } = render(
|
|
23
|
+
mockContext(<PrimaryStoryCard story={storyData} />),
|
|
24
|
+
);
|
|
25
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.primaryStoryHeadline);
|
|
26
|
+
expect(element.props.children).toBe('Jack and jill');
|
|
27
|
+
});
|
|
28
|
+
test('renders story publish date properly', () => {
|
|
29
|
+
const { getByTestId } = render(
|
|
30
|
+
mockContext(<PrimaryStoryCard story={storyData} />),
|
|
31
|
+
);
|
|
32
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.primaryStoryPubishedAt);
|
|
33
|
+
expect(element.props.children).toBe('1 Feb, 2021');
|
|
34
|
+
});
|
|
35
|
+
test('OnPress handler called properly', () => {
|
|
36
|
+
const { getByTestId } = render(
|
|
37
|
+
mockContext(<PrimaryStoryCard story={storyData} onPress={onPress} />),
|
|
38
|
+
);
|
|
39
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.primaryStoryCard);
|
|
40
|
+
fireEvent(element, 'press');
|
|
41
|
+
expect(onPress).toHaveBeenCalled();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { throttle } from 'lodash';
|
|
2
|
+
import get from 'lodash/get';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import React, {
|
|
4
|
+
import React, { useContext } from 'react';
|
|
4
5
|
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
5
6
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
6
|
-
import PremiumIcons from '../../Icons/PremiumIcons/index';
|
|
7
|
-
import {
|
|
8
|
-
COMP_GENERAL_CONSTANTS,
|
|
9
|
-
} from '../../constants/component-constants';
|
|
10
7
|
import {
|
|
11
8
|
AppTheme,
|
|
12
9
|
getImageMetadata,
|
|
13
10
|
getImageSlug,
|
|
11
|
+
getTimeForStoryCards,
|
|
14
12
|
} from '../../utils';
|
|
15
13
|
import { getStoryHeadline } from '../../utils/story';
|
|
16
|
-
import { ResponsiveImage,
|
|
14
|
+
import { ResponsiveImage, Text } from '../index';
|
|
17
15
|
import { storyStyles } from './styles';
|
|
16
|
+
import {
|
|
17
|
+
COMP_GENERAL_CONSTANTS,
|
|
18
|
+
COMP_CONTENT_CONSTANTS,
|
|
19
|
+
} from '../../constants/component-constants';
|
|
18
20
|
|
|
19
|
-
const
|
|
21
|
+
export const PrimaryStoryCard = (props) => {
|
|
20
22
|
const { story = {} } = props;
|
|
21
23
|
const { theme } = useContext(AppTheme);
|
|
24
|
+
|
|
25
|
+
const translate = get(theme, ['translate'], (word) => word);
|
|
26
|
+
|
|
22
27
|
const {
|
|
23
28
|
COLORS,
|
|
24
29
|
FONT_SIZE,
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
locale,
|
|
31
|
+
reverseTimeAdverbPosition,
|
|
32
|
+
enableReadTimeOnStoryCards,
|
|
33
|
+
DATE_TIME_FORMAT,
|
|
27
34
|
} = theme || {};
|
|
28
35
|
|
|
29
|
-
const
|
|
36
|
+
const DATE_FORMAT = DATE_TIME_FORMAT.dateFormat;
|
|
37
|
+
|
|
38
|
+
const styles = storyStyles(COLORS, FONT_SIZE);
|
|
30
39
|
const containerStyle = StyleSheet.flatten([
|
|
31
40
|
styles.container,
|
|
32
41
|
{ paddingHorizontal: props.horizontalPadding },
|
|
@@ -35,8 +44,16 @@ const PrimaryStoryCardBase = (props) => {
|
|
|
35
44
|
styles.headline,
|
|
36
45
|
props.headlineStyle,
|
|
37
46
|
]);
|
|
47
|
+
const autorStyle = StyleSheet.flatten([
|
|
48
|
+
styles.autorText,
|
|
49
|
+
props.authorTextStyle,
|
|
50
|
+
]);
|
|
38
51
|
|
|
39
|
-
const
|
|
52
|
+
const name = get(story.authors, [0, 'name']);
|
|
53
|
+
const authorName = name ? `${translate('By')} ${name} | ` : '';
|
|
54
|
+
const readTime = enableReadTimeOnStoryCards && story['read-time']
|
|
55
|
+
? `${story['read-time']} ${translate('min read')}`
|
|
56
|
+
: '';
|
|
40
57
|
|
|
41
58
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
42
59
|
|
|
@@ -68,7 +85,6 @@ const PrimaryStoryCardBase = (props) => {
|
|
|
68
85
|
};
|
|
69
86
|
|
|
70
87
|
return (
|
|
71
|
-
<>
|
|
72
88
|
<TouchableOpacity
|
|
73
89
|
testID={COMP_GENERAL_CONSTANTS.primaryStoryCard}
|
|
74
90
|
onPress={throttledOnpress}
|
|
@@ -81,51 +97,54 @@ const PrimaryStoryCardBase = (props) => {
|
|
|
81
97
|
cdn={props.cdn}
|
|
82
98
|
imageWidth={props.imageWidth}
|
|
83
99
|
>
|
|
100
|
+
<Text style={styles.xminContainer}>
|
|
101
|
+
{readTime && (
|
|
102
|
+
<View style={styles.xmin}>
|
|
103
|
+
<Text style={styles.xminText}>{readTime}</Text>
|
|
104
|
+
</View>
|
|
105
|
+
)}
|
|
106
|
+
</Text>
|
|
84
107
|
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
85
108
|
</ResponsiveImage>
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</
|
|
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>
|
|
110
133
|
</TouchableOpacity>
|
|
111
|
-
<View style={[styles.separatorLine, {marginHorizontal: props.horizontalPadding}]}/>
|
|
112
|
-
</>
|
|
113
134
|
);
|
|
114
135
|
};
|
|
115
136
|
|
|
116
|
-
|
|
137
|
+
PrimaryStoryCard.propTypes = {
|
|
117
138
|
cdn: PropTypes.string,
|
|
118
139
|
imageWidth: PropTypes.number,
|
|
119
140
|
headlineStyle: PropTypes.func,
|
|
141
|
+
authorTextStyle: PropTypes.func,
|
|
120
142
|
story: PropTypes.object.isRequired,
|
|
121
143
|
onPress: PropTypes.func,
|
|
122
144
|
horizontalPadding: PropTypes.number,
|
|
123
|
-
iconComponent: PropTypes.element,
|
|
124
145
|
};
|
|
125
146
|
|
|
126
|
-
|
|
147
|
+
PrimaryStoryCard.defaultProps = {
|
|
127
148
|
cdn: '',
|
|
128
149
|
horizontalPadding: 12,
|
|
129
150
|
};
|
|
130
|
-
|
|
131
|
-
export const PrimaryStoryCard = memo(PrimaryStoryCardBase);
|
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
export const storyStyles = ({
|
|
1
|
+
export const storyStyles = (COLORS = {}, FONT_SIZE = {}, DARK_MODE = {}) => ({
|
|
2
2
|
container: {
|
|
3
3
|
backgroundColor: COLORS.BRAND_WHITE,
|
|
4
|
-
|
|
5
|
-
gap: 10,
|
|
4
|
+
marginTop: 12,
|
|
6
5
|
},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
headlineAndTimestampContainer: {
|
|
14
|
-
flexShrink: 1,
|
|
15
|
-
gap: 4,
|
|
16
|
-
},
|
|
17
|
-
icon: {
|
|
18
|
-
marginBottom: 4,
|
|
19
|
-
marginTop: storyCardOptions.enableSectionName ? FONT_SIZE.h4 * lineHeightMultiplier + 8 : 4,
|
|
6
|
+
autorText: {
|
|
7
|
+
color: COLORS?.BRAND_6,
|
|
8
|
+
fontSize: FONT_SIZE.h5,
|
|
9
|
+
lineHeight: FONT_SIZE.h5 * 1.3,
|
|
10
|
+
paddingVertical: 8,
|
|
20
11
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
divider: {
|
|
13
|
+
backgroundColor: COLORS.BRAND_6,
|
|
14
|
+
height: 12,
|
|
15
|
+
marginHorizontal: 5,
|
|
16
|
+
width: 1,
|
|
25
17
|
},
|
|
26
18
|
headline: {
|
|
27
|
-
fontFamily: FONT_FAMILY.primaryBold,
|
|
28
19
|
fontSize: FONT_SIZE.title,
|
|
29
|
-
lineHeight: FONT_SIZE.title *
|
|
20
|
+
lineHeight: FONT_SIZE.title * 1.5,
|
|
21
|
+
color: COLORS.BRAND_BLACK,
|
|
22
|
+
opacity: 0.9,
|
|
23
|
+
},
|
|
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: {
|
|
30
35
|
color: COLORS.BRAND_BLACK,
|
|
31
|
-
|
|
36
|
+
fontSize: FONT_SIZE.h5,
|
|
32
37
|
},
|
|
33
38
|
storyTypeContainer: {
|
|
34
39
|
position: 'absolute',
|
|
@@ -58,13 +63,4 @@ export const storyStyles = ({COLORS, FONT_SIZE, FONT_FAMILY, lineHeightMultiplie
|
|
|
58
63
|
borderRadius: 50,
|
|
59
64
|
backgroundColor: COLORS.BRAND_3,
|
|
60
65
|
},
|
|
61
|
-
premiumIcon: {
|
|
62
|
-
marginTop: FONT_SIZE.h3 * 0.92,
|
|
63
|
-
marginRight: 5,
|
|
64
|
-
},
|
|
65
|
-
separatorLine: {
|
|
66
|
-
height: 0.8,
|
|
67
|
-
opacity: 0.1,
|
|
68
|
-
backgroundColor: COLORS.BRAND_BLACK,
|
|
69
|
-
},
|
|
70
66
|
});
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
import {
|
|
7
|
+
AppTheme,
|
|
8
|
+
getImageMetadata,
|
|
9
|
+
getImageSlug,
|
|
10
|
+
} from '../../utils';
|
|
11
|
+
import { getStoryHeadline } from '../../utils/story';
|
|
12
|
+
import { ResponsiveImage, Text, StoryCardDetailsRow } from '../index';
|
|
13
|
+
import { storyStyles } from './styles';
|
|
14
|
+
import {
|
|
15
|
+
COMP_GENERAL_CONSTANTS,
|
|
16
|
+
COMP_CONTENT_CONSTANTS,
|
|
17
|
+
} from '../../constants/component-constants';
|
|
18
|
+
import PremiumIcons from '../../Icons/PremiumIcons/index';
|
|
19
|
+
|
|
20
|
+
const PrimaryStoryCardNewBase = (props) => {
|
|
21
|
+
const { story = {} } = props;
|
|
22
|
+
const { theme } = useContext(AppTheme);
|
|
23
|
+
const {
|
|
24
|
+
COLORS,
|
|
25
|
+
FONT_SIZE,
|
|
26
|
+
FONT_FAMILY,
|
|
27
|
+
premiumIcon,
|
|
28
|
+
lineHeightMultiplier,
|
|
29
|
+
storyCardOptions = {},
|
|
30
|
+
} = theme || {};
|
|
31
|
+
|
|
32
|
+
const styles = storyStyles(theme);
|
|
33
|
+
const containerStyle = StyleSheet.flatten([
|
|
34
|
+
styles.container,
|
|
35
|
+
{ paddingHorizontal: props.horizontalPadding },
|
|
36
|
+
]);
|
|
37
|
+
const headlineStyle = StyleSheet.flatten([
|
|
38
|
+
styles.headline,
|
|
39
|
+
props.headlineStyle,
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
const isPremiumStory = story['access'] === 'subscription';
|
|
43
|
+
|
|
44
|
+
const throttledOnpress = throttle(props.onPress, 1000);
|
|
45
|
+
|
|
46
|
+
const showIcon = (name) => (
|
|
47
|
+
<View style={styles.storyType}>
|
|
48
|
+
<Icon name={name} size={22} color={COLORS.MONO7} />
|
|
49
|
+
</View>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const showLiveBlogIcon = () => (
|
|
53
|
+
<View style={styles.storyType}>
|
|
54
|
+
<View style={styles.liveBlogIcon} />
|
|
55
|
+
<Text style={styles.liveBlogText}>LIVE</Text>
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
const showStoryType = () => {
|
|
59
|
+
switch (story['story-template']) {
|
|
60
|
+
case 'text':
|
|
61
|
+
return null;
|
|
62
|
+
case 'photo':
|
|
63
|
+
return showIcon('photo');
|
|
64
|
+
case 'video':
|
|
65
|
+
return showIcon('play');
|
|
66
|
+
case 'live-blog':
|
|
67
|
+
return showLiveBlogIcon();
|
|
68
|
+
default:
|
|
69
|
+
null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<TouchableOpacity
|
|
76
|
+
testID={COMP_GENERAL_CONSTANTS.primaryStoryCard}
|
|
77
|
+
onPress={throttledOnpress}
|
|
78
|
+
activeOpacity={0.8}
|
|
79
|
+
style={containerStyle}
|
|
80
|
+
>
|
|
81
|
+
<ResponsiveImage
|
|
82
|
+
metaData={getImageMetadata(story)}
|
|
83
|
+
slug={getImageSlug(story)}
|
|
84
|
+
cdn={props.cdn}
|
|
85
|
+
imageWidth={props.imageWidth}
|
|
86
|
+
>
|
|
87
|
+
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
88
|
+
</ResponsiveImage>
|
|
89
|
+
<View style={styles.contentContainer}>
|
|
90
|
+
<View style={styles.headlineAndTimestampContainer}>
|
|
91
|
+
{storyCardOptions.enableSectionName && <Text numberOfLines={1} ellipsizeMode="tail" style={styles.sectionName}>{get(story, ['sections', 0, 'display-name'], '')}</Text>}
|
|
92
|
+
<View style={{display:'flex', flexDirection:'row'}}>
|
|
93
|
+
<Text
|
|
94
|
+
primary
|
|
95
|
+
numberOfLines={storyCardOptions.numberOfLinesForTitle}
|
|
96
|
+
ellipsizeMode="tail"
|
|
97
|
+
style={headlineStyle}
|
|
98
|
+
testID={COMP_GENERAL_CONSTANTS.primaryStoryHeadline}
|
|
99
|
+
>
|
|
100
|
+
{isPremiumStory && premiumIcon !=='none' && <PremiumIcons style={styles.premiumIcon} name={premiumIcon} color={COLORS.primary} size={FONT_SIZE.h2} /> }
|
|
101
|
+
{isPremiumStory && premiumIcon !=='none' && ' '}
|
|
102
|
+
{getStoryHeadline(story)}
|
|
103
|
+
</Text>
|
|
104
|
+
</View>
|
|
105
|
+
<StoryCardDetailsRow
|
|
106
|
+
authorName={get(story.authors, [0, 'name'])}
|
|
107
|
+
publishedAt={story["published-at"]}
|
|
108
|
+
readTime={story['read-time']}
|
|
109
|
+
/>
|
|
110
|
+
</View>
|
|
111
|
+
<View style={styles.icon}>{props.iconComponent}</View>
|
|
112
|
+
</View>
|
|
113
|
+
</TouchableOpacity>
|
|
114
|
+
<View style={[styles.separatorLine, {marginHorizontal: props.horizontalPadding}]}/>
|
|
115
|
+
</>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
PrimaryStoryCardNewBase.propTypes = {
|
|
120
|
+
cdn: PropTypes.string,
|
|
121
|
+
imageWidth: PropTypes.number,
|
|
122
|
+
headlineStyle: PropTypes.func,
|
|
123
|
+
story: PropTypes.object.isRequired,
|
|
124
|
+
onPress: PropTypes.func,
|
|
125
|
+
horizontalPadding: PropTypes.number,
|
|
126
|
+
iconComponent: PropTypes.element,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
PrimaryStoryCardNewBase.defaultProps = {
|
|
130
|
+
cdn: '',
|
|
131
|
+
horizontalPadding: 12,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const PrimaryStoryCardNew = memo(PrimaryStoryCardNewBase);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export const storyStyles = ({COLORS, FONT_SIZE, FONT_FAMILY, lineHeightMultiplier, storyCardOptions = {}}) => ({
|
|
2
|
+
container: {
|
|
3
|
+
backgroundColor: COLORS.BRAND_WHITE,
|
|
4
|
+
paddingVertical: 10,
|
|
5
|
+
gap: 10,
|
|
6
|
+
},
|
|
7
|
+
contentContainer: {
|
|
8
|
+
flexDirection: 'row',
|
|
9
|
+
justifyContent: 'space-between',
|
|
10
|
+
alignItems: 'flex-start',
|
|
11
|
+
gap: 10,
|
|
12
|
+
},
|
|
13
|
+
headlineAndTimestampContainer: {
|
|
14
|
+
flexShrink: 1,
|
|
15
|
+
gap: 4,
|
|
16
|
+
},
|
|
17
|
+
icon: {
|
|
18
|
+
marginBottom: 4,
|
|
19
|
+
marginTop: storyCardOptions.enableSectionName ? FONT_SIZE.h4 * lineHeightMultiplier + 8 : 4,
|
|
20
|
+
},
|
|
21
|
+
sectionName: {
|
|
22
|
+
color: COLORS.BRAND_1,
|
|
23
|
+
fontSize: FONT_SIZE.h4,
|
|
24
|
+
lineHeight: FONT_SIZE.h4 * lineHeightMultiplier,
|
|
25
|
+
},
|
|
26
|
+
headline: {
|
|
27
|
+
fontFamily: FONT_FAMILY.primaryBold,
|
|
28
|
+
fontSize: FONT_SIZE.title,
|
|
29
|
+
lineHeight: FONT_SIZE.title * lineHeightMultiplier,
|
|
30
|
+
color: COLORS.BRAND_BLACK,
|
|
31
|
+
marginBottom: 4,
|
|
32
|
+
},
|
|
33
|
+
storyTypeContainer: {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
bottom: 0,
|
|
36
|
+
left: 0,
|
|
37
|
+
},
|
|
38
|
+
storyType: {
|
|
39
|
+
backgroundColor: COLORS.MONO1,
|
|
40
|
+
padding: 8,
|
|
41
|
+
justifyContent: 'space-between',
|
|
42
|
+
alignItems: 'space-between',
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
},
|
|
45
|
+
storyTypeText: {
|
|
46
|
+
color: COLORS.MONO7,
|
|
47
|
+
fontSize: FONT_SIZE.h5,
|
|
48
|
+
},
|
|
49
|
+
liveBlogText: {
|
|
50
|
+
color: COLORS.MONO7,
|
|
51
|
+
fontSize: FONT_SIZE.h4,
|
|
52
|
+
marginLeft: 10,
|
|
53
|
+
fontWeight: 'bold',
|
|
54
|
+
},
|
|
55
|
+
liveBlogIcon: {
|
|
56
|
+
height: 15,
|
|
57
|
+
width: 15,
|
|
58
|
+
borderRadius: 50,
|
|
59
|
+
backgroundColor: COLORS.BRAND_3,
|
|
60
|
+
},
|
|
61
|
+
premiumIcon: {
|
|
62
|
+
marginTop: FONT_SIZE.h3 * 0.92,
|
|
63
|
+
marginRight: 5,
|
|
64
|
+
},
|
|
65
|
+
separatorLine: {
|
|
66
|
+
height: 0.8,
|
|
67
|
+
opacity: 0.1,
|
|
68
|
+
backgroundColor: COLORS.BRAND_BLACK,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import React, { useContext } from "react";
|
|
3
2
|
import {
|
|
4
3
|
StyleSheet,
|
|
5
|
-
TouchableOpacity,
|
|
6
4
|
View,
|
|
5
|
+
TouchableOpacity,
|
|
7
6
|
ViewPropTypes,
|
|
8
7
|
} from "react-native";
|
|
9
|
-
import
|
|
8
|
+
import PropTypes from "prop-types";
|
|
10
9
|
import { radioButtonStyles } from "./styles";
|
|
10
|
+
import { AppTheme } from "../../utils";
|
|
11
11
|
|
|
12
12
|
import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants";
|
|
13
13
|
|
|
@@ -2,9 +2,9 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
4
|
import { StarRatingDisplay } from 'react-native-star-rating-widget';
|
|
5
|
-
import { AppTheme } from '../../utils';
|
|
6
5
|
import { Text } from '../Text';
|
|
7
6
|
import { ratingStyles } from './styles';
|
|
7
|
+
import { AppTheme } from '../../utils';
|
|
8
8
|
|
|
9
9
|
export const RatingLayout = ({ reviewTitle, ratingValue, ratingLabel }) => {
|
|
10
10
|
const { theme } = useContext(AppTheme);
|
|
@@ -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, ShareButton } from '../index';
|
|
6
|
+
import { SecondaryStoryCard, SecondaryStoryCardNew, ShareButton } from '../index';
|
|
7
7
|
|
|
8
8
|
import { relatedStoriesStyles } from './styles';
|
|
9
9
|
|
|
@@ -13,8 +13,10 @@ export const RelatedStoriesCard = ({
|
|
|
13
13
|
cdn,
|
|
14
14
|
stories,
|
|
15
15
|
onStoryPress,
|
|
16
|
+
collectionTestID,
|
|
16
17
|
RelatedCardID,
|
|
17
18
|
title,
|
|
19
|
+
switchToNewDesign,
|
|
18
20
|
}) => {
|
|
19
21
|
const sliceLimit = 5;
|
|
20
22
|
|
|
@@ -39,12 +41,19 @@ export const RelatedStoriesCard = ({
|
|
|
39
41
|
onPress: () => onStoryPress(secondaryStory),
|
|
40
42
|
key: secondaryStory?.id,
|
|
41
43
|
};
|
|
42
|
-
|
|
44
|
+
return switchToNewDesign ? (
|
|
45
|
+
<SecondaryStoryCardNew
|
|
43
46
|
{...storyCardProps}
|
|
44
47
|
iconComponent={<ShareButton story={secondaryStory} inListingStoryCard />}
|
|
45
48
|
imageWidth={getScreenPercentageWidth(28)}
|
|
46
49
|
horizontalPadding={4}
|
|
47
50
|
/>
|
|
51
|
+
) : (
|
|
52
|
+
<SecondaryStoryCard
|
|
53
|
+
{...storyCardProps}
|
|
54
|
+
imageWidth={getScreenPercentageWidth(40)}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
48
57
|
})}
|
|
49
58
|
</View>
|
|
50
59
|
</>
|
|
@@ -57,4 +66,5 @@ RelatedStoriesCard.propTypes = {
|
|
|
57
66
|
collectionTestID: PropTypes.string,
|
|
58
67
|
RelatedCardID: PropTypes.string,
|
|
59
68
|
title:PropTypes.string,
|
|
69
|
+
switchToNewDesign: PropTypes.bool,
|
|
60
70
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cleanup, render, fireEvent } from '@testing-library/react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import 'react-native';
|
|
4
|
+
import { mockContext } from '../../utils';
|
|
5
|
+
import { SecondaryStoryCard } from './index';
|
|
6
|
+
import { data } from '../../constants/test-data/story.json';
|
|
7
|
+
import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
|
|
8
|
+
|
|
9
|
+
const storyData = data.story;
|
|
10
|
+
const onPress = jest.fn();
|
|
11
|
+
|
|
12
|
+
describe('Test Secondary Story Card :', () => {
|
|
13
|
+
afterEach(cleanup);
|
|
14
|
+
test('renders author name properly', () => {
|
|
15
|
+
const { getByTestId } = render(
|
|
16
|
+
mockContext(<SecondaryStoryCard story={storyData} />),
|
|
17
|
+
);
|
|
18
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.secondaryStoryAuthor);
|
|
19
|
+
expect(element.props.children).toBe('By Raghavendra Vaidya | ');
|
|
20
|
+
});
|
|
21
|
+
test('renders story headline properly', () => {
|
|
22
|
+
const { getByTestId } = render(
|
|
23
|
+
mockContext(<SecondaryStoryCard story={storyData} />),
|
|
24
|
+
);
|
|
25
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.secondaryStoryHeadline);
|
|
26
|
+
expect(element.props.children).toBe('Jack and jill');
|
|
27
|
+
});
|
|
28
|
+
test('renders story date properly', () => {
|
|
29
|
+
const { getByTestId } = render(
|
|
30
|
+
mockContext(<SecondaryStoryCard story={storyData} />),
|
|
31
|
+
);
|
|
32
|
+
const element = getByTestId(
|
|
33
|
+
COMP_GENERAL_CONSTANTS.secondaryStoryPubishedAt,
|
|
34
|
+
);
|
|
35
|
+
expect(element.props.children).toBe('1 Feb, 2021');
|
|
36
|
+
});
|
|
37
|
+
test('OnPress handler called properly', () => {
|
|
38
|
+
const { getByTestId } = render(
|
|
39
|
+
mockContext(
|
|
40
|
+
<SecondaryStoryCard
|
|
41
|
+
story={storyData}
|
|
42
|
+
onPress={onPress}
|
|
43
|
+
collectionTestID="secondaryStoryCardView"
|
|
44
|
+
/>,
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
const element = getByTestId(COMP_GENERAL_CONSTANTS.secondaryStoryCard);
|
|
48
|
+
fireEvent(element, 'press');
|
|
49
|
+
expect(onPress).toHaveBeenCalled();
|
|
50
|
+
});
|
|
51
|
+
});
|