@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.
Files changed (44) hide show
  1. package/package.json +1 -1
  2. package/src/components/AlsoRead/index.js +4 -4
  3. package/src/components/AuthorRow/index.js +3 -3
  4. package/src/components/BackNavigator/index.js +6 -6
  5. package/src/components/Button/index.js +1 -1
  6. package/src/components/CollectionCard/index.js +10 -20
  7. package/src/components/CollectionCardNew/index.js +84 -0
  8. package/src/components/CollectionTitle/CollectionTitle.test.js +12 -0
  9. package/src/components/CollectionTitle/__snapshots__/CollectionTitle.test.js.snap +3 -0
  10. package/src/components/CollectionTitle/index.js +38 -19
  11. package/src/components/CollectionTitle/styles.js +13 -11
  12. package/src/components/CollectionTitleNew/index.js +44 -0
  13. package/src/components/CollectionTitleNew/styles.js +20 -0
  14. package/src/components/CustomSwitch/index.js +4 -4
  15. package/src/components/DailyMotionPlayer/index.js +2 -2
  16. package/src/components/Header/index.js +2 -2
  17. package/src/components/Html/index.js +4 -4
  18. package/src/components/IconText/index.js +4 -4
  19. package/src/components/JSEmbedElement/index.js +35 -6
  20. package/src/components/LightBoxImage/index.js +2 -2
  21. package/src/components/PDFReader/index.js +8 -7
  22. package/src/components/PrimaryStoryCard/PrimaryStoryCard.test.js +43 -0
  23. package/src/components/PrimaryStoryCard/index.js +63 -44
  24. package/src/components/PrimaryStoryCard/styles.js +28 -32
  25. package/src/components/PrimaryStoryCardNew/index.js +134 -0
  26. package/src/components/PrimaryStoryCardNew/styles.js +70 -0
  27. package/src/components/RadioButton/index.js +3 -3
  28. package/src/components/Rating/index.js +1 -1
  29. package/src/components/RelatedStoriesCard/index.js +12 -2
  30. package/src/components/SecondaryStoryCard/SecondaryStoryCard.test.js +51 -0
  31. package/src/components/SecondaryStoryCard/index.js +62 -37
  32. package/src/components/SecondaryStoryCard/styles.js +34 -37
  33. package/src/components/SecondaryStoryCardNew/index.js +140 -0
  34. package/src/components/SecondaryStoryCardNew/styles.js +82 -0
  35. package/src/components/Story/index.js +13 -12
  36. package/src/components/StoryHeader/index.js +8 -8
  37. package/src/components/StoryText/index.js +2 -5
  38. package/src/components/Text/index.js +1 -3
  39. package/src/components/TextA/index.js +4 -4
  40. package/src/components/TextBigFact/index.js +4 -4
  41. package/src/components/TextBlockQuote/index.js +5 -5
  42. package/src/components/TextBlurb/index.js +3 -3
  43. package/src/components/TextQandA/index.js +3 -2
  44. package/src/components/index.js +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.22.5-beta.0",
3
+ "version": "2.22.6",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,10 +1,10 @@
1
- import get from 'lodash/get';
2
1
  import React, { useContext } from 'react';
3
- import { TouchableOpacity, View } from 'react-native';
4
- import { FallbackIcon } from '../../Icons/FallBackIcon';
5
- import { AppTheme } from '../../utils';
2
+ import get from 'lodash/get';
3
+ import { View, TouchableOpacity } from 'react-native';
6
4
  import { ResponsiveImage, Text } from '../index';
7
5
  import { alsoReadStyles } from './styles';
6
+ import { FallbackIcon } from '../../Icons/FallBackIcon';
7
+ import { AppTheme } from '../../utils';
8
8
 
9
9
  export const AlsoRead = (props) => {
10
10
  const {
@@ -2,12 +2,12 @@ import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
3
  import { View } from 'react-native';
4
4
  import Icon from 'react-native-vector-icons/FontAwesome';
5
- import { ActionText } from '../ActionText/ActionText';
6
5
  import { ResponsiveImage, Text } from '../index';
6
+ import { ActionText } from '../ActionText/ActionText';
7
7
 
8
- import { COMP_CONTENT_CONSTANTS } from '../../constants/component-constants/content-constants/constants';
9
- import { AppTheme } from '../../utils';
10
8
  import { authorRowStyleSheet } from './styles';
9
+ import { AppTheme } from '../../utils';
10
+ import { COMP_CONTENT_CONSTANTS } from '../../constants/component-constants/content-constants/constants';
11
11
 
12
12
  export const AuthorRow = ({
13
13
  authors,
@@ -1,18 +1,18 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, { useContext } from 'react';
3
2
  import {
4
- I18nManager,
5
- StyleSheet,
6
- TouchableOpacity,
7
3
  View,
4
+ StyleSheet,
8
5
  ViewPropTypes,
6
+ TouchableOpacity,
7
+ I18nManager,
9
8
  } from 'react-native';
10
9
  import Icon from 'react-native-vector-icons/AntDesign';
11
- import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
10
+ import PropTypes from 'prop-types';
12
11
  import { AppTheme } from '../../utils/context';
12
+ import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
13
13
 
14
- import { Text } from '../Text';
15
14
  import { backNavigatorStyles } from './styles';
15
+ import { Text } from '../Text';
16
16
 
17
17
  export const BackNavigator = (props) => {
18
18
  const { theme } = useContext(AppTheme);
@@ -6,10 +6,10 @@ import {
6
6
  View,
7
7
  ViewPropTypes,
8
8
  } from "react-native";
9
- import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
10
9
  import { AppTheme } from "../../utils";
11
10
  import { Text } from "../Text";
12
11
  import { styles } from "./styles";
12
+ import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
13
13
 
14
14
  export const Button = (props) => {
15
15
  const { icon, text, onPress } = props;
@@ -1,22 +1,20 @@
1
1
  import get from 'lodash/get';
2
2
  import isEmpty from 'lodash/isEmpty';
3
3
  import PropTypes from 'prop-types';
4
- import React, { memo } from 'react';
4
+ import React from 'react';
5
5
  import { getScreenPercentageWidth } from '../../utils/index';
6
6
  import {
7
7
  CollectionTitle,
8
8
  PrimaryStoryCard,
9
9
  SecondaryStoryCard,
10
- ShareButton,
11
10
  } from '../index';
12
11
 
13
- const CollectionCardBase = ({
12
+ export const CollectionCard = ({
14
13
  cdn,
15
14
  collectionName,
16
15
  stories,
17
16
  onCollectionPress,
18
17
  onStoryPress,
19
- collectionTestID,
20
18
  offset,
21
19
  horizontalPadding,
22
20
  initialOffset, /* Number of items to load on first load */
@@ -24,10 +22,10 @@ const CollectionCardBase = ({
24
22
  }) => {
25
23
  const sliceLimit = offset || initialOffset || 5;
26
24
  const primaryStory = !isEmpty(stories) && get(stories, [0, 'story'], stories[0]);
27
-
28
25
  return (
29
26
  <>
30
- {!hideCollectionTitle && (
27
+ {!hideCollectionTitle
28
+ && (
31
29
  <CollectionTitle
32
30
  title={collectionName}
33
31
  onPress={onCollectionPress}
@@ -35,13 +33,11 @@ const CollectionCardBase = ({
35
33
  />
36
34
  )}
37
35
  <PrimaryStoryCard
38
- collectionTestID={collectionTestID}
39
36
  onPress={() => {
40
37
  !isEmpty(stories) && onStoryPress(primaryStory);
41
38
  }}
42
39
  cdn={cdn}
43
40
  story={!isEmpty(stories) ? primaryStory : {}}
44
- iconComponent={<ShareButton story={primaryStory} inListingStoryCard />}
45
41
  imageWidth={getScreenPercentageWidth(100) - 2 * horizontalPadding}
46
42
  horizontalPadding={horizontalPadding}
47
43
  />
@@ -49,13 +45,11 @@ const CollectionCardBase = ({
49
45
  const secondaryStory = get(currentStory, ['story'], currentStory);
50
46
  return (
51
47
  <SecondaryStoryCard
52
- collectionTestID={collectionTestID}
53
48
  onPress={() => onStoryPress(secondaryStory)}
54
- key={secondaryStory?.id}
49
+ key={`${secondaryStory?.id}`}
55
50
  cdn={cdn}
56
51
  story={secondaryStory}
57
- iconComponent={<ShareButton story={secondaryStory} inListingStoryCard />}
58
- imageWidth={getScreenPercentageWidth(28)}
52
+ imageWidth={getScreenPercentageWidth(40)}
59
53
  horizontalPadding={horizontalPadding}
60
54
  />
61
55
  );
@@ -63,22 +57,18 @@ const CollectionCardBase = ({
63
57
  </>
64
58
  );
65
59
  };
66
-
67
- CollectionCardBase.propTypes = {
68
- offset: PropTypes.number,
60
+ CollectionCard.propTypes = {
69
61
  initialOffset: PropTypes.number,
70
62
  cdn: PropTypes.string.isRequired,
71
- collectionName: PropTypes.string,
63
+ collectionName: PropTypes.string.isRequired,
72
64
  stories: PropTypes.array.isRequired,
73
65
  onCollectionPress: PropTypes.func,
74
66
  onStoryPress: PropTypes.func,
75
- collectionTestID: PropTypes.string,
67
+ offset: PropTypes.number,
76
68
  horizontalPadding: PropTypes.number,
77
69
  hideCollectionTitle: PropTypes.bool,
78
70
  };
79
71
 
80
- CollectionCardBase.defaultProps = {
72
+ CollectionCard.defaultProps = {
81
73
  horizontalPadding: 12,
82
74
  };
83
-
84
- export const CollectionCard = memo(CollectionCardBase);
@@ -0,0 +1,84 @@
1
+ import get from 'lodash/get';
2
+ import isEmpty from 'lodash/isEmpty';
3
+ import PropTypes from 'prop-types';
4
+ import React, { memo } from 'react';
5
+ import { getScreenPercentageWidth } from '../../utils/index';
6
+ import {
7
+ CollectionTitleNew,
8
+ PrimaryStoryCardNew,
9
+ SecondaryStoryCardNew,
10
+ ShareButton,
11
+ } from '../index';
12
+
13
+ const CollectionCardNewBase = ({
14
+ cdn,
15
+ collectionName,
16
+ stories,
17
+ onCollectionPress,
18
+ onStoryPress,
19
+ collectionTestID,
20
+ offset,
21
+ horizontalPadding,
22
+ initialOffset, /* Number of items to load on first load */
23
+ hideCollectionTitle,
24
+ }) => {
25
+ const sliceLimit = offset || initialOffset || 5;
26
+ const primaryStory = !isEmpty(stories) && get(stories, [0, 'story'], stories[0]);
27
+
28
+ return (
29
+ <>
30
+ {!hideCollectionTitle && (
31
+ <CollectionTitleNew
32
+ title={collectionName}
33
+ onPress={onCollectionPress}
34
+ horizontalPadding={horizontalPadding}
35
+ />
36
+ )}
37
+ <PrimaryStoryCardNew
38
+ collectionTestID={collectionTestID}
39
+ onPress={() => {
40
+ !isEmpty(stories) && onStoryPress(primaryStory);
41
+ }}
42
+ cdn={cdn}
43
+ story={!isEmpty(stories) ? primaryStory : {}}
44
+ iconComponent={<ShareButton story={primaryStory} inListingStoryCard />}
45
+ imageWidth={getScreenPercentageWidth(100) - 2 * horizontalPadding}
46
+ horizontalPadding={horizontalPadding}
47
+ />
48
+ {stories.slice(1, sliceLimit).map((currentStory) => {
49
+ const secondaryStory = get(currentStory, ['story'], currentStory);
50
+ return (
51
+ <SecondaryStoryCardNew
52
+ collectionTestID={collectionTestID}
53
+ onPress={() => onStoryPress(secondaryStory)}
54
+ key={secondaryStory?.id}
55
+ cdn={cdn}
56
+ story={secondaryStory}
57
+ iconComponent={<ShareButton story={secondaryStory} inListingStoryCard />}
58
+ imageWidth={getScreenPercentageWidth(28)}
59
+ horizontalPadding={horizontalPadding}
60
+ />
61
+ );
62
+ })}
63
+ </>
64
+ );
65
+ };
66
+
67
+ CollectionCardNewBase.propTypes = {
68
+ offset: PropTypes.number,
69
+ initialOffset: PropTypes.number,
70
+ cdn: PropTypes.string.isRequired,
71
+ collectionName: PropTypes.string,
72
+ stories: PropTypes.array.isRequired,
73
+ onCollectionPress: PropTypes.func,
74
+ onStoryPress: PropTypes.func,
75
+ collectionTestID: PropTypes.string,
76
+ horizontalPadding: PropTypes.number,
77
+ hideCollectionTitle: PropTypes.bool,
78
+ };
79
+
80
+ CollectionCardNewBase.defaultProps = {
81
+ horizontalPadding: 12,
82
+ };
83
+
84
+ export const CollectionCardNew = memo(CollectionCardNewBase);
@@ -0,0 +1,12 @@
1
+ import 'react-native';
2
+ import React from 'react';
3
+ import renderer from 'react-test-renderer';
4
+
5
+ import { CollectionTitle } from './index';
6
+ import { mockContext } from '../../utils';
7
+
8
+ test('renders correctly', () => {
9
+ const component = mockContext(<CollectionTitle />);
10
+ const tree = renderer.create(component).toJSON();
11
+ expect(tree).toMatchSnapshot();
12
+ });
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders correctly 1`] = `null`;
@@ -1,42 +1,61 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { memo, useContext } from 'react';
2
+ import React, { useContext } from 'react';
3
3
  import {
4
+ TextStyle,
5
+ TouchableOpacity,
6
+ TouchableOpacityProps,
7
+ View,
8
+ ViewStyle,
4
9
  StyleSheet,
5
- TouchableOpacity
6
10
  } from 'react-native';
7
- import { AppTheme } from '../../utils';
11
+
8
12
  import { Text } from '../index';
9
- import { collectionTitleStyles } from './styles';
10
13
 
11
- const CollectionTitleBase = (props) => {
14
+ import { collectionStyles } from './styles';
15
+ import { AppTheme } from '../../utils';
16
+ import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
17
+
18
+ export const CollectionTitle = (props) => {
12
19
  const { theme } = useContext(AppTheme);
13
- const styles = collectionTitleStyles(theme);
20
+ const styles = collectionStyles(theme);
14
21
  const containerStyle = StyleSheet.flatten([
15
- styles.container,
22
+ styles.titleContainer,
16
23
  { paddingHorizontal: props.horizontalPadding },
17
24
  ]);
18
- const titleStyle = StyleSheet.flatten([styles.title, props.titleStyle]);
25
+ const titleStyle = StyleSheet.flatten([styles.titleStyle, props.titleStyle]);
26
+ const indicatorStyle = StyleSheet.flatten([
27
+ styles.indicatorStyle,
28
+ props.indicatorStyle,
29
+ ]);
19
30
 
20
31
  if (!props.title) {
21
32
  return null;
22
33
  }
23
34
 
24
35
  return (
25
- <TouchableOpacity style={containerStyle} onPress={props.onPress}>
26
- <Text style={titleStyle}>{props.title}</Text>
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
48
  </TouchableOpacity>
28
49
  );
29
50
  };
30
51
 
31
- CollectionTitleBase.propTypes = TouchableOpacityProps
32
- && {
33
- title: PropTypes.string,
34
- titleStyle: TextStyle,
35
- horizontalPadding: PropTypes.number,
36
- };
52
+ CollectionTitle.propTypes = TouchableOpacityProps && {
53
+ title: PropTypes.string,
54
+ titleStyle: TextStyle,
55
+ indicatorStyle: ViewStyle,
56
+ horizontalPadding: PropTypes.number,
57
+ };
37
58
 
38
- CollectionTitleBase.defaultProps = {
59
+ CollectionTitle.defaultProps = {
39
60
  horizontalPadding: 12,
40
61
  };
41
-
42
- export const CollectionTitle = memo(CollectionTitleBase);
@@ -1,20 +1,22 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- export const collectionTitleStyles = (appThemeContext) => {
4
- const { COLORS, FONT_SIZE, FONT_FAMILY } = appThemeContext;
5
-
3
+ export const collectionStyles = (appThemeContext) => {
4
+ const { COLORS, FONT_SIZE } = appThemeContext;
6
5
  return StyleSheet.create({
7
- container: {
8
- justifyContent: 'center',
6
+ titleContainer: {
9
7
  backgroundColor: COLORS.BRAND_WHITE,
10
- paddingHorizontal: 12,
11
- paddingVertical: 8,
12
- marginTop: 8,
8
+ paddingVertical: 12,
9
+ justifyContent: 'center',
13
10
  },
14
- title: {
15
- fontSize: FONT_SIZE.h3,
16
- fontFamily: FONT_FAMILY.secondaryBold,
11
+ titleStyle: {
12
+ fontSize: FONT_SIZE.h1,
17
13
  color: COLORS.BRAND_5,
18
14
  },
15
+ indicatorStyle: {
16
+ marginTop: 8,
17
+ width: 30,
18
+ height: 3,
19
+ backgroundColor: COLORS.BRAND_1,
20
+ },
19
21
  });
20
22
  };
@@ -0,0 +1,44 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { useContext, memo } from 'react';
3
+ import {
4
+ TextStyle,
5
+ TouchableOpacity,
6
+ TouchableOpacityProps,
7
+ StyleSheet,
8
+ } from 'react-native';
9
+ import { Text } from '../index';
10
+ import { collectionTitleStyles } from './styles';
11
+ import { AppTheme } from '../../utils';
12
+
13
+ const CollectionTitleNewBase = (props) => {
14
+ const { theme } = useContext(AppTheme);
15
+ const styles = collectionTitleStyles(theme);
16
+ const containerStyle = StyleSheet.flatten([
17
+ styles.container,
18
+ { paddingHorizontal: props.horizontalPadding },
19
+ ]);
20
+ const titleStyle = StyleSheet.flatten([styles.title, props.titleStyle]);
21
+
22
+ if (!props.title) {
23
+ return null;
24
+ }
25
+
26
+ return (
27
+ <TouchableOpacity style={containerStyle} onPress={props.onPress}>
28
+ <Text style={titleStyle}>{props.title}</Text>
29
+ </TouchableOpacity>
30
+ );
31
+ };
32
+
33
+ CollectionTitleNewBase.propTypes = TouchableOpacityProps
34
+ && {
35
+ title: PropTypes.string,
36
+ titleStyle: TextStyle,
37
+ horizontalPadding: PropTypes.number,
38
+ };
39
+
40
+ CollectionTitleNewBase.defaultProps = {
41
+ horizontalPadding: 12,
42
+ };
43
+
44
+ export const CollectionTitleNew = memo(CollectionTitleNewBase);
@@ -0,0 +1,20 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const collectionTitleStyles = (appThemeContext) => {
4
+ const { COLORS, FONT_SIZE, FONT_FAMILY } = appThemeContext;
5
+
6
+ return StyleSheet.create({
7
+ container: {
8
+ justifyContent: 'center',
9
+ backgroundColor: COLORS.BRAND_WHITE,
10
+ paddingHorizontal: 12,
11
+ paddingVertical: 8,
12
+ marginTop: 8,
13
+ },
14
+ title: {
15
+ fontSize: FONT_SIZE.h3,
16
+ fontFamily: FONT_FAMILY.secondaryBold,
17
+ color: COLORS.BRAND_5,
18
+ },
19
+ });
20
+ };
@@ -1,11 +1,11 @@
1
- import PropTypes from "prop-types";
2
- import React, { useContext } from "react";
1
+ import React, { useContext, useState } from "react";
3
2
  import { Switch, View } from "react-native";
3
+ import PropTypes from "prop-types";
4
4
  import Icon from "react-native-vector-icons/FontAwesome";
5
- import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
6
- import { AppTheme } from "../../utils";
7
5
  import { Text } from "../Text";
6
+ import { AppTheme } from "../../utils";
8
7
  import { customSwitchStyles } from "./styles";
8
+ import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
9
9
 
10
10
  export const CustomSwitch = ({
11
11
  label = "",
@@ -1,6 +1,6 @@
1
- import get from 'lodash/get';
2
- import PropTypes from 'prop-types';
3
1
  import React, { useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import get from 'lodash/get';
4
4
  import { WebView } from 'react-native-webview';
5
5
  import { dailyMotionStyles } from './styles';
6
6
 
@@ -7,9 +7,9 @@ import {
7
7
  ViewPropTypes,
8
8
  } from "react-native";
9
9
 
10
- import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants";
11
- import { AppTheme } from "../../utils";
12
10
  import { headerStyles } from "./styles";
11
+ import { AppTheme } from "../../utils";
12
+ import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants";
13
13
 
14
14
  export const Header = (props) => {
15
15
  const { theme } = useContext(AppTheme);
@@ -1,8 +1,8 @@
1
- import { Text } from "@quintype/native-components/src/components/Text";
2
- import isHTML from "is-html";
3
- import React from "react";
4
- import { I18nManager, Linking, StyleSheet } from "react-native";
1
+ import { TouchableOpacity, View, I18nManager, StyleSheet, Linking } from "react-native";
5
2
  import HTML from "react-native-render-html";
3
+ import React from "react";
4
+ import isHTML from "is-html";
5
+ import { Text } from "@quintype/native-components/src/components/Text";
6
6
 
7
7
  const CustomHtmlParser = ({ text, textStyle={}, containerStyle={} }) => {
8
8
  const textStyles = StyleSheet.flatten([
@@ -1,15 +1,15 @@
1
- import PropTypes from "prop-types";
2
1
  import React from "react";
3
2
  import {
4
- StyleSheet,
5
- TouchableOpacity,
6
3
  View,
4
+ TouchableOpacity,
5
+ StyleSheet,
7
6
  ViewPropTypes,
8
7
  } from "react-native";
9
8
  import Icon from "react-native-vector-icons/FontAwesome";
10
- import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
9
+ import PropTypes from "prop-types";
11
10
  import { Text } from "../Text";
12
11
  import { iconTextStyles } from "./iconText_styles";
12
+ import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
13
13
 
14
14
  const IconText = ({
15
15
  onPress,
@@ -1,9 +1,9 @@
1
+ import { WebView } from 'react-native-webview';
2
+ import React, { useState, useRef, useEffect } from 'react';
1
3
  import { decode as atob } from 'base-64';
2
- import get from 'lodash/get';
3
4
  import PropTypes from 'prop-types';
4
- import React, { useEffect, useRef, useState } from 'react';
5
5
  import { Dimensions, View } from 'react-native';
6
- import { WebView } from 'react-native-webview';
6
+ import get from 'lodash/get';
7
7
  import { STORY_ELEMENT_SUBTYPES } from '../../constants/cardConstants';
8
8
 
9
9
  const escapeRegExp = (string) => string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&');
@@ -64,7 +64,6 @@ const getHTMLContent = (embedJs) => {
64
64
  <style>
65
65
  iframe{
66
66
  width:${width - 20}px;
67
- height:${width - 20}px;
68
67
  }
69
68
  </style>
70
69
  </head>
@@ -76,7 +75,7 @@ const getHTMLContent = (embedJs) => {
76
75
  };
77
76
 
78
77
  export const JSEmbedElement = (props) => {
79
- const [height, setHeight] = useState(300);
78
+ const [height, setHeight] = useState(-1);
80
79
  const webViewRef = useRef(null);
81
80
  const width = get(
82
81
  props,
@@ -107,13 +106,42 @@ export const JSEmbedElement = (props) => {
107
106
  };
108
107
  };
109
108
 
109
+ if (height > 0) {
110
+ return <View testID="embed-js">
111
+ <WebView
112
+ ref={webViewRef}
113
+ style={{
114
+ width,
115
+ height: Number(height),
116
+ flex: 0,
117
+ opacity: 0.99,
118
+ }}
119
+ automaticallyAdjustContentInsets={false}
120
+ scrollEnabled={false}
121
+ onMessage={handleOnMessage}
122
+ javaScriptEnabled
123
+ domStorageEnabled
124
+ startInLoadingState
125
+ allowsFullscreenVideo={false}
126
+ originWhitelist={['*']}
127
+ onError={(syntheticEvent) => {
128
+ const { nativeEvent } = syntheticEvent;
129
+ console.warn('WebView error: ', nativeEvent);
130
+ }}
131
+ source={constructSource()}
132
+ mixedContentMode="always"
133
+ mediaPlaybackRequiresUserAction={true}
134
+ />
135
+ </View>
136
+ }
137
+
110
138
  return (
111
139
  <View testID="embed-js">
112
140
  <WebView
113
141
  ref={webViewRef}
114
142
  style={{
115
143
  width,
116
- height,
144
+ height: Number(height),
117
145
  flex: 0,
118
146
  opacity: 0.99,
119
147
  }}
@@ -132,6 +160,7 @@ export const JSEmbedElement = (props) => {
132
160
  source={constructSource()}
133
161
  mixedContentMode="always"
134
162
  mediaPlaybackRequiresUserAction={true}
163
+ injectedJavaScript='window.ReactNativeWebView.postMessage(document.body.scrollHeight)'
135
164
  />
136
165
  </View>
137
166
  );
@@ -1,9 +1,9 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useState } from 'react';
3
3
  import { TouchableOpacity } from 'react-native';
4
- import { getImageHeight } from '../../utils';
5
- import { LightBox } from '../LightBox';
6
4
  import { ResponsiveImage } from '../ResponsiveImage';
5
+ import { LightBox } from '../LightBox';
6
+ import { getImageHeight } from '../../utils';
7
7
 
8
8
  export const LightBoxImage = ({
9
9
  data, hero, currentLayout, additionalStyles, elementType, onClickHandler = () => {}, index,
@@ -1,20 +1,21 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { useContext, useState } from 'react';
2
+ import React, { useState, useContext } from 'react';
3
3
  import {
4
+ View,
4
5
  Modal,
5
- Platform,
6
+ TouchableOpacity,
6
7
  SafeAreaView,
7
8
  StyleSheet,
8
- TouchableOpacity,
9
- View
9
+ Platform
10
10
  } from 'react-native';
11
- import Pdf from 'react-native-pdf';
12
11
  import IonIcon from 'react-native-vector-icons/Ionicons';
13
12
  import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
13
+ import Pdf from 'react-native-pdf';
14
14
 
15
- import { AppTheme } from '../../utils';
16
- import { ShareButton, Text } from '../index';
15
+ import { Text } from '../index';
17
16
  import { pdfStyles } from './styles';
17
+ import { ShareButton } from '../index';
18
+ import { AppTheme } from '../../utils';
18
19
 
19
20
  export const PDFReader = ({ card, story }) => {
20
21
  const [modalVisible, setModalVisible] = useState(false);