2024-01-06 11:46:45 +03:00
|
|
|
import './embed-modal.css';
|
|
|
|
|
2024-08-13 10:26:23 +03:00
|
|
|
import { t, Trans } from '@lingui/macro';
|
|
|
|
|
2024-01-06 11:46:45 +03:00
|
|
|
import Icon from './icon';
|
|
|
|
|
2024-01-19 15:31:05 +03:00
|
|
|
function EmbedModal({ html, url, width, height, onClose = () => {} }) {
|
2024-01-06 11:46:45 +03:00
|
|
|
return (
|
|
|
|
<div class="embed-modal-container">
|
|
|
|
<div class="top-controls">
|
|
|
|
<button type="button" class="light" onClick={() => onClose()}>
|
2024-08-13 10:26:23 +03:00
|
|
|
<Icon icon="x" alt={t`Close`} />
|
2024-01-06 11:46:45 +03:00
|
|
|
</button>
|
|
|
|
{url && (
|
|
|
|
<a
|
|
|
|
href={url}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
class="button plain"
|
|
|
|
>
|
2024-08-13 10:26:23 +03:00
|
|
|
<span>
|
|
|
|
<Trans>Open in new window</Trans>
|
|
|
|
</span>{' '}
|
|
|
|
<Icon icon="external" />
|
2024-01-06 11:46:45 +03:00
|
|
|
</a>
|
|
|
|
)}
|
|
|
|
</div>
|
2024-01-19 15:31:05 +03:00
|
|
|
<div
|
|
|
|
class="embed-content"
|
|
|
|
dangerouslySetInnerHTML={{ __html: html }}
|
|
|
|
style={{
|
|
|
|
'--width': width + 'px',
|
|
|
|
'--height': height + 'px',
|
|
|
|
'--aspect-ratio': `${width}/${height}`,
|
|
|
|
}}
|
|
|
|
/>
|
2024-01-06 11:46:45 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default EmbedModal;
|