EmbedModal: improve styling

This commit is contained in:
Alex Gleason 2022-08-22 12:08:30 -05:00
parent 2780027363
commit 393f6a9b60
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 29 additions and 19 deletions

View File

@ -1,8 +1,10 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { closeModal } from 'soapbox/actions/modals';
import SafeEmbed from 'soapbox/components/safe-embed'; import SafeEmbed from 'soapbox/components/safe-embed';
import { Modal, Stack, Text, Input } from 'soapbox/components/ui'; import { Modal, Stack, Text, Input } from 'soapbox/components/ui';
import { useAppDispatch } from 'soapbox/hooks';
import useEmbed from 'soapbox/queries/embed'; import useEmbed from 'soapbox/queries/embed';
interface IEmbedModal { interface IEmbedModal {
@ -11,6 +13,7 @@ interface IEmbedModal {
} }
const EmbedModal: React.FC<IEmbedModal> = ({ url, onError }) => { const EmbedModal: React.FC<IEmbedModal> = ({ url, onError }) => {
const dispatch = useAppDispatch();
const { data: embed, error, isError } = useEmbed(url); const { data: embed, error, isError } = useEmbed(url);
useEffect(() => { useEffect(() => {
@ -23,11 +26,17 @@ const EmbedModal: React.FC<IEmbedModal> = ({ url, onError }) => {
e.currentTarget.select(); e.currentTarget.select();
}; };
const handleClose = () => {
dispatch(closeModal('EMBED'));
};
return ( return (
<Modal title={<FormattedMessage id='status.embed' defaultMessage='Embed' />}> <Modal
title={<FormattedMessage id='status.embed' defaultMessage='Embed post' />}
onClose={handleClose}
>
<Stack space={4}> <Stack space={4}>
<Stack> <Text theme='muted'>
<Text theme='muted' size='sm'>
<FormattedMessage id='embed.instructions' defaultMessage='Embed this post on your website by copying the code below.' /> <FormattedMessage id='embed.instructions' defaultMessage='Embed this post on your website by copying the code below.' />
</Text> </Text>
@ -39,13 +48,14 @@ const EmbedModal: React.FC<IEmbedModal> = ({ url, onError }) => {
/> />
</Stack> </Stack>
<hr className='my-9' />
<SafeEmbed <SafeEmbed
className='inline-flex rounded-xl overflow-hidden max-w-full' className='rounded-xl overflow-hidden w-full'
sandbox='allow-same-origin allow-scripts' sandbox='allow-same-origin allow-scripts'
title='embedded-status' title='embedded-status'
html={embed?.html} html={embed?.html}
/> />
</Stack>
</Modal> </Modal>
); );
}; };

View File

@ -986,7 +986,7 @@
"status.delete": "Delete", "status.delete": "Delete",
"status.detailed_status": "Detailed conversation view", "status.detailed_status": "Detailed conversation view",
"status.direct": "Direct message @{name}", "status.direct": "Direct message @{name}",
"status.embed": "Embed", "status.embed": "Embed post",
"status.favourite": "Like", "status.favourite": "Like",
"status.filtered": "Filtered", "status.filtered": "Filtered",
"status.load_more": "Load more", "status.load_more": "Load more",