mirror of
https://github.com/dergigi/boris.git
synced 2026-02-18 13:34:38 +01:00
- Add image prop to ContentPanel to display hero images - Extract image tag from kind:30023 bookmark tags - Display article images in Card, Large, and Compact views - Show hero image at top of article reader view - Add CSS styling for article-hero-image and reader-hero-image - Article images clickable to open article in reader - Per NIP-23: image tag contains header/preview image URL
103 lines
3.2 KiB
TypeScript
103 lines
3.2 KiB
TypeScript
import React from 'react'
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
import { IndividualBookmark } from '../../types/bookmarks'
|
|
import { formatDate } from '../../utils/bookmarkUtils'
|
|
import ContentWithResolvedProfiles from '../ContentWithResolvedProfiles'
|
|
import { IconGetter } from './shared'
|
|
|
|
interface LargeViewProps {
|
|
bookmark: IndividualBookmark
|
|
index: number
|
|
hasUrls: boolean
|
|
extractedUrls: string[]
|
|
onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void
|
|
getIconForUrlType: IconGetter
|
|
firstUrlClassification: { buttonText: string } | null
|
|
previewImage: string | null
|
|
authorNpub: string
|
|
eventNevent?: string
|
|
getAuthorDisplayName: () => string
|
|
handleReadNow: (e: React.MouseEvent<HTMLButtonElement>) => void
|
|
}
|
|
|
|
export const LargeView: React.FC<LargeViewProps> = ({
|
|
bookmark,
|
|
index,
|
|
hasUrls,
|
|
extractedUrls,
|
|
onSelectUrl,
|
|
getIconForUrlType,
|
|
firstUrlClassification,
|
|
previewImage,
|
|
authorNpub,
|
|
eventNevent,
|
|
getAuthorDisplayName,
|
|
handleReadNow
|
|
}) => {
|
|
const isArticle = bookmark.kind === 30023
|
|
|
|
return (
|
|
<div key={`${bookmark.id}-${index}`} className={`individual-bookmark large ${bookmark.isPrivate ? 'private-bookmark' : ''}`}>
|
|
{(hasUrls || (isArticle && previewImage)) && (
|
|
<div
|
|
className="large-preview-image"
|
|
onClick={() => {
|
|
if (isArticle) {
|
|
handleReadNow({ preventDefault: () => {} } as React.MouseEvent<HTMLButtonElement>)
|
|
} else {
|
|
onSelectUrl?.(extractedUrls[0])
|
|
}
|
|
}}
|
|
style={previewImage ? { backgroundImage: `url(${previewImage})` } : undefined}
|
|
>
|
|
{!previewImage && hasUrls && (
|
|
<div className="preview-placeholder">
|
|
<FontAwesomeIcon icon={getIconForUrlType(extractedUrls[0])} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
)}
|
|
|
|
<div className="large-content">
|
|
{bookmark.content && (
|
|
<div className="large-text">
|
|
<ContentWithResolvedProfiles content={bookmark.content} />
|
|
</div>
|
|
)}
|
|
|
|
<div className="large-footer">
|
|
<span className="large-author">
|
|
<a
|
|
href={`https://search.dergigi.com/p/${authorNpub}`}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="author-link-minimal"
|
|
>
|
|
{getAuthorDisplayName()}
|
|
</a>
|
|
</span>
|
|
|
|
{eventNevent && (
|
|
<a
|
|
href={`https://search.dergigi.com/e/${eventNevent}`}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="bookmark-date-link"
|
|
>
|
|
{formatDate(bookmark.created_at)}
|
|
</a>
|
|
)}
|
|
|
|
{(hasUrls && firstUrlClassification) || isArticle ? (
|
|
<button className="large-read-button" onClick={handleReadNow}>
|
|
<FontAwesomeIcon icon={isArticle ? getIconForUrlType('') : getIconForUrlType(extractedUrls[0])} />
|
|
{isArticle ? 'Read Article' : firstUrlClassification?.buttonText}
|
|
</button>
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|