pleroma/app/soapbox/features/compose/components/reply_indicator.js

71 lines
1.8 KiB
JavaScript
Raw Normal View History

import PropTypes from 'prop-types';
2020-03-27 13:59:38 -07:00
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
2022-01-10 14:01:24 -08:00
import ImmutablePureComponent from 'react-immutable-pure-component';
2022-05-17 07:03:37 -07:00
import AttachmentThumbs from 'soapbox/components/attachment-thumbs';
2022-03-21 11:09:01 -07:00
import { Stack, Text } from 'soapbox/components/ui';
import AccountContainer from 'soapbox/containers/account_container';
2020-03-27 13:59:38 -07:00
import { isRtl } from '../../../rtl';
2022-03-21 11:09:01 -07:00
export default class ReplyIndicator extends ImmutablePureComponent {
2020-03-27 13:59:38 -07:00
static propTypes = {
2022-03-23 10:14:42 -07:00
status: ImmutablePropTypes.record,
2020-03-27 13:59:38 -07:00
onCancel: PropTypes.func.isRequired,
2022-03-21 11:09:01 -07:00
hideActions: PropTypes.bool,
2020-03-27 13:59:38 -07:00
};
handleClick = () => {
this.props.onCancel();
}
render() {
2022-03-21 11:09:01 -07:00
const { status, hideActions } = this.props;
2020-03-27 13:59:38 -07:00
if (!status) {
return null;
}
2022-05-17 07:03:37 -07:00
const style = {
2020-03-27 13:59:38 -07:00
direction: isRtl(status.get('search_index')) ? 'rtl' : 'ltr',
};
2022-03-21 11:09:01 -07:00
let actions = {};
if (!hideActions) {
actions = {
onActionClick: this.handleClick,
actionIcon: require('@tabler/icons/icons/x.svg'),
actionAlignment: 'top',
actionTitle: 'Dismiss',
};
}
2020-03-27 13:59:38 -07:00
2022-03-21 11:09:01 -07:00
return (
<Stack space={2} className='p-4 rounded-lg bg-gray-100 dark:bg-slate-700'>
2022-03-21 11:09:01 -07:00
<AccountContainer
{...actions}
id={status.getIn(['account', 'id'])}
timestamp={status.get('created_at')}
showProfileHoverCard={false}
/>
2020-03-27 13:59:38 -07:00
2022-03-21 11:09:01 -07:00
<Text
size='sm'
dangerouslySetInnerHTML={{ __html: status.get('contentHtml') }}
style={style}
/>
{status.get('media_attachments').size > 0 && (
<AttachmentThumbs
media={status.get('media_attachments')}
sensitive={status.get('sensitive')}
/>
)}
2022-03-21 11:09:01 -07:00
</Stack>
2020-03-27 13:59:38 -07:00
);
}
}