VideoModal: convert to TSX
This commit is contained in:
parent
e648162f66
commit
b8eff3e46b
2 changed files with 51 additions and 0 deletions
Binary file not shown.
51
app/soapbox/features/ui/components/video_modal.tsx
Normal file
51
app/soapbox/features/ui/components/video_modal.tsx
Normal file
|
@ -0,0 +1,51 @@
|
|||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import Video from 'soapbox/features/video';
|
||||
|
||||
import type { Status, Account, Attachment } from 'soapbox/types/entities';
|
||||
|
||||
interface IVideoModal {
|
||||
media: Attachment,
|
||||
status: Status,
|
||||
account: Account,
|
||||
time: number,
|
||||
onClose: () => void,
|
||||
}
|
||||
|
||||
const VideoModal: React.FC<IVideoModal> = ({ status, account, media, time, onClose }) => {
|
||||
const history = useHistory();
|
||||
|
||||
const handleStatusClick: React.MouseEventHandler = e => {
|
||||
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault();
|
||||
history.push(`/@${account.acct}/posts/${status.id}`);
|
||||
}
|
||||
};
|
||||
|
||||
const link = status && account && (
|
||||
<a href={status.url} onClick={handleStatusClick}>
|
||||
<FormattedMessage id='lightbox.view_context' defaultMessage='View context' />
|
||||
</a>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='modal-root__modal video-modal'>
|
||||
<div>
|
||||
<Video
|
||||
preview={media.preview_url}
|
||||
blurhash={media.blurhash}
|
||||
src={media.url}
|
||||
startTime={time}
|
||||
onCloseVideo={onClose}
|
||||
link={link}
|
||||
detailed
|
||||
alt={media.description}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoModal;
|
Loading…
Reference in a new issue