-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScriptureFeature.js
87 lines (81 loc) · 2.06 KB
/
ScriptureFeature.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React from 'react';
import PropTypes from 'prop-types';
import { ActionCard, PaddedView, named } from '@apollosproject/ui-kit';
import { ScriptureItem } from '@apollosproject/ui-scripture';
import ShareButtonConnected from '../ShareButtonConnected';
const ScriptureFeature = ({
contentId,
featureId,
isCard,
isLoading,
nodeId,
scriptures,
sharing: { message } = {},
showShareButton,
title,
}) => {
const Wrapper = (
{ children } // eslint-disable-line react/prop-types
) =>
// eslint-disable-next-line no-nested-ternary
isCard ? (
showShareButton ? (
<ActionCard
label={title}
icon={'text'}
action={
<ShareButtonConnected
message={message}
itemId={nodeId || contentId || featureId}
/>
}
>
{children}
</ActionCard>
) : (
<ActionCard label={title} icon={'text'}>
{children}
</ActionCard>
)
) : (
<PaddedView>{children}</PaddedView>
);
return (
<Wrapper>
{scriptures.map(({ copyright, reference, html, id, version }) => (
<ScriptureItem
key={id}
reference={reference}
html={html}
isLoading={isLoading}
copyright={copyright}
version={version}
/>
))}
</Wrapper>
);
};
ScriptureFeature.defaultProps = {
isCard: true,
showShareButton: true,
};
ScriptureFeature.propTypes = {
isCard: PropTypes.bool,
isLoading: PropTypes.bool,
scriptures: PropTypes.arrayOf(
PropTypes.shape({
html: PropTypes.string.isRequired,
reference: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
copyright: PropTypes.string,
version: PropTypes.string,
})
),
sharing: PropTypes.shape({ message: PropTypes.string }),
contentId: PropTypes.string,
title: PropTypes.string,
nodeId: PropTypes.string,
featureId: PropTypes.string,
showShareButton: PropTypes.bool,
};
export default named('ui-connected.ScriptureFeature')(ScriptureFeature);