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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | 2x 2x 2x 2x 2x 2x 11x 11x 2x 2x | import React from 'react'; import PropTypes from 'prop-types'; import { Card, Image, Link, LinkifiedText, Text, } from '@bufferapp/components'; import Post from '../Shared/Post'; const postContentStyle = { display: 'flex', flexDirection: 'column', }; const postContentTextStyle = { paddingBottom: '1rem', }; const linkAttachmentContentStyle = { display: 'flex', flexDirection: 'row', }; const linkAttachmentTextStyle = { display: 'flex', flexDirection: 'column', padding: '1rem', flexGrow: 1, minWidth: 0, }; const linkUrlStyle = { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', color: 'rgba(50, 59, 67, 0.3)', margin: '0.25rem 1rem 1rem 0', }; const LinkPost = ({ hasPermission, isConfirmingDelete, isDeleting, isMoving, isPastDue, isWorking, links, linkAttachment, manager, onApproveClick, onCancelConfirmClick, onDeleteClick, onDeleteConfirmClick, onEditClick, onMoveToDraftsClick, onRequestApprovalClick, onRescheduleClick, draftDetails, scheduledAt, text, view, }) => { const children = ( <div style={postContentStyle}> <div style={postContentTextStyle}> <LinkifiedText links={links} size={'mini'} newTab unstyled > {text} </LinkifiedText> </div> <div> <Link href={linkAttachment.url} unstyled newTab> <Card noPadding > <div style={linkAttachmentContentStyle}> <Image src={linkAttachment.thumbnailUrl} width={'15rem'} minWidth={'15rem'} maxWidth={'15rem'} height={'10rem'} border={'rounded'} objectFit={'cover'} /> <div style={linkAttachmentTextStyle}> <div> <Text> {linkAttachment.title} </Text> </div> <div style={linkUrlStyle}> <Text size={'small'} color={'outerSpaceLight'}> {linkAttachment.url} </Text> </div> <div> <Text size={'small'}> {linkAttachment.description} </Text> </div> </div> </div> </Card> </Link> </div> </div> ); return ( <Post hasPermission={hasPermission} isConfirmingDelete={isConfirmingDelete} isDeleting={isDeleting} isMoving={isMoving} isPastDue={isPastDue} isWorking={isWorking} links={links} linkAttachment={linkAttachment} manager={manager} onApproveClick={onApproveClick} onCancelConfirmClick={onCancelConfirmClick} onDeleteClick={onDeleteClick} onDeleteConfirmClick={onDeleteConfirmClick} onEditClick={onEditClick} onMoveToDraftsClick={onMoveToDraftsClick} onRequestApprovalClick={onRequestApprovalClick} onRescheduleClick={onRescheduleClick} draftDetails={draftDetails} scheduledAt={scheduledAt} text={text} view={view} > {children} </Post> ); }; LinkPost.propTypes = { ...Post.commonPropTypes, links: PropTypes.arrayOf( PropTypes.shape({ rawString: PropTypes.string, displayString: PropTypes.string, expandedUrl: PropTypes.string, indices: PropTypes.arrayOf(PropTypes.number), }), ).isRequired, linkAttachment: PropTypes.shape({ title: PropTypes.string, description: PropTypes.string, url: PropTypes.string, thumbnailUrl: PropTypes.string, }).isRequired, text: PropTypes.string.isRequired, }; LinkPost.defaultProps = Post.defaultProps; export default LinkPost; |