Skip to content

Commit 8052dcb

Browse files
authored
feat: optimize UI/UX performance (#63)
1 parent 07834ac commit 8052dcb

14 files changed

Lines changed: 86 additions & 29 deletions

File tree

public/magaaazine.png

-83.4 KB
Loading

public/magaaazine_pro.png

-93.5 KB
Loading

src/app/[username]/layout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import DefaultLayout from "~/components/templates/DefaultLayout";
1+
import dynamic from "next/dynamic";
2+
3+
const DefaultLayout = dynamic(() => import("~/components/templates/DefaultLayout"));
24

35
export default function UserPageLayout({ children }: { children: React.ReactNode }) {
46
return (
57
<DefaultLayout>
6-
<section className="relative flex w-full flex-col items-center">
7-
{children}
8-
</section>
8+
<section className="relative flex w-full flex-col items-center">{children}</section>
99
</DefaultLayout>
1010
);
1111
}

src/app/[username]/loading.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default function Loading() {
2+
return (
3+
<div className="flex h-full w-full flex-col items-center justify-center">
4+
<div className="flex w-full max-w-2xl flex-col items-center gap-y-10 px-5 pb-10">
5+
<div className="h-[13rem] w-[13rem] animate-pulse rounded-full bg-neutral-300 object-cover" />
6+
<div className="flex w-full flex-col items-center gap-y-2">
7+
<div className="h-[2rem] w-[20rem] animate-pulse rounded-full bg-neutral-300" />
8+
<div className="h-[1.5rem] w-[15rem] animate-pulse rounded-full bg-neutral-300" />
9+
</div>
10+
<div className="flex w-full flex-row items-center justify-center gap-x-2">
11+
<div className="h-[2rem] w-[2rem] animate-pulse rounded-full bg-neutral-300" />
12+
<div className="h-[2rem] w-[2rem] animate-pulse rounded-full bg-neutral-300" />
13+
<div className="h-[2rem] w-[2rem] animate-pulse rounded-full bg-neutral-300" />
14+
<div className="h-[2rem] w-[2rem] animate-pulse rounded-full bg-neutral-300" />
15+
<div className="h-[2rem] w-[2rem] animate-pulse rounded-full bg-neutral-300" />
16+
</div>
17+
<div className="flex w-full flex-col items-center gap-y-3">
18+
<div className="h-[2rem] w-[20rem] animate-pulse rounded-full bg-neutral-300" />
19+
<div className="h-[1.5rem] w-full animate-pulse rounded-full bg-neutral-300" />
20+
</div>
21+
<div className="h-[15rem] w-full animate-pulse rounded-xl bg-neutral-300" />
22+
</div>
23+
</div>
24+
);
25+
}

src/app/[username]/page.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { Suspense } from "react";
22
import { Metadata } from "next";
33
import Image from "next/image";
4+
import dynamic from "next/dynamic";
45
import clsx from "clsx";
56

67
import getBase64 from "~/lib/functions/getBase64";
7-
import SocialMediaHolder from "~/components/molecules/SocialMediaHolder";
8-
import ProfileUpload from "~/components/molecules/Uploads/ProfileUpload";
9-
import CoverUpload from "~/components/molecules/Uploads/CoverUpload";
10-
import ProfileMainHolder from "~/components/molecules/ProfileMainHolder";
118

129
import { serverClient } from "../_trpc/serverClient";
1310

11+
const SocialMediaHolder = dynamic(() => import("~/components/molecules/SocialMediaHolder"));
12+
const ProfileUpload = dynamic(() => import("~/components/molecules/Uploads/ProfileUpload"));
13+
const CoverUpload = dynamic(() => import("~/components/molecules/Uploads/CoverUpload"));
14+
const ProfileMainHolder = dynamic(() => import("~/components/molecules/ProfileMainHolder"));
15+
1416
export async function generateMetadata({
1517
params,
1618
}: {
@@ -167,7 +169,7 @@ export default async function UserPage({ params }: { params: { username: string
167169
)}
168170
</div>
169171
{profile?.favorite_quote && (
170-
<q className="text-center text-base">{profile?.favorite_quote}</q>
172+
<q className="text-center text-xl font-light italic">{profile?.favorite_quote}</q>
171173
)}
172174
<ProfileMainHolder profile={profile} />
173175
</div>

src/app/discover/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import DiscoverList from "~/components/molecules/Lists/DiscoverList";
1+
import dynamic from "next/dynamic";
22

33
import { serverClient } from "~/app/_trpc/serverClient";
44

5+
const DiscoverList = dynamic(() => import("~/components/molecules/Lists/DiscoverList"));
6+
57
export default async function Discover() {
68
const usersData = await serverClient.users({
79
cursor: "",

src/app/files-images/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { cookies } from "next/headers";
22
import { redirect } from "next/navigation";
3+
import dynamic from "next/dynamic";
34

4-
import FilesImagesList from "~/components/molecules/Lists/FilesImagesList";
5+
const FilesImagesList = dynamic(() => import("~/components/molecules/Lists/FilesImagesList"));
56

67
import { serverClient } from "../_trpc/serverClient";
78

src/app/forgot-password/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Metadata } from "next";
22
import { cookies } from "next/headers";
33
import { redirect } from "next/navigation";
4+
import dynamic from "next/dynamic";
45

5-
import ForgotPasswordForm from "~/components/molecules/Forms/ForgotPasswordForm";
6+
const ForgotPasswordForm = dynamic(() => import("~/components/molecules/Forms/ForgotPasswordForm"));
67

78
export const metadata: Metadata = {
89
title: "Magaaazine | Forgot Password?",

src/app/pricing/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default function Pricing() {
1111
className="h-[10rem] w-[10rem] rounded-full object-scale-down"
1212
src="/magaaazine.png"
1313
alt="magaaazine"
14+
priority
1415
width={100}
1516
height={100}
1617
quality={100}
@@ -51,6 +52,7 @@ export default function Pricing() {
5152
className="h-[10rem] w-[10rem] rounded-full object-scale-down"
5253
src="/magaaazine_pro.png"
5354
alt="magaaazine_pro"
55+
priority
5456
width={100}
5557
height={100}
5658
quality={100}

src/components/molecules/Lists/FilesImagesList.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import { useState, useEffect, Fragment } from "react";
44
import { useInView } from "react-intersection-observer";
55
import Link from "next/link";
66
import Image from "next/legacy/image";
7+
import dynamic from "next/dynamic";
78
import clsx from "clsx";
89
import moment from "moment";
9-
import AlertModal from "../Modals/AlertModal";
10-
import AlertModalDynamic from "../Modals/AlertModalDynamic";
1110
import ActivityIndicator from "~/components/atoms/ActivityIndicator";
1211

1312
import { trpc } from "~/app/_trpc/client";
1413
import { serverClient } from "~/app/_trpc/serverClient";
1514
import { deleteImage } from "~/lib/functions/deleteImage";
1615

16+
const AlertModal = dynamic(() => import("../Modals/AlertModal"));
17+
const AlertModalDynamic = dynamic(() => import("../Modals/AlertModalDynamic"));
18+
1719
interface FilesImagesListProps {
1820
initialData: Awaited<ReturnType<(typeof serverClient)["filesImages"]>> | any;
1921
}

0 commit comments

Comments
 (0)