Skip to content

Commit a0996bb

Browse files
authored
Merge pull request #137 from CodeForStartup/feat/add-loading-skeleton-comp
feat: add loading infinity skeleton component
2 parents 92e7fe5 + f21c258 commit a0996bb

File tree

24 files changed

+216
-161
lines changed

24 files changed

+216
-161
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<p align="center">
22
<a href="https://codeforstartup.com/">
33
<img src="./images/home-screen.png">
4-
<h1 align="center" style="color: red">TOPLIST</h1>
4+
<h1 align="center" style="color: red">NEXT FORUM</h1>
55
</a>
66
</p>
77

8-
# About TOPLIST
8+
# About next-forum
99

1010
# Installation
1111

apps/admin/@/molecules/nav/logo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Logo: React.FC = () => {
1616
bebasNeue.className
1717
)}
1818
>
19-
TOPLIST
19+
NEXT-FORUM
2020
</h1>
2121
</Link>
2222
)

apps/web/@/hooks/useInfinityScroll.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { useCallback, useEffect, useRef, useState } from "react"
22

3-
const useInfiniteScroll = (callback: () => void, root: HTMLElement | null, isFetching: boolean) => {
4-
// const [isFetching, setIsFetching] = useState(false)
3+
const useInfiniteScroll = (callback: Function, root: HTMLElement | null, isFetching: boolean) => {
54
const observer = useRef<IntersectionObserver | null>(null)
65
const [node, setNode] = useState<HTMLElement | null>(null)
76

87
const handleIntersection = useCallback(
98
(entries: IntersectionObserverEntry[]) => {
10-
console.log("entries", entries)
119
if (entries[0].isIntersecting && !isFetching) {
1210
callback?.()
1311
}
@@ -22,7 +20,6 @@ const useInfiniteScroll = (callback: () => void, root: HTMLElement | null, isFet
2220
observer.current.disconnect()
2321
}
2422

25-
console.log("observer.current", observer.current)
2623
observer.current = new IntersectionObserver(handleIntersection, {
2724
root,
2825
rootMargin: "100px",

apps/web/@/messages/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@
119119
"order_by_name": "Name",
120120
"order_by_size": "Size",
121121
"order_by_type": "Type",
122-
"order_by_uploaded_at": "Uploaded at"
122+
"order_by_uploaded_at": "Uploaded at",
123+
"search_results_for": "Search results for"
123124
},
124125
"uploads": {
125126
"asset_management": "Asset Management",

apps/web/@/molecules/follower/user-profile/index.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ export type UserProfileProps = {
1414
}
1515

1616
export async function UserProfile({ authorId }: UserProfileProps) {
17-
const rawAuthor = await fetch(
18-
`${process.env.NEXT_PUBLIC_FRONTEND_URL}${generatePath(APP_APIS.protected.user.GET, {
19-
userId: authorId,
20-
})}`,
21-
{
22-
method: "GET",
23-
cache: "no-cache",
24-
headers: {
25-
"Content-Type": "application/json",
26-
},
27-
}
28-
)
17+
// const rawAuthor = await fetch(
18+
// `${process.env.NEXT_PUBLIC_FRONTEND_URL}${generatePath(APP_APIS.protected.user.GET, {
19+
// userId: authorId,
20+
// })}`,
21+
// {
22+
// method: "GET",
23+
// cache: "no-cache",
24+
// headers: {
25+
// "Content-Type": "application/json",
26+
// },
27+
// }
28+
// )
2929
const author: TUserItem = await rawAuthor?.json()
3030
const t = await getTranslations()
3131

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"use client"
2+
3+
import { Loader } from "lucide-react"
4+
5+
import useInfiniteScroll from "@/hooks/useInfinityScroll"
6+
7+
interface InfiniteScrollProps {
8+
containerClassName?: string
9+
children: React.ReactNode
10+
hasMore?: boolean
11+
root?: HTMLElement | null
12+
loading: boolean
13+
nextPage: (params: Record<string, any>) => Promise<any>
14+
}
15+
16+
export default function InfiniteScroll({
17+
containerClassName,
18+
children,
19+
hasMore,
20+
root,
21+
nextPage,
22+
loading,
23+
}: InfiniteScrollProps) {
24+
const { setNode } = useInfiniteScroll(nextPage, root, loading)
25+
26+
return (
27+
<div className={containerClassName}>
28+
{children}
29+
30+
<div
31+
ref={setNode}
32+
className="flex h-10 w-full items-center justify-center"
33+
>
34+
{loading && <Loader className="animate-spin" />}
35+
</div>
36+
</div>
37+
)
38+
}

apps/web/@/molecules/nav/logo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Logo: React.FC = () => {
1616
bebasNeue.className
1717
)}
1818
>
19-
TOPLIST
19+
NEXT-FORUM
2020
</h1>
2121
</Link>
2222
)

apps/web/@/molecules/post-list/index.tsx

Lines changed: 0 additions & 50 deletions
This file was deleted.

apps/web/@/molecules/posts/post-detail/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Link from "next/link"
22

3+
import { TPostItem } from "database"
34
import { Typography } from "ui"
45

56
import APP_ROUTES from "@/constants/routes"
67
import TagList from "@/molecules/tag/tag-list"
78
import PostMeta from "@/molecules/user/posts/post-meta"
8-
import { TPostItem } from "@/types/posts"
99
import { generatePath } from "@/utils/generatePath"
1010

1111
import EditPostButton from "./edit-post-button"

apps/web/@/molecules/posts/post-detail/like-button/LikeButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"use client"
22

3-
import { PostOnUserType } from "database"
3+
import { PostOnUserType, TPostItem } from "database"
44
import { useTranslations } from "next-intl"
55
import { Button, cn, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "ui"
66

77
import { addRelation, removeRelation } from "@/actions/protect/postAction"
8-
import { TPostItem } from "@/types/posts"
98

109
type LikeButtonProps = {
1110
post: TPostItem

0 commit comments

Comments
 (0)