-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
167 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
"use client" | ||
|
||
import { useState } from "react" | ||
import { Loader2 } from "lucide-react" | ||
|
||
import NotePreview from "~/components/NotePreview" | ||
import { useTL } from "~/features/timeline/libs" | ||
import NotePreview from "~/features/timeline/NotePreview" | ||
import { useBottom } from "~/libs/utils" | ||
|
||
// todo: TLの切り替え | ||
export default function HomePage() { | ||
const { notes, more } = useTL("homeTimeline") | ||
const [loadingMore, setLoadingMore] = useState(false) | ||
|
||
useBottom(() => { | ||
setLoadingMore(true) | ||
more().then(() => setLoadingMore(false)) | ||
}) | ||
useBottom(more) | ||
|
||
return ( | ||
<div> | ||
{notes.map((note, i) => ( | ||
<NotePreview note={note} key={i} /> | ||
))} | ||
{loadingMore && <div>loading...</div>} | ||
</div> | ||
<> | ||
<div className="rounded-xl border border-neutral-100 bg-white shadow"> | ||
<div className="flex justify-center"> | ||
<p className="border-x px-4 py-2">※これはHTLです</p> | ||
</div> | ||
<div className="flex flex-col"> | ||
{notes.map((note, i) => ( | ||
<div className="border-t" key={i}> | ||
<NotePreview note={note} /> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
<div className="mx-auto mb-8 mt-6 flex items-center gap-1 font-bold"> | ||
<Loader2 className="animate-spin" size={24} /> | ||
<p className="text-center">Loading...</p> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { entities } from "misskey-js" | ||
import Image from "next/image" | ||
|
||
export default function FilePreview({ file }: { file: entities.DriveFile }) { | ||
if (file.type.startsWith("image/")) { | ||
return <Image src={file.url} width={125} height={125} alt="File" /> | ||
} else { | ||
return ( | ||
<> | ||
{file.url}({file.type}) | ||
</> | ||
) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { MoreHorizontal, Plus, Repeat2, Reply } from "lucide-react" | ||
import { entities } from "misskey-js" | ||
import Image from "next/image" | ||
import Link from "next/link" | ||
import { memo } from "react" | ||
|
||
import FilePreview from "~/components/FilePreview" | ||
import { profileLink } from "~/features/profile/libs" | ||
import { reltime } from "~/libs/utils" | ||
|
||
type NotePreviewProps = { | ||
note: entities.Note | ||
renote?: entities.Note | ||
} | ||
|
||
const NotePreviewMemo = memo<NotePreviewProps>(function NP({ note }) { | ||
return <NotePreview note={note} /> | ||
}) | ||
|
||
export default NotePreviewMemo | ||
|
||
// Todo: まともなTLのデザイン | ||
function NotePreview({ note, renote }: NotePreviewProps) { | ||
if (note.renote && !note.text) { | ||
return <NotePreview note={note.renote} renote={note} /> | ||
} | ||
|
||
return ( | ||
<div className="p-3"> | ||
{renote && <RenoteHeader rn={renote} />} | ||
<div className="flex gap-1.5"> | ||
<Link | ||
className="m-1 h-fit w-fit overflow-hidden rounded-[48px] shadow transition-all hover:rounded-md" | ||
href={profileLink(note.user)}> | ||
<Image src={note.user.avatarUrl} width={48} height={48} alt="Icon" /> | ||
</Link> | ||
<div className="flex w-full flex-col gap-0.5"> | ||
<div className="flex justify-between"> | ||
<div className="flex gap-1 font-bold"> | ||
<Link className="hover:underline" href={profileLink(note.user)}> | ||
{note.user.name} | ||
</Link> | ||
<p> | ||
<span>@{note.user.username}</span> | ||
<span className="text-neutral-400">@{note.user.host}</span> | ||
</p> | ||
</div> | ||
<p>{reltime(note.createdAt)}</p> | ||
</div> | ||
<p>{note.text}</p> | ||
{!!note.files.length && ( | ||
// todo: grid layout | ||
<div className=""> | ||
{note.files.map((file, i) => ( | ||
<div key={i}> | ||
<FilePreview file={file} /> | ||
</div> | ||
))} | ||
</div> | ||
)} | ||
<div className="mt-1 flex gap-8"> | ||
<Reply size={20} /> | ||
<Repeat2 size={20} /> | ||
<Plus size={20} /> | ||
<MoreHorizontal size={20} /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
function RenoteHeader({ rn }: { rn: entities.Note }) { | ||
return ( | ||
<div className="mb-1 flex justify-between text-neutral-600"> | ||
<p className="ml-1 flex items-center gap-1 text-sm"> | ||
<Repeat2 size={16} /> | ||
<Link className="font-bold hover:underline" href={profileLink(rn.user)}> | ||
{rn.user.name} | ||
</Link> | ||
</p> | ||
<p>{reltime(rn.createdAt)}</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters