diff --git a/src/components/common/CharacterCard.tsx b/src/components/common/CharacterCard.tsx
index db108847..4d0be64b 100644
--- a/src/components/common/CharacterCard.tsx
+++ b/src/components/common/CharacterCard.tsx
@@ -2,6 +2,7 @@ import { FollowingButton } from "~/components/common/FollowingButton"
import { FollowingCount } from "~/components/common/FollowingCount"
import { Titles } from "~/components/common/Titles"
import { Avatar } from "~/components/ui/Avatar"
+import { Skeleton } from "~/components/ui/Skeleton"
import { useDate } from "~/hooks/useDate"
import { useTranslation } from "~/lib/i18n/client"
import { cn } from "~/lib/utils"
@@ -97,7 +98,15 @@ export const CharacterCard: React.FC<{
)}
>
) : (
- <>{t("Loading")}...>
+
+
+
+
+
+
+
+
+
)}
)
diff --git a/src/components/home/HomeFeed.tsx b/src/components/home/HomeFeed.tsx
index eb874d7b..d1bb79eb 100644
--- a/src/components/home/HomeFeed.tsx
+++ b/src/components/home/HomeFeed.tsx
@@ -24,6 +24,7 @@ import type { FeedType, SearchType } from "~/models/home.model"
import { useGetFeed } from "~/queries/home"
import { EmptyState } from "../ui/EmptyState"
+import { Skeleton } from "../ui/Skeleton"
const PostCard = ({
post,
@@ -337,7 +338,7 @@ export const HomeFeed: React.FC<{
)}
{feed.isLoading ? (
-
{t("Loading")}...
+
) : !feed.data?.pages[0]?.count ? (
) : (
@@ -390,3 +391,19 @@ const Loader = () => {
)
}
+
+const FeedSkeleton = () => {
+ return (
+
+
+
+ )
+}
diff --git a/src/components/ui/Skeleton.tsx b/src/components/ui/Skeleton.tsx
new file mode 100644
index 00000000..acb79ba7
--- /dev/null
+++ b/src/components/ui/Skeleton.tsx
@@ -0,0 +1,87 @@
+"use client"
+
+import React, { PropsWithChildren, useMemo } from "react"
+
+import { useTranslation } from "~/lib/i18n/client"
+import { cn } from "~/lib/utils"
+
+interface Props {
+ className?: string
+ width?: number | string
+ height?: number | string
+}
+
+const skeletonColor = "bg-gray-200 dark:bg-gray-700"
+
+function unit(unit: string | number | undefined) {
+ if (!unit) return
+ return typeof unit === "number" ? `${unit}px` : unit
+}
+
+export function Skeleton({ className, width, height }: Props) {
+ const sizeObj = useMemo(() => {
+ const _size: any = {}
+ let _className = []
+ width ? (_size.width = unit(width)) : _className.push("w-full")
+ height ? (_size.height = unit(height)) : _className.push("h-4")
+ return {
+ style: _size,
+ className: _className.join(" "),
+ }
+ }, [width, height])
+
+ return (
+
+ )
+}
+
+function Container({
+ count = 1,
+ className,
+ children,
+}: PropsWithChildren<{ count?: number; className?: string }>) {
+ const { t } = useTranslation("common")
+ const childrenArray = React.Children.toArray(children)
+
+ return (
+
+ {Array.from(new Array(count)).map((_, index) => (
+
+ {childrenArray.map((child) =>
+ React.cloneElement(child as React.ReactElement, {
+ key: index,
+ }),
+ )}
+
+ ))}
+
{t("Loading")}...
+
+ )
+}
+
+function Circle({
+ size = 40,
+ className,
+}: {
+ size?: number
+ className?: string
+}) {
+ return (
+
+ )
+}
+
+function Rectangle({ className }: { className?: string }) {
+ return
+}
+
+Skeleton.Container = Container
+Skeleton.Circle = Circle
+Skeleton.Rectangle = Rectangle