ligun and sogup
This commit is contained in:
parent
b6633d6f25
commit
4573048a47
24 changed files with 482 additions and 226 deletions
|
@ -1,60 +0,0 @@
|
|||
import { Post } from '../model/posts/posts.ts'
|
||||
import { Link } from 'react-router'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
interface PostItemProps {
|
||||
post: Post
|
||||
index: number
|
||||
}
|
||||
|
||||
export default function PostItem({ post, index }: PostItemProps) {
|
||||
const formattedDate = post.createdAt.toLocaleString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
})
|
||||
|
||||
const [visible, setVisible] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = setTimeout(() => setVisible(true))
|
||||
return () => clearTimeout(timeout)
|
||||
}, [])
|
||||
|
||||
const opacity = visible ? 'opacity-100' : 'opacity-0'
|
||||
|
||||
const delayMs = index * 100
|
||||
|
||||
return (
|
||||
<article
|
||||
className={`w-full p-4 ${opacity} transition-opacity duration-500`}
|
||||
style={{ transitionDelay: `${delayMs}ms` }}
|
||||
key={post.postId}
|
||||
>
|
||||
<div className="text-sm text-gray-500 mb-3">
|
||||
<Link to={`/u/${post.authorName}`} className="text-gray-400 hover:underline mr-2">
|
||||
@{post.authorName}
|
||||
</Link>
|
||||
• {formattedDate}
|
||||
</div>
|
||||
|
||||
<div className="text-gray-800 mb-4 whitespace-pre-wrap">{post.content}</div>
|
||||
|
||||
{post.media.length > 0 && (
|
||||
<div className="grid gap-4 grid-cols-1">
|
||||
{post.media.map((src) => (
|
||||
<img
|
||||
key={src.toString()}
|
||||
src={src.toString()}
|
||||
alt="todo sry :("
|
||||
className="w-full h-auto"
|
||||
loading="lazy"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue