@quintype/native-components 2.21.3 → 2.21.5

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.
@@ -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.21.3",
3
+ "version": "2.21.5",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -25,7 +25,7 @@ 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 { CustomFallBackIcon, translate } = theme;
28
+ const { CustomFallBackIcon, translate, showAlsoRead } = theme;
29
29
  const styles = alsoReadStyles(theme);
30
30
 
31
31
  const fallBackIcon = CustomFallBackIcon ? <CustomFallBackIcon /> : <FallbackIcon />;
@@ -36,7 +36,7 @@ export const AlsoRead = (props) => {
36
36
  <ResponsiveImage
37
37
  metaData={linkedStoryMetadata}
38
38
  cdn={cdn}
39
- imageWidth={120}
39
+ imageWidth={150}
40
40
  slug={linkedImage}
41
41
  />
42
42
  );
@@ -44,13 +44,13 @@ export const AlsoRead = (props) => {
44
44
 
45
45
  return (
46
46
  <View style={styles.wrapper}>
47
+ {showAlsoRead && <Text style={styles.alsoReadText}>{translate("Also Read")}</Text>}
47
48
  <TouchableOpacity
48
49
  onPress={() => handleAlsoReadTap(slug, navigation, screenList)}
49
50
  >
50
51
  <View style={styles.container}>
51
52
  {getImageComponent()}
52
53
  <View style={styles.alsoReadContentWrapper}>
53
- <Text style={styles.alsoReadText}>{translate("Also Read")}</Text>
54
54
  <Text primary numberOfLines={2} style={styles.alsoReadTitle}>
55
55
  {text}
56
56
  </Text>
@@ -5,9 +5,15 @@ export const alsoReadStyles = (appThemeContext) => {
5
5
  return StyleSheet.create({
6
6
  wrapper: {
7
7
  padding: 10,
8
+ margin:15
8
9
  },
9
10
  container: {
10
11
  flexDirection: "row",
12
+ padding:10,
13
+ borderWidth:0.5,
14
+ borderRadius:2,
15
+ marginTop:8,
16
+ borderColor:COLORS.MONO5
11
17
  },
12
18
  alsoReadContentWrapper: {
13
19
  paddingLeft: 12,
@@ -15,12 +21,13 @@ export const alsoReadStyles = (appThemeContext) => {
15
21
  },
16
22
  alsoReadText: {
17
23
  fontSize: FONT_SIZE.h2,
18
- fontFamily: FONT_FAMILY.secondaryBold,
19
- color: DARK_MODE ? COLORS.BRAND_BLACK : COLORS.BRAND_1,
24
+ fontFamily: FONT_FAMILY.primaryBold,
25
+ color: COLORS.BRAND_BLACK,
20
26
  },
21
27
  alsoReadTitle: {
22
28
  fontSize: FONT_SIZE.h2,
23
- color: DARK_MODE ? COLORS.BRAND_BLACK : COLORS.BRAND_1,
29
+ color: COLORS.BRAND_1,
30
+ fontFamily: FONT_FAMILY.primary,
24
31
  },
25
32
  fallBackImageWrapper: {
26
33
  backgroundColor: COLORS.BRAND_WHITE,
@@ -35,7 +35,7 @@ const PrimaryStoryCardNewBase = (props) => {
35
35
 
36
36
  const translate = get(theme, ['translate'], (word) => word);
37
37
 
38
- const styles = storyStyles(COLORS, FONT_SIZE, DARK_MODE, lineHeightMultiplier);
38
+ const styles = storyStyles(COLORS, FONT_SIZE, lineHeightMultiplier);
39
39
  const containerStyle = StyleSheet.flatten([
40
40
  styles.container,
41
41
  { paddingHorizontal: props.horizontalPadding },
@@ -23,6 +23,7 @@ export const StoryContent = ({
23
23
  const textProps = {
24
24
  text: storyElement.text,
25
25
  attribution: storyElement?.metadata?.attribution,
26
+ navigation
26
27
  };
27
28
 
28
29
  switch (storyElement.type) {
@@ -39,15 +40,18 @@ export const StoryContent = ({
39
40
  return React.createElement(AllComponents.TextBlockQuote, textProps);
40
41
  case STORY_ELEMENT_SUBTYPES.BIGFACT:
41
42
  return React.createElement(AllComponents.TextBigFact, textProps);
42
- case STORY_ELEMENT_SUBTYPES.QUESTION:
43
- return React.createElement(AllComponents.StoryText, {
44
- ...textProps,
45
- question: true,
46
- });
47
43
  case STORY_ELEMENT_SUBTYPES.Q_A:
48
44
  return React.createElement(AllComponents.TextQandA, {
49
- question: stripHTML(storyElement.metadata.question),
50
- answer: stripHTML(storyElement.metadata.answer),
45
+ question: storyElement.metadata.question,
46
+ answer: storyElement.metadata.answer,
47
+ });
48
+ case STORY_ELEMENT_SUBTYPES.QUESTION:
49
+ return React.createElement(AllComponents.TextQ, {
50
+ question: storyElement.text,
51
+ });
52
+ case STORY_ELEMENT_SUBTYPES.ANSWER:
53
+ return React.createElement(AllComponents.TextA, {
54
+ answer: storyElement.text,
51
55
  });
52
56
 
53
57
  case STORY_ELEMENT_SUBTYPES.ALSO_READ: {
@@ -10,7 +10,8 @@ import { customHTMLStyles } from '../../constants/renderHTML';
10
10
  import { storyTextStyles } from './styles';
11
11
 
12
12
  export const StoryText = (props) => {
13
- const { theme } = useContext(AppTheme);
13
+ const {navigation} = props;
14
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
14
15
  const {
15
16
  COLORS,
16
17
  FONT_FAMILY,
@@ -39,7 +40,7 @@ export const StoryText = (props) => {
39
40
  key={Math.random()}
40
41
  baseFontStyle={style}
41
42
  onLinkPress={(evt, href) => {
42
- Linking.openURL(href);
43
+ useDeeplinkHandler(href, navigation)
43
44
  }}
44
45
  listsPrefixesRenderers={{
45
46
  ul: () => <View style={customTagsStyles.ul} />,
@@ -0,0 +1,55 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { useContext } from 'react';
3
+ import { View, StyleSheet, Linking,I18nManager } from 'react-native';
4
+ import { StoryText, Text } from '@quintype/native-components/src/components';
5
+ import { textAnswerStyles } from '@quintype/native-components/src/components/TextA/styles';
6
+ import { AppTheme } from '@quintype/native-components/src/utils/context';
7
+ import HTML from 'react-native-render-html';
8
+ import { customHTMLStyles } from '../../constants/renderHTML';
9
+
10
+ export const TextA = ({ answer }) => {
11
+ const { theme } = useContext(AppTheme);
12
+ const { COLORS, FONT_SIZE, lineHeightMultiplier, FONT_FAMILY} = theme;
13
+ const styles = textAnswerStyles(COLORS, FONT_SIZE, lineHeightMultiplier);
14
+ const customTagsStyles = customHTMLStyles();
15
+ const style = StyleSheet.flatten([
16
+ styles.answerText,
17
+ {
18
+ fontFamily: FONT_FAMILY.secondary,
19
+ writingDirection: I18nManager.isRTL ? "rtl" : "ltr",
20
+ },
21
+ ]);
22
+ return (
23
+ <View testID="text-answer" style={styles.container}>
24
+ <View style={styles.iconContainer}>
25
+ <Text style={styles.iconText}>A</Text>
26
+ </View>
27
+ <HTML
28
+ html={answer}
29
+ key={Math.random()}
30
+ baseFontStyle={style}
31
+ onLinkPress={(evt, href) => {
32
+ Linking.openURL(href);
33
+ }}
34
+ tagsStyles={{
35
+ del: customTagsStyles.del,
36
+ ins: customTagsStyles.ins,
37
+ p: customTagsStyles.p,
38
+ li: customTagsStyles.li,
39
+ a: customTagsStyles.a,
40
+ h2: customTagsStyles.h,
41
+ h3: customTagsStyles.h,
42
+ h4: customTagsStyles.h,
43
+ h5: customTagsStyles.h,
44
+ h6: customTagsStyles.h,
45
+ }}
46
+ containerStyle={styles.htmlContainer}
47
+ />
48
+ </View>
49
+ );
50
+ };
51
+
52
+ TextA.propTypes = {
53
+ question: PropTypes.string.isRequired,
54
+ answer: PropTypes.string.isRequired,
55
+ };
@@ -0,0 +1,46 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { isRTLEnabled } from '@quintype/native-components/src/utils';
3
+ export const textAnswerStyles = (COLORS, FONT_SIZE, lineHeightMultiplier) => StyleSheet.create({
4
+ container: {
5
+ margin: 10,
6
+ display:'flex',
7
+ flexDirection:'row',
8
+ alignItems:'center',
9
+ marginBottom:20,
10
+ marginTop:5
11
+ },
12
+ questionText: {
13
+ fontSize: FONT_SIZE.h2,
14
+ fontWeight: '600',
15
+ lineHeight: FONT_SIZE.h2 * lineHeightMultiplier,
16
+ color: COLORS.BRAND_BLACK,
17
+ opacity: 0.8,
18
+ textAlign: isRTLEnabled() ? 'left' : 'auto',
19
+ },
20
+ answerText: {
21
+ fontSize: FONT_SIZE.h2,
22
+ lineHeight: FONT_SIZE.h2 * lineHeightMultiplier,
23
+ color: COLORS.BRAND_BLACK,
24
+ opacity: 0.8,
25
+ },
26
+ iconContainer:{
27
+ borderRadius:5,
28
+ height:10+FONT_SIZE.h1,
29
+ width:10+FONT_SIZE.h1,
30
+ backgroundColor:COLORS.BRAND_1,
31
+ display:'flex',
32
+ justifyContent:'center',
33
+ alignItems:'center',
34
+ marginRight:5,
35
+ alignSelf:'flex-start'
36
+ },
37
+ iconText:{
38
+ fontSize:FONT_SIZE.h1,
39
+ color:COLORS.DYNAMIC_PRIMARY_TEXT_COLOR
40
+ },
41
+ htmlContainer:{
42
+ alignSelf:'flex-start',
43
+ marginTop:-5,
44
+ width:'90%'
45
+ }
46
+ });
@@ -9,7 +9,7 @@ import { customHTMLStyles } from '../../constants/renderHTML';
9
9
  import { alterQuoteData } from '../../utils';
10
10
 
11
11
  export const TextBigFact = ({ text, attribution, id }) => {
12
- const { theme } = useContext(AppTheme);
12
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
13
13
  const {
14
14
  FONT_FAMILY,
15
15
  COLORS,
@@ -40,7 +40,7 @@ export const TextBigFact = ({ text, attribution, id }) => {
40
40
  key={Math.random()}
41
41
  baseFontStyle={style}
42
42
  onLinkPress={(evt, href) => {
43
- Linking.openURL(href);
43
+ useDeeplinkHandler(href, props?.navigation);
44
44
  }}
45
45
  tagsStyles={{
46
46
  del: customTagsStyles.del,
@@ -10,7 +10,7 @@ import { AppTheme } from '../../utils/context';
10
10
  import { alterQuoteData } from '../../utils';
11
11
 
12
12
  export const TextBlockQuote = ({ text, attribution }) => {
13
- const { theme } = useContext(AppTheme);
13
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
14
14
  const {
15
15
  FONT_FAMILY, FONT_SIZE, COLORS, CAN_COPY_TEXT, DARK_MODE, lineHeightMultiplier
16
16
  } = theme;
@@ -36,7 +36,7 @@ export const TextBlockQuote = ({ text, attribution }) => {
36
36
  key={Math.random()}
37
37
  baseFontStyle={style}
38
38
  onLinkPress={(evt, href) => {
39
- Linking.openURL(href);
39
+ useDeeplinkHandler(href, props?.navigation);
40
40
  }}
41
41
  tagsStyles={{
42
42
  del: customTagsStyles.del,
@@ -7,7 +7,7 @@ import { AppTheme } from '../../utils/context';
7
7
  import { customHTMLStyles } from '../../constants/renderHTML';
8
8
 
9
9
  export const TextBlurb = ({ text }) => {
10
- const { theme } = useContext(AppTheme);
10
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
11
11
  const {
12
12
  FONT_FAMILY, COLORS, FONT_SIZE, CAN_COPY_TEXT, lineHeightMultiplier,
13
13
  } = theme;
@@ -35,7 +35,7 @@ export const TextBlurb = ({ text }) => {
35
35
  key={Math.random()}
36
36
  baseFontStyle={style}
37
37
  onLinkPress={(evt, href) => {
38
- Linking.openURL(href);
38
+ useDeeplinkHandler(href, props?.navigation);
39
39
  }}
40
40
  tagsStyles={{
41
41
  del: customTagsStyles.del,
@@ -0,0 +1,54 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { useContext } from 'react';
3
+ import { View, StyleSheet, Linking, I18nManager } from 'react-native';
4
+ import { Text } from '@quintype/native-components/src/components';
5
+ import { textQuestionStyles } from '@quintype/native-components/src/components/TextQ/styles';
6
+ import { AppTheme } from '@quintype/native-components/src/utils/context';
7
+ import HTML from 'react-native-render-html';
8
+ import { customHTMLStyles } from '../../constants/renderHTML';
9
+ export const TextQ = ({ question }) => {
10
+ const { theme } = useContext(AppTheme);
11
+ const { COLORS, FONT_SIZE, lineHeightMultiplier, FONT_FAMILY } = theme;
12
+ const styles = textQuestionStyles(COLORS, FONT_SIZE, lineHeightMultiplier);
13
+ const customTagsStyles = customHTMLStyles();
14
+ const style = StyleSheet.flatten([
15
+ styles.questionText,
16
+ {
17
+ fontFamily: FONT_FAMILY.primaryBold,
18
+ writingDirection: I18nManager.isRTL ? "rtl" : "ltr",
19
+ },
20
+ ]);
21
+ return (
22
+ <View testID="text-question" style={styles.container}>
23
+ <View style={styles.iconContainer}>
24
+ <Text style={styles.iconText}>Q</Text>
25
+ </View>
26
+ <HTML
27
+ html={question}
28
+ key={Math.random()}
29
+ baseFontStyle={style}
30
+ onLinkPress={(evt, href) => {
31
+ Linking.openURL(href);
32
+ }}
33
+ tagsStyles={{
34
+ del: customTagsStyles.del,
35
+ ins: customTagsStyles.ins,
36
+ p: customTagsStyles.p,
37
+ li: customTagsStyles.li,
38
+ a: customTagsStyles.a,
39
+ h2: customTagsStyles.h,
40
+ h3: customTagsStyles.h,
41
+ h4: customTagsStyles.h,
42
+ h5: customTagsStyles.h,
43
+ h6: customTagsStyles.h,
44
+ }}
45
+ containerStyle={styles.htmlContainer}
46
+ />
47
+ </View>
48
+ );
49
+ };
50
+
51
+ TextQ.propTypes = {
52
+ question: PropTypes.string.isRequired,
53
+ answer: PropTypes.string.isRequired,
54
+ };
@@ -0,0 +1,46 @@
1
+ import { isRTLEnabled } from '@quintype/native-components/src/utils';
2
+ import { StyleSheet } from 'react-native';
3
+
4
+ export const textQuestionStyles = (COLORS, FONT_SIZE, lineHeightMultiplier) => StyleSheet.create({
5
+ container: {
6
+ margin: 10,
7
+ display:'flex',
8
+ flexDirection:'row',
9
+ alignItems:'center',
10
+ marginBottom:0,
11
+ marginTop:0
12
+ },
13
+ questionText: {
14
+ fontSize: FONT_SIZE.h2,
15
+ lineHeight: FONT_SIZE.h2 * lineHeightMultiplier,
16
+ color: COLORS.BRAND_BLACK,
17
+ opacity: 0.8,
18
+ textAlign: isRTLEnabled() ? 'left' : 'auto',
19
+ },
20
+ answerText: {
21
+ fontSize: FONT_SIZE.h2,
22
+ lineHeight: FONT_SIZE.h2 * lineHeightMultiplier,
23
+ color: COLORS.BRAND_BLACK,
24
+ opacity: 0.8,
25
+ },
26
+ iconContainer:{
27
+ borderRadius:5,
28
+ height:10+FONT_SIZE.h1,
29
+ width:10+FONT_SIZE.h1,
30
+ backgroundColor:COLORS.BRAND_1,
31
+ display:'flex',
32
+ justifyContent:'center',
33
+ alignItems:'center',
34
+ marginRight:5,
35
+ alignSelf:'flex-start'
36
+ },
37
+ iconText:{
38
+ fontSize:FONT_SIZE.h1,
39
+ color:COLORS.DYNAMIC_PRIMARY_TEXT_COLOR
40
+ },
41
+ htmlContainer:{
42
+ alignSelf:'flex-start',
43
+ marginTop:-10,
44
+ width:'90%'
45
+ }
46
+ });
@@ -4,6 +4,8 @@ import { View } from 'react-native';
4
4
  import { Text } from '../index';
5
5
  import { textQandAStyles } from './styles';
6
6
  import { AppTheme } from '../../utils/context';
7
+ import { TextQ } from '../TextQ/index';
8
+ import { TextA } from '../TextA/index';
7
9
 
8
10
  export const TextQandA = ({ question, answer }) => {
9
11
  const { theme } = useContext(AppTheme);
@@ -11,8 +13,8 @@ export const TextQandA = ({ question, answer }) => {
11
13
  const styles = textQandAStyles(COLORS, FONT_SIZE, lineHeightMultiplier);
12
14
  return (
13
15
  <View testID="text-q-and-a" style={styles.container}>
14
- <Text style={styles.questionText}>{question}</Text>
15
- <Text style={styles.answerText}>{answer}</Text>
16
+ {question && <TextQ question={question}/>}
17
+ {answer && <TextA answer={answer}/>}
16
18
  </View>
17
19
  );
18
20
  };
@@ -2,19 +2,6 @@ import { StyleSheet } from 'react-native';
2
2
 
3
3
  export const textQandAStyles = (COLORS, FONT_SIZE, lineHeightMultiplier) => StyleSheet.create({
4
4
  container: {
5
- margin: 10,
6
- },
7
- questionText: {
8
- fontSize: FONT_SIZE.h2,
9
- fontWeight: '600',
10
- lineHeight: FONT_SIZE.h2 * lineHeightMultiplier,
11
- color: COLORS.BRAND_BLACK,
12
- opacity: 0.8,
13
- },
14
- answerText: {
15
- fontSize: FONT_SIZE.h2,
16
- lineHeight: FONT_SIZE.h2 * lineHeightMultiplier,
17
- color: COLORS.BRAND_BLACK,
18
- opacity: 0.8,
19
- },
5
+ margin: 0
6
+ }
20
7
  });
@@ -44,3 +44,5 @@ export { IconText } from './IconText';
44
44
  export { CustomSwitch } from './CustomSwitch';
45
45
  export { RelatedStoriesCard } from './RelatedStoriesCard';
46
46
  export { References } from './References';
47
+ export {TextA} from './TextA'
48
+ export {TextQ} from './TextQ'