EmbedModal: fix styles

This commit is contained in:
Alex Gleason 2022-05-03 16:23:26 -05:00
parent 0d0d12489e
commit 851c28a3a8
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 32 additions and 29 deletions

View File

@ -381,11 +381,14 @@ class StatusActionBar extends ImmutablePureComponent<IStatusActionBar, IStatusAc
action: this.handleCopy, action: this.handleCopy,
icon: require('@tabler/icons/icons/link.svg'), icon: require('@tabler/icons/icons/link.svg'),
}); });
// menu.push({
// text: intl.formatMessage(messages.embed), if (features.embeds) {
// action: this.handleEmbed, menu.push({
// icon: require('feather-icons/dist/icons/link-2.svg'), text: intl.formatMessage(messages.embed),
// }); action: this.handleEmbed,
icon: require('@tabler/icons/icons/share.svg'),
});
}
} }
if (!me) { if (!me) {

View File

@ -374,7 +374,7 @@ class ActionBar extends React.PureComponent<IActionBar, IActionBarState> {
menu.push({ menu.push({
text: intl.formatMessage(messages.embed), text: intl.formatMessage(messages.embed),
action: this.handleEmbed, action: this.handleEmbed,
icon: require('feather-icons/dist/icons/link-2.svg'), icon: require('@tabler/icons/icons/share.svg'),
}); });
} }
} }

View File

@ -5,6 +5,7 @@ import { FormattedMessage, injectIntl } from 'react-intl';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import api from 'soapbox/api'; import api from 'soapbox/api';
import { Modal, Stack, Text, Input } from 'soapbox/components/ui';
export default @connect() export default @connect()
@injectIntl @injectIntl
@ -42,9 +43,13 @@ class EmbedModal extends ImmutablePureComponent {
iframeDocument.write(res.data.html); iframeDocument.write(res.data.html);
iframeDocument.close(); iframeDocument.close();
const innerFrame = iframeDocument.querySelector('iframe');
iframeDocument.body.style.margin = 0; iframeDocument.body.style.margin = 0;
this.iframe.width = iframeDocument.body.scrollWidth;
this.iframe.height = iframeDocument.body.scrollHeight; if (innerFrame) {
innerFrame.width = '100%';
}
}).catch(error => { }).catch(error => {
this.props.onError(error); this.props.onError(error);
}); });
@ -62,35 +67,30 @@ class EmbedModal extends ImmutablePureComponent {
const { oembed } = this.state; const { oembed } = this.state;
return ( return (
<div className='modal-root__modal embed-modal'> <Modal title={<FormattedMessage id='status.embed' defaultMessage='Embed' />}>
<h4><FormattedMessage id='status.embed' defaultMessage='Embed' /></h4> <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>
<div className='embed-modal__container'> <Input
<p className='hint'> type='text'
<FormattedMessage id='embed.instructions' defaultMessage='Embed this post on your website by copying the code below.' /> readOnly
</p> value={oembed?.html || ''}
onClick={this.handleTextareaClick}
<input />
type='text' </Stack>
className='embed-modal__html'
readOnly
value={oembed && oembed.html || ''}
onClick={this.handleTextareaClick}
/>
<p className='hint'>
<FormattedMessage id='embed.preview' defaultMessage='Here is what it will look like:' />
</p>
<iframe <iframe
className='embed-modal__iframe' className='inline-flex rounded-xl overflow-hidden max-w-full'
frameBorder='0' frameBorder='0'
ref={this.setIframeRef} ref={this.setIframeRef}
sandbox='allow-same-origin' sandbox='allow-same-origin'
title='preview' title='preview'
/> />
</div> </Stack>
</div> </Modal>
); );
} }