mirror of
https://github.com/dergigi/boris.git
synced 2025-12-30 04:54:49 +01:00
- Private bookmarks are now grouped in 'Private Bookmarks' section - No need for redundant lock icon on each individual bookmark - Cleaner UI with less visual clutter - Removed faUserLock import and conditional rendering from all three views
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import React from 'react'
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core'
|
|
import { IndividualBookmark } from '../../types/bookmarks'
|
|
import { formatDateCompact } from '../../utils/bookmarkUtils'
|
|
import ContentWithResolvedProfiles from '../ContentWithResolvedProfiles'
|
|
|
|
interface CompactViewProps {
|
|
bookmark: IndividualBookmark
|
|
index: number
|
|
hasUrls: boolean
|
|
extractedUrls: string[]
|
|
onSelectUrl?: (url: string, bookmark?: { id: string; kind: number; tags: string[][]; pubkey: string }) => void
|
|
articleSummary?: string
|
|
contentTypeIcon: IconDefinition
|
|
}
|
|
|
|
export const CompactView: React.FC<CompactViewProps> = ({
|
|
bookmark,
|
|
index,
|
|
hasUrls,
|
|
extractedUrls,
|
|
onSelectUrl,
|
|
articleSummary,
|
|
contentTypeIcon
|
|
}) => {
|
|
const isArticle = bookmark.kind === 30023
|
|
const isWebBookmark = bookmark.kind === 39701
|
|
const isClickable = hasUrls || isArticle || isWebBookmark
|
|
|
|
const handleCompactClick = () => {
|
|
if (!onSelectUrl) return
|
|
|
|
if (isArticle) {
|
|
onSelectUrl('', { id: bookmark.id, kind: bookmark.kind, tags: bookmark.tags, pubkey: bookmark.pubkey })
|
|
} else if (hasUrls) {
|
|
onSelectUrl(extractedUrls[0])
|
|
}
|
|
}
|
|
|
|
// For articles, prefer summary; for others, use content
|
|
const displayText = isArticle && articleSummary
|
|
? articleSummary
|
|
: bookmark.content
|
|
|
|
return (
|
|
<div key={`${bookmark.id}-${index}`} className={`individual-bookmark compact ${bookmark.isPrivate ? 'private-bookmark' : ''}`}>
|
|
<div
|
|
className={`compact-row ${isClickable ? 'clickable' : ''}`}
|
|
onClick={handleCompactClick}
|
|
role={isClickable ? 'button' : undefined}
|
|
tabIndex={isClickable ? 0 : undefined}
|
|
>
|
|
<span className="bookmark-type-compact">
|
|
<FontAwesomeIcon icon={contentTypeIcon} className="content-type-icon" />
|
|
</span>
|
|
{displayText && (
|
|
<div className="compact-text">
|
|
<ContentWithResolvedProfiles content={displayText.slice(0, 60) + (displayText.length > 60 ? '…' : '')} />
|
|
</div>
|
|
)}
|
|
<span className="bookmark-date-compact">{formatDateCompact(bookmark.created_at)}</span>
|
|
{/* CTA removed */}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|