@quintype/native-components 2.30.15 → 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
|
@@ -20,18 +20,13 @@ export const AuthorRow = ({
|
|
|
20
20
|
const { theme } = useContext(AppTheme);
|
|
21
21
|
const { COLORS, translate, enableReadTimeOnStoryScreen, hideAuthorName } = theme;
|
|
22
22
|
const styles = authorRowStyleSheet(theme);
|
|
23
|
-
const shouldShowAuthors = !hideAuthorName;
|
|
24
|
-
const shouldShowReadTime = Boolean(enableReadTimeOnStoryScreen && readtime);
|
|
25
|
-
const readTimeLabel = `${shouldShowAuthors ? '| ' : ''}${readtime} ${translate(
|
|
26
|
-
'min read',
|
|
27
|
-
)}`;
|
|
28
23
|
|
|
29
|
-
if (
|
|
24
|
+
if (hideAuthorName) return null;
|
|
30
25
|
|
|
31
26
|
return (
|
|
32
27
|
<View style={styles.authorRow}>
|
|
33
|
-
{
|
|
34
|
-
const avatarUrl = author?.['avatar-s3-key'] ? `${cdn}/${author?.['avatar-s3-key']}` :
|
|
28
|
+
{authors?.map((author) => {
|
|
29
|
+
const avatarUrl = author?.['avatar-s3-key'] ? `${cdn}/${author?.['avatar-s3-key']}` : author?.['avatar-url'] ?? null;
|
|
35
30
|
if (!author.name) {
|
|
36
31
|
return null;
|
|
37
32
|
}
|
|
@@ -78,10 +73,12 @@ export const AuthorRow = ({
|
|
|
78
73
|
</View>
|
|
79
74
|
);
|
|
80
75
|
})}
|
|
81
|
-
{
|
|
76
|
+
{enableReadTimeOnStoryScreen && readtime ? (
|
|
82
77
|
<View style={styles.readtimeComponent}>
|
|
83
78
|
<Text style={styles.readtime}>
|
|
84
|
-
{
|
|
79
|
+
{`| ${readtime} ${translate(
|
|
80
|
+
'min read',
|
|
81
|
+
)}`}
|
|
85
82
|
</Text>
|
|
86
83
|
</View>
|
|
87
84
|
) : null}
|
|
@@ -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);
|
package/src/components/index.js
CHANGED
|
@@ -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';
|