mirror of
https://github.com/dergigi/boris.git
synced 2026-01-26 18:24:22 +01:00
- Create AuthorCard component showing profile picture and bio - Display author card after mark as read button - Only shown for nostr-native articles (not external URLs) - Fetch author profile data using applesauce ProfileModel - Card displays author name, avatar, and bio (truncated to 3 lines) - Responsive design with smaller avatar on mobile - Elegant card styling matching app design system Author information helps readers learn more about article authors directly within the reading experience.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import React from 'react'
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
import { faUserCircle } from '@fortawesome/free-solid-svg-icons'
|
|
import { useEventModel } from 'applesauce-react/hooks'
|
|
import { Models } from 'applesauce-core'
|
|
|
|
interface AuthorCardProps {
|
|
authorPubkey: string
|
|
}
|
|
|
|
const AuthorCard: React.FC<AuthorCardProps> = ({ authorPubkey }) => {
|
|
const profile = useEventModel(Models.ProfileModel, [authorPubkey])
|
|
|
|
const getAuthorName = () => {
|
|
if (profile?.name) return profile.name
|
|
if (profile?.display_name) return profile.display_name
|
|
return `${authorPubkey.slice(0, 8)}...${authorPubkey.slice(-8)}`
|
|
}
|
|
|
|
const authorImage = profile?.picture || profile?.image
|
|
const authorBio = profile?.about
|
|
|
|
return (
|
|
<div className="author-card">
|
|
<div className="author-card-avatar">
|
|
{authorImage ? (
|
|
<img src={authorImage} alt={getAuthorName()} />
|
|
) : (
|
|
<FontAwesomeIcon icon={faUserCircle} />
|
|
)}
|
|
</div>
|
|
<div className="author-card-content">
|
|
<div className="author-card-name">{getAuthorName()}</div>
|
|
{authorBio && (
|
|
<p className="author-card-bio">{authorBio}</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default AuthorCard
|
|
|