2022-08-12 10:58:35 -07:00
|
|
|
import React from 'react';
|
2022-05-03 14:43:04 -07:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
import { Modal, Stack, Text, Input } from 'soapbox/components/ui';
|
|
|
|
|
2022-08-12 10:58:35 -07:00
|
|
|
import type { Status } from 'soapbox/types/entities';
|
2022-05-03 14:43:04 -07:00
|
|
|
|
|
|
|
interface IEmbedModal {
|
2022-08-12 10:58:35 -07:00
|
|
|
status: Status,
|
2022-05-03 14:43:04 -07:00
|
|
|
}
|
|
|
|
|
2022-08-12 10:58:35 -07:00
|
|
|
const EmbedModal: React.FC<IEmbedModal> = ({ status }) => {
|
|
|
|
const url = `${location.origin}/embed/${status.id}`;
|
|
|
|
const embed = `<iframe src="${url}" width="100%" height="300" frameborder="0" />`;
|
2022-05-03 14:43:04 -07:00
|
|
|
|
|
|
|
const handleInputClick: React.MouseEventHandler<HTMLInputElement> = (e) => {
|
|
|
|
e.currentTarget.select();
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal title={<FormattedMessage id='status.embed' defaultMessage='Embed' />}>
|
|
|
|
<Stack space={4}>
|
|
|
|
<Stack>
|
|
|
|
<Text theme='muted' size='sm'>
|
|
|
|
<FormattedMessage id='embed.instructions' defaultMessage='Embed this post on your website by copying the code below.' />
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
<Input
|
|
|
|
type='text'
|
|
|
|
readOnly
|
2022-08-12 10:58:35 -07:00
|
|
|
value={embed}
|
2022-05-03 14:43:04 -07:00
|
|
|
onClick={handleInputClick}
|
|
|
|
/>
|
|
|
|
</Stack>
|
|
|
|
|
2022-08-12 10:58:35 -07:00
|
|
|
<div dangerouslySetInnerHTML={{ __html: embed }} />
|
2022-05-03 14:43:04 -07:00
|
|
|
</Stack>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-08-12 10:58:35 -07:00
|
|
|
export default EmbedModal;
|