bigbuffet-rw/app/soapbox/features/compose/components/reply-indicator.tsx

66 lines
1.6 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
2022-05-30 12:05:15 -07:00
import React from 'react';
import AttachmentThumbs from 'soapbox/components/attachment-thumbs';
import { Stack, Text } from 'soapbox/components/ui';
2022-11-15 08:13:54 -08:00
import AccountContainer from 'soapbox/containers/account-container';
import { isRtl } from 'soapbox/rtl';
2022-05-30 12:05:15 -07:00
import type { Status } from 'soapbox/types/entities';
interface IReplyIndicator {
className?: string
status?: Status
onCancel?: () => void
hideActions: boolean
2022-05-30 12:05:15 -07:00
}
const ReplyIndicator: React.FC<IReplyIndicator> = ({ className, status, hideActions, onCancel }) => {
2022-05-30 12:05:15 -07:00
const handleClick = () => {
onCancel!();
2022-05-30 12:05:15 -07:00
};
if (!status) {
return null;
}
let actions = {};
if (!hideActions && onCancel) {
2022-05-30 12:05:15 -07:00
actions = {
onActionClick: handleClick,
actionIcon: require('@tabler/icons/x.svg'),
2022-05-30 12:05:15 -07:00
actionAlignment: 'top',
actionTitle: 'Dismiss',
};
}
return (
<Stack space={2} className={clsx('rounded-lg bg-gray-100 p-4 dark:bg-gray-800', className)}>
2022-05-30 12:05:15 -07:00
<AccountContainer
{...actions}
id={status.getIn(['account', 'id']) as string}
timestamp={status.created_at}
showProfileHoverCard={false}
2022-07-01 13:07:01 -07:00
withLinkToProfile={false}
hideActions={hideActions}
2022-05-30 12:05:15 -07:00
/>
<Text
2023-02-01 14:13:42 -08:00
className='status__content break-words'
2022-05-30 12:05:15 -07:00
size='sm'
dangerouslySetInnerHTML={{ __html: status.contentHtml }}
direction={isRtl(status.search_index) ? 'rtl' : 'ltr'}
/>
{status.media_attachments.size > 0 && (
<AttachmentThumbs
media={status.media_attachments}
sensitive={status.sensitive}
/>
)}
</Stack>
);
};
export default ReplyIndicator;