@quintype/native-components 2.30.14 → 2.30.16-beta.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.30.14",
3
+ "version": "2.30.16-beta.0",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,87 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { memo, useContext } from 'react';
3
+ import { ScrollView, StyleSheet, View } from 'react-native';
4
+ import HTML from 'react-native-render-html';
5
+ import { customHTMLStyles } from '../../constants/renderHTML';
6
+ import { AppTheme } from '../../utils/context';
7
+ import { Text } from '../index';
8
+
9
+ const SUMMARY_FONT_SIZE = 19;
10
+
11
+ const ShortSummaryBase = ({ html }) => {
12
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
13
+ const { FONT_FAMILY, COLORS, CAN_COPY_TEXT } = theme;
14
+
15
+ if (!html) return null;
16
+
17
+ const baseFontStyle = StyleSheet.flatten({
18
+ fontFamily: FONT_FAMILY.secondary,
19
+ fontSize: SUMMARY_FONT_SIZE,
20
+ lineHeight: SUMMARY_FONT_SIZE * 1.5,
21
+ color: COLORS.BRAND_BLACK,
22
+ opacity: 0.85,
23
+ });
24
+
25
+ const customTagsStyles = customHTMLStyles();
26
+
27
+ // Override tag font sizes to stay at SUMMARY_FONT_SIZE instead of theme FONT_SIZE.p1
28
+ const tagsStyles = {
29
+ del: customTagsStyles.del,
30
+ ins: customTagsStyles.ins,
31
+ p: { ...customTagsStyles.p, fontSize: SUMMARY_FONT_SIZE, lineHeight: SUMMARY_FONT_SIZE * 1.5 },
32
+ li: { ...customTagsStyles.li, fontSize: SUMMARY_FONT_SIZE, lineHeight: SUMMARY_FONT_SIZE * 1.5 },
33
+ ul: customTagsStyles.ul,
34
+ ol: customTagsStyles.ol,
35
+ a: { ...customTagsStyles.a, fontSize: SUMMARY_FONT_SIZE, lineHeight: SUMMARY_FONT_SIZE * 1.5 },
36
+ h2: customTagsStyles.h,
37
+ h3: customTagsStyles.h,
38
+ h4: customTagsStyles.h,
39
+ h5: customTagsStyles.h,
40
+ h6: customTagsStyles.h,
41
+ };
42
+
43
+ return (
44
+ // flex:1 lets the summary consume leftover space between headline and meta block.
45
+ // The inner ScrollView makes rich/long content scrollable within that space
46
+ // without pushing siblings out of position.
47
+ <ScrollView
48
+ style={styles.fill}
49
+ contentContainerStyle={styles.scrollContent}
50
+ showsVerticalScrollIndicator={false}
51
+ nestedScrollEnabled
52
+ >
53
+ <HTML
54
+ html={html}
55
+ textSelectable={CAN_COPY_TEXT}
56
+ baseFontStyle={baseFontStyle}
57
+ onLinkPress={(_evt, href) => useDeeplinkHandler && useDeeplinkHandler(href)}
58
+ listsPrefixesRenderers={{
59
+ ul: () => <View style={customTagsStyles['ul-bullet']} />,
60
+ ol: (htmlAttribs, _children, _css, passProps) => {
61
+ const { index } = passProps;
62
+ const bulletNumber = htmlAttribs.start
63
+ ? parseInt(htmlAttribs.start) + index
64
+ : index + 1;
65
+ return <Text style={customTagsStyles['ol-number']}>{bulletNumber})</Text>;
66
+ },
67
+ }}
68
+ tagsStyles={tagsStyles}
69
+ />
70
+ </ScrollView>
71
+ );
72
+ };
73
+
74
+ const styles = StyleSheet.create({
75
+ fill: {
76
+ flex: 1,
77
+ },
78
+ scrollContent: {
79
+ paddingBottom: 4,
80
+ },
81
+ });
82
+
83
+ ShortSummaryBase.propTypes = {
84
+ html: PropTypes.string,
85
+ };
86
+
87
+ export const ShortSummary = memo(ShortSummaryBase);
@@ -32,6 +32,7 @@ export { TextBlurb } from './TextBlurb';
32
32
  export { TextQandA } from './TextQandA';
33
33
  export { TextQuote } from './TextQuote';
34
34
  export { TextSummary } from './TextSummary';
35
+ export { ShortSummary } from './ShortSummary';
35
36
  export { TitleElement } from './TitleElement';
36
37
  export { WebView } from './WebView';
37
38
  export { YouTubePlayer } from './YouTubePlayer';