1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-07-22 03:05:32 +02:00
archivr/frontend/src/components/PreviewModal.jsx
TheGeneralist 900e33fa60
fix: iframe/page preview height chain and toolbar UX
Problem: changing .preview-modal from height to max-height broke iframe
previews - <iframe style='flex:1'> needs a concrete ancestor height, which
max-height alone doesn't supply when content is shorter than the cap.

Fix - CSS:
  .preview-modal--full { height: 88vh } applied to non-tweet modals
  .preview-modal--full .preview-modal-body { max-height: none }
  .preview-iframe-toolbar span: remove text-transform/letter-spacing
    (was uppercasing the URL/title in shouty caps)

Fix - PreviewModal: className adds --full when entity_kind is not
  tweet/tweet_thread; tweet previews keep shrink-to-fit behavior.

Fix - PreviewPanel: pass title + original_url from summary to IframePreview
  for both HTML and PDF; wrappers use flex:1/minHeight:0 not height:100%.

Fix - IframePreview:
  - Accept title + originalUrl props; show originalUrl in toolbar (falls
    back to artifact src only when original_url absent); show title above
    URL when available
  - flex:1 + minHeight:0 instead of height:100% on the wrap div
  - Single unified layout for page + pdf (both just show the iframe)
2026-07-12 15:18:38 +02:00

40 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useEffect } from 'react'
import PreviewPanel from './PreviewPanel'
export default function PreviewModal({ archiveId, entry, detail, onClose }) {
// Close on Escape key
useEffect(() => {
const handler = (e) => { if (e.key === 'Escape') onClose() }
window.addEventListener('keydown', handler)
return () => window.removeEventListener('keydown', handler)
}, [onClose])
return (
<div className="preview-modal-backdrop" onClick={onClose}>
<div
className={`preview-modal${
detail?.summary?.entity_kind === 'tweet' ||
detail?.summary?.entity_kind === 'tweet_thread'
? ''
: ' preview-modal--full'
}`}
onClick={e => e.stopPropagation()}
>
<div className="preview-modal-header">
<span className="preview-modal-title">{entry?.title || entry?.entry_uid || 'Preview'}</span>
<a
className="preview-modal-newtab"
href={`/preview/${archiveId}/${entry?.entry_uid}`}
target="_blank"
rel="noopener noreferrer"
title="Open in new tab"
></a>
<button className="preview-modal-close" onClick={onClose} aria-label="Close preview">×</button>
</div>
<div className="preview-modal-body">
<PreviewPanel archiveId={archiveId} entry={entry} detail={detail} />
</div>
</div>
</div>
)
}