| 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 |
2x
2x
2x
2x
2x
25x
13x
2x
25x
25x
2x
2x
| import React from 'react';
import PropTypes from 'prop-types';
import {
IdTag,
Image,
LinkifiedText,
} from '@bufferapp/components';
import Post from '../Shared/Post';
const postContentStyle = {
display: 'flex',
};
const postContentTextStyle = {
paddingRight: '1rem',
flexGrow: 1,
};
const imageWrapperStyle = {
position: 'relative',
};
const imageTagStyle = {
position: 'absolute',
bottom: '0.7rem',
left: '0.7rem',
};
const renderTag = (tag) => {
if (!tag) return;
return (
<span style={imageTagStyle}>
<IdTag>{tag}</IdTag>
</span>
);
};
const ImagePost = ({
hasPermission,
isConfirmingDelete,
isDeleting,
isMoving,
isPastDue,
isWorking,
imageSrc,
links,
manager,
onApproveClick,
onCancelConfirmClick,
onDeleteClick,
onDeleteConfirmClick,
onEditClick,
onMoveToDraftsClick,
onRequestApprovalClick,
onRescheduleClick,
draftDetails,
text,
tag,
retweetProfile,
scheduledAt,
view,
}) => {
const children = (
<div style={postContentStyle}>
<span style={postContentTextStyle}>
<LinkifiedText
links={links}
size={'mini'}
newTab
unstyled
>
{text}
</LinkifiedText>
</span>
<div style={imageWrapperStyle}>
<Image
src={imageSrc}
width={'15rem'}
maxHeight={'20rem'}
minHeight={'10rem'}
border={'rounded'}
objectFit={'cover'}
/>
{ renderTag(tag) }
</div>
</div>
);
return (
<Post
hasPermission={hasPermission}
isConfirmingDelete={isConfirmingDelete}
isDeleting={isDeleting}
isMoving={isMoving}
isPastDue={isPastDue}
isWorking={isWorking}
imageSrc={imageSrc}
links={links}
manager={manager}
onApproveClick={onApproveClick}
onCancelConfirmClick={onCancelConfirmClick}
onDeleteClick={onDeleteClick}
onDeleteConfirmClick={onDeleteConfirmClick}
onEditClick={onEditClick}
onMoveToDraftsClick={onMoveToDraftsClick}
onRequestApprovalClick={onRequestApprovalClick}
onRescheduleClick={onRescheduleClick}
draftDetails={draftDetails}
text={text}
retweetProfile={retweetProfile}
scheduledAt={scheduledAt}
view={view}
>
{children}
</Post>
);
};
ImagePost.propTypes = {
...Post.commonPropTypes,
imageSrc: PropTypes.string.isRequired,
links: PropTypes.arrayOf(
PropTypes.shape({
rawString: PropTypes.string,
displayString: PropTypes.string,
expandedUrl: PropTypes.string,
indices: PropTypes.arrayOf(PropTypes.number),
}),
).isRequired,
text: PropTypes.string.isRequired,
tag: PropTypes.string,
};
ImagePost.defaultProps = Post.defaultProps;
export default ImagePost;
|