phanpy/src/components/embed-modal.jsx

38 wiersze
991 B
React

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