@quintype/native-components 2.22.6 → 2.28.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.22.6",
3
+ "version": "2.28.0",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -2,14 +2,13 @@ import { get, throttle } from 'lodash';
2
2
  import PropTypes from 'prop-types';
3
3
  import React, { useContext, memo } from 'react';
4
4
  import { StyleSheet, TouchableOpacity, View } from 'react-native';
5
- import Icon from 'react-native-vector-icons/FontAwesome';
6
5
  import {
7
6
  AppTheme,
8
7
  getImageMetadata,
9
8
  getImageSlug,
10
9
  } from '../../utils';
11
10
  import { getStoryHeadline } from '../../utils/story';
12
- import { ResponsiveImage, Text, StoryCardDetailsRow } from '../index';
11
+ import { ResponsiveImage, Text, StoryCardDetailsRow, StoryTemplateIcon } from '../index';
13
12
  import { storyStyles } from './styles';
14
13
  import {
15
14
  COMP_GENERAL_CONSTANTS,
@@ -23,9 +22,7 @@ const PrimaryStoryCardNewBase = (props) => {
23
22
  const {
24
23
  COLORS,
25
24
  FONT_SIZE,
26
- FONT_FAMILY,
27
25
  premiumIcon,
28
- lineHeightMultiplier,
29
26
  storyCardOptions = {},
30
27
  } = theme || {};
31
28
 
@@ -43,33 +40,6 @@ const PrimaryStoryCardNewBase = (props) => {
43
40
 
44
41
  const throttledOnpress = throttle(props.onPress, 1000);
45
42
 
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
43
  return (
74
44
  <>
75
45
  <TouchableOpacity
@@ -84,7 +54,9 @@ const PrimaryStoryCardNewBase = (props) => {
84
54
  cdn={props.cdn}
85
55
  imageWidth={props.imageWidth}
86
56
  >
87
- <View style={styles.storyTypeContainer}>{showStoryType()}</View>
57
+ <View style={styles.storyTypeContainer}>
58
+ <StoryTemplateIcon storyTemplate={story['story-template']} cardType="primary" theme={theme} />
59
+ </View>
88
60
  </ResponsiveImage>
89
61
  <View style={styles.contentContainer}>
90
62
  <View style={styles.headlineAndTimestampContainer}>
@@ -35,29 +35,6 @@ export const storyStyles = ({COLORS, FONT_SIZE, FONT_FAMILY, lineHeightMultiplie
35
35
  bottom: 0,
36
36
  left: 0,
37
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
38
  premiumIcon: {
62
39
  marginTop: FONT_SIZE.h3 * 0.92,
63
40
  marginRight: 5,
@@ -23,7 +23,8 @@ export const searchStyles = (appThemeContext) => {
23
23
  flex: 1,
24
24
  justifyContent: 'center',
25
25
  margin: 12,
26
- padding: 12,
26
+ padding: 5,
27
+ paddingHorizontal:12
27
28
  },
28
29
  });
29
30
  };
@@ -1,4 +1,4 @@
1
- import { get, isNull, 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
4
  import {
@@ -8,14 +8,13 @@ import {
8
8
  TextStyle,
9
9
  TouchableOpacityProps,
10
10
  } from 'react-native';
11
- import Icon from 'react-native-vector-icons/FontAwesome';
12
11
  import {
13
12
  AppTheme,
14
13
  getImageMetadata,
15
14
  getImageSlug,
16
15
  } from '../../utils';
17
16
  import { getStoryHeadline } from '../../utils/story';
18
- import { ResponsiveImage, Text, StoryCardDetailsRow } from '../index';
17
+ import { ResponsiveImage, Text, StoryCardDetailsRow, StoryTemplateIcon } from '../index';
19
18
  import { storyStyles } from './styles';
20
19
  import {
21
20
  COMP_GENERAL_CONSTANTS,
@@ -47,78 +46,52 @@ const SecondaryStoryCardNewBase = (props) => {
47
46
 
48
47
  const throttledOnpress = throttle(props.onPress, 1000);
49
48
 
50
- const showIcon = (name) => (
51
- <View style={styles.storyType}>
52
- <Icon name={name} size={14} 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
-
63
- const showStoryType = () => {
64
- switch (story['story-template']) {
65
- case 'text':
66
- return null;
67
- case 'photo':
68
- return showIcon('photo');
69
- case 'video':
70
- return showIcon('play');
71
- case 'live-blog':
72
- return showLiveBlogIcon();
73
- default:
74
- null;
75
- }
76
- };
77
-
78
49
  return (
79
50
  <>
80
- <TouchableOpacity
81
- testID={COMP_GENERAL_CONSTANTS.secondaryStoryCard}
82
- onPress={throttledOnpress}
83
- activeOpacity={0.8}
84
- style={containerStyle}
85
- >
86
- <View style={[styles.imageAndDetails, storyCardOptions.alignSmallCardImage === "right" && { flexDirection: 'row-reverse'}]}>
87
- {storyCardOptions.enableSmallCardImage && (<ResponsiveImage
88
- styles={styles.image}
89
- metaData={getImageMetadata(story)}
90
- slug={getImageSlug(story) || ''}
91
- cdn={props.cdn || ''}
92
- imageWidth={props.imageWidth}
51
+ <TouchableOpacity
52
+ testID={COMP_GENERAL_CONSTANTS.secondaryStoryCard}
53
+ onPress={throttledOnpress}
54
+ activeOpacity={0.8}
55
+ style={containerStyle}
93
56
  >
94
- <View style={styles.storyTypeContainer}>{showStoryType()}</View>
95
- </ResponsiveImage>)
96
- }
97
- <View style={styles.headlineAndTimestampBlockContainer}>
98
- {storyCardOptions.enableSectionName && <Text numberOfLines={1} ellipsizeMode="tail" style={styles.sectionName}>{get(story, ['sections', 0, 'display-name'], '')}</Text>}
99
- <View style={{display:'flex', flexDirection:'row'}}>
100
- <Text
101
- primary
102
- numberOfLines={storyCardOptions.numberOfLinesForTitle}
103
- ellipsizeMode="tail"
104
- style={headlineStyle}
105
- testID={COMP_GENERAL_CONSTANTS.secondaryStoryHeadline}
106
- >
107
- {isPremiumStory && premiumIcon !=='none' && <PremiumIcons style={styles.premiumIcon} name={premiumIcon} color={COLORS.primary} size={FONT_SIZE.h4} />}
108
- {isPremiumStory && premiumIcon !=='none' && ' '}
109
- {getStoryHeadline(story)?.trim()}
110
- </Text>
57
+ <View style={[styles.imageAndDetails, storyCardOptions.alignSmallCardImage === "right" && { flexDirection: 'row-reverse' }]}>
58
+ {storyCardOptions.enableSmallCardImage && (<ResponsiveImage
59
+ styles={styles.image}
60
+ metaData={getImageMetadata(story)}
61
+ slug={getImageSlug(story) || ''}
62
+ cdn={props.cdn || ''}
63
+ imageWidth={props.imageWidth}
64
+ >
65
+ <View style={styles.storyTypeContainer}>
66
+ <StoryTemplateIcon storyTemplate={story['story-template']} theme={theme} />
67
+ </View>
68
+ </ResponsiveImage>)
69
+ }
70
+ <View style={styles.headlineAndTimestampBlockContainer}>
71
+ {storyCardOptions.enableSectionName && <Text numberOfLines={1} ellipsizeMode="tail" style={styles.sectionName}>{get(story, ['sections', 0, 'display-name'], '')}</Text>}
72
+ <View style={{ display: 'flex', flexDirection: 'row' }}>
73
+ <Text
74
+ primary
75
+ numberOfLines={storyCardOptions.numberOfLinesForTitle}
76
+ ellipsizeMode="tail"
77
+ style={headlineStyle}
78
+ testID={COMP_GENERAL_CONSTANTS.secondaryStoryHeadline}
79
+ >
80
+ {isPremiumStory && premiumIcon !== 'none' && <PremiumIcons style={styles.premiumIcon} name={premiumIcon} color={COLORS.primary} size={FONT_SIZE.h4} />}
81
+ {isPremiumStory && premiumIcon !== 'none' && ' '}
82
+ {getStoryHeadline(story)?.trim()}
83
+ </Text>
84
+ </View>
85
+ <StoryCardDetailsRow
86
+ authorName={get(story.authors, [0, 'name'])}
87
+ publishedAt={story["published-at"]}
88
+ readTime={story['read-time']}
89
+ />
90
+ </View>
111
91
  </View>
112
- <StoryCardDetailsRow
113
- authorName={get(story.authors, [0, 'name'])}
114
- publishedAt={story["published-at"]}
115
- readTime={story['read-time']}
116
- />
117
- </View>
118
- </View>
119
- <View style={styles.icon}>{props.iconComponent}</View>
120
- </TouchableOpacity>
121
- <View style={[styles.separatorLine, { marginHorizontal: props.horizontalPadding }]}/>
92
+ <View style={styles.icon}>{props.iconComponent}</View>
93
+ </TouchableOpacity>
94
+ <View style={[styles.separatorLine, { marginHorizontal: props.horizontalPadding }]} />
122
95
  </>
123
96
  );
124
97
  };
@@ -44,32 +44,9 @@ export const storyStyles = ({ COLORS, FONT_SIZE, FONT_FAMILY, lineHeightMultipli
44
44
  },
45
45
  storyTypeContainer: {
46
46
  position: 'absolute',
47
- backgroundColor: COLORS.MONO1,
48
47
  bottom: 0,
49
48
  left: 0,
50
49
  },
51
- storyType: {
52
- padding: 5,
53
- justifyContent: 'space-between',
54
- alignItems: 'center',
55
- flexDirection: 'row',
56
- },
57
- storyTypeText: {
58
- color: COLORS.MONO7,
59
- fontSize: FONT_SIZE.h5,
60
- },
61
- liveBlogText: {
62
- color: COLORS.MONO7,
63
- fontSize: FONT_SIZE.h5,
64
- marginLeft: 4,
65
- fontWeight: 'bold',
66
- },
67
- liveBlogIcon: {
68
- height: 12,
69
- width: 12,
70
- borderRadius: 50,
71
- backgroundColor: COLORS.BRAND_3,
72
- },
73
50
  premiumIcon: {
74
51
  marginTop: FONT_SIZE.h3 * 0.45,
75
52
  marginRight: 3,
@@ -0,0 +1,58 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import FAIcon from "react-native-vector-icons/FontAwesome";
4
+ import MaterialIcon from "react-native-vector-icons/MaterialIcons";
5
+ import { Text } from "../index";
6
+ import { storyTemplateIconStyles } from "./styles";
7
+
8
+ export const StoryTemplateIcon = ({
9
+ storyTemplate,
10
+ cardType = "secondary",
11
+ theme,
12
+ }) => {
13
+ const { COLORS, FONT_SIZE } = theme;
14
+
15
+ const styles = storyTemplateIconStyles(COLORS, FONT_SIZE, cardType);
16
+
17
+ const iconSize = () => {
18
+ switch (cardType) {
19
+ case "primary":
20
+ return 20;
21
+ case "secondary":
22
+ default:
23
+ return 14;
24
+ }
25
+ };
26
+
27
+ const showIcon = (name, iconFamily = "FontAwesome") => (
28
+ <View style={styles.storyType}>
29
+ {iconFamily === "MaterialIcons" ? (
30
+ <MaterialIcon name={name} size={iconSize()} color={COLORS.MONO7} />
31
+ ) : (
32
+ <FAIcon name={name} size={iconSize()} color={COLORS.MONO7} />
33
+ )}
34
+ </View>
35
+ );
36
+
37
+ const showLiveBlogIcon = () => (
38
+ <View style={styles.storyType}>
39
+ <View style={styles.liveBlogIcon} />
40
+ <Text style={styles.liveBlogText}>LIVE</Text>
41
+ </View>
42
+ );
43
+
44
+ switch (storyTemplate) {
45
+ case "text":
46
+ return null;
47
+ case "photo":
48
+ return showIcon("photo");
49
+ case "video":
50
+ return showIcon("play");
51
+ case "live-blog":
52
+ return showLiveBlogIcon();
53
+ case "visual-story":
54
+ return showIcon("web-stories", "MaterialIcons");
55
+ default:
56
+ return null;
57
+ }
58
+ };
@@ -0,0 +1,23 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const storyTemplateIconStyles = (COLORS, FONT_SIZE, cardType) => StyleSheet.create({
4
+ storyType: {
5
+ backgroundColor: COLORS.MONO1,
6
+ padding: cardType === "primary" ? 8 : 4,
7
+ justifyContent: 'space-between',
8
+ alignItems: 'space-between',
9
+ flexDirection: 'row',
10
+ },
11
+ liveBlogText: {
12
+ color: COLORS.MONO7,
13
+ fontSize: FONT_SIZE.h5,
14
+ marginLeft: cardType === "primary" ? 8 : 4,
15
+ fontWeight: 'bold',
16
+ },
17
+ liveBlogIcon: {
18
+ height: 12,
19
+ width: 12,
20
+ borderRadius: 50,
21
+ backgroundColor: COLORS.BRAND_3,
22
+ },
23
+ });
@@ -44,6 +44,7 @@ export { IconText } from './IconText';
44
44
  export { CustomSwitch } from './CustomSwitch';
45
45
  export { RelatedStoriesCard } from './RelatedStoriesCard';
46
46
  export { References } from './References';
47
+ export { StoryTemplateIcon } from './StoryTemplateIcon'
47
48
  export { StoryCardDetailsRow } from './StoryCardDetailsRow';
48
49
  export { TextA } from './TextA'
49
50
  export { TextQ } from './TextQ'
@@ -1,4 +1,5 @@
1
1
  export const STORY_TYPES = {
2
2
  LIVE_BLOG: 'live-blog',
3
3
  VIDEO_STORY: 'video',
4
+ VISUAL_STORY: 'visual-story',
4
5
  };