1
0
Fork 0
mirror of https://github.com/cheeaun/phanpy.git synced 2025-04-02 03:51:38 +02:00
phanpy/src/components/embed-modal.jsx

38 lines
991 B
React
Raw Normal View History

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