Skip to content

Commit

Permalink
feat(frontend):Implement responsive news page & responsive admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
teguhbayu committed May 5, 2024
1 parent e2201fe commit 541f2e1
Show file tree
Hide file tree
Showing 15 changed files with 1,428 additions and 1,892 deletions.
2,890 changes: 1,137 additions & 1,753 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@uiw/react-md-editor": "^4.0.4",
"bcrypt": "^5.1.1",
"cloudinary": "^2.1.0",
"clsx": "^2.1.1",
"dotenv-cli": "^7.4.1",
"framer-motion": "^11.0.20",
"next": "14.2.1",
Expand All @@ -35,14 +36,15 @@
"react-select": "^5.8.0",
"schema-dts": "^1.1.2",
"sonner": "^1.4.41",
"styled-components": "^6.1.8"
"styled-components": "^6.1.8",
"tailwind-merge": "^2.3.0"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.4.19",
"eslint": "^9.1.0",
"eslint": "^8.57.0",
"eslint-config-next": "14.1.4",
"husky": "^9.0.11",
"postcss": "^8",
Expand Down
61 changes: 46 additions & 15 deletions src/app/(admin)/admin/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,65 @@ export const DashboardIcon = () => {
<path
d="M10.1103 11.65H7.4603C6.8303 11.65 6.32031 12.16 6.32031 12.79V17.91H10.1103V11.65V11.65Z"
stroke="#E04E4E"
stroke-width="1.5"
stroke-miterlimit="10"
stroke-linecap="round"
stroke-linejoin="round"
strokeWidth="1.5"
strokeMiterlimit="10"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M12.7616 7.09998H11.2415C10.6115 7.09998 10.1016 7.60999 10.1016 8.23999V17.9H13.8916V8.23999C13.8916 7.60999 13.3916 7.09998 12.7616 7.09998Z"
stroke="#E04E4E"
stroke-width="1.5"
stroke-miterlimit="10"
stroke-linecap="round"
stroke-linejoin="round"
strokeWidth="1.5"
strokeMiterlimit="10"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M16.5484 13.35H13.8984V17.9H17.6884V14.49C17.6784 13.86 17.1684 13.35 16.5484 13.35Z"
stroke="#E04E4E"
stroke-width="1.5"
stroke-miterlimit="10"
stroke-linecap="round"
stroke-linejoin="round"
strokeWidth="1.5"
strokeMiterlimit="10"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M9 22.5H15C20 22.5 22 20.5 22 15.5V9.5C22 4.5 20 2.5 15 2.5H9C4 2.5 2 4.5 2 9.5V15.5C2 20.5 4 22.5 9 22.5Z"
stroke="#E04E4E"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
};

export function HamburgerIcon() {
return (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3 7H21"
stroke="#121212"
strokeWidth="1.2"
strokeLinecap="round"
/>
<path
d="M3 12H21"
stroke="#121212"
strokeWidth="1.2"
strokeLinecap="round"
/>
<path
d="M3 17H21"
stroke="#121212"
strokeWidth="1.2"
strokeLinecap="round"
/>
</svg>
);
}
98 changes: 98 additions & 0 deletions src/app/(admin)/admin/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import Image from "next/image";
import { DashboardIcon, HamburgerIcon } from "./Icons";
import { useState } from "react";
import { protectedRoutes } from "@/utils/protectedRoutes";
import { Session } from "next-auth";
import { P } from "@/app/_components/global/Text";
import { PrimaryButton } from "@/app/_components/global/Button";
import { signOut } from "next-auth/react";

interface NavOption {
title: string;
href: string;
}

const navOptions: NavOption[] = [
{ title: "Beranda", href: "/" },
{ title: "Berita", href: "/berita" },
{ title: "Sub-organ", href: "/sub-organ" },
{ title: "Tentang", href: "/tentang" },
{ title: "Kontributor", href: "/kontributor" },
];

export default function Navbar({ session }: { session: Session | null }) {
const pathname = usePathname();
const [isExpanded, setIsExpanded] = useState(false);

const allowedRoutes = protectedRoutes.filter(
(item) =>
item.roles == "All" ||
item.roles.includes(session?.user?.role!) ||
(!session?.user?.role?.includes("Admin") &&
item.roles.includes("SubOrgan")),
);

return (
<nav className="xl:relative fixed z-[999] mx-auto w-full flex flex-col lg:hidden">
<div className="w-full flex xl:max-w-[1192px] z-[999] py-4 xl:py-0 px-5 bg-white xl:bg-transparent justify-between">
<Link href={"/"} className="block xl:mt-8">
<Image
src={"/horizontal.svg"}
alt="Logo moklet.org"
width={120}
height={50}
className="pointer-events-none h-[50px] w-[130px]"
/>
</Link>
<button
className="block xl:hidden"
onClick={() => setIsExpanded(!isExpanded)}
>
<HamburgerIcon />
</button>
</div>
<div
className={`block xl:hidden py-3 w-full z-[800] bg-white transition-all duration-500 ${isExpanded ? "mt-0" : " -mt-[650px]"}`}
>
<div className="flex flex-col gap-8 text-start justify-start items-start my-[21px] mx-5">
<ul className="space-y-4 pb-2 w-full">
<li>
<Link
href={"/admin"}
className="group flex items-center rounded-lg p-2 text-base font-normal text-primary-400 hover:bg-red-100 transition-all"
>
<DashboardIcon />
<P className="ml-3 whitespace-nowrap text-primary-400 font-semibold">
Dashboard
</P>
</Link>
</li>
<P className="font-semibold">Menu</P>
{allowedRoutes.map((item, index) => (
<li key={index}>
<Link
href={item.path}
className={
(pathname.includes(item.path) ? "bg-red-100 " : "") +
"group flex items-center rounded-lg p-2 text-base font-normal text-primary-400 hover:bg-red-200 transition-all"
}
>
<div dangerouslySetInnerHTML={{ __html: item.icon }} />
<P className="ml-3 whitespace-nowrap text-primary-400 font-semibold">
{item.title}
</P>
</Link>
</li>
))}
<PrimaryButton onClick={() => signOut()} className="w-full">
Log Out
</PrimaryButton>
</ul>
</div>
</div>
</nav>
);
}
5 changes: 5 additions & 0 deletions src/app/(admin)/admin/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { P } from "@/app/_components/global/Text";
import { protectedRoutes } from "@/utils/protectedRoutes";
import { usePathname } from "next/navigation";
import { DashboardIcon } from "./Icons";
import { PrimaryButton } from "@/app/_components/global/Button";
import { signOut } from "next-auth/react";

type navbarParam = {
nav: boolean;
Expand Down Expand Up @@ -70,6 +72,9 @@ export function Sidebar({ nav, session }: navbarParam) {
</Link>
</li>
))}
<PrimaryButton onClick={() => signOut()} className="w-full">
Log Out
</PrimaryButton>
</ul>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/app/(admin)/admin/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Sidebar } from "./components/Sidebar";
import React, { useState } from "react";
import { usePathname } from "next/navigation";
import Link from "next/link";
import Image from "next/image";
import Navbar from "./components/Navbar";
import { useSession } from "next-auth/react";

export default function RootLayout({
Expand All @@ -19,15 +19,16 @@ export default function RootLayout({
return (
<main className="flex w-full h-screen overflow-hidden bg-slate-50">
<Sidebar nav={nav} session={session} />
<Navbar session={session} />
<div
className={`bg-gray-900 opacity-50 ${
nav ? "" : "hidden"
} fixed inset-0 z-10 `}
} fixed inset-0 z-10`}
id="sidebarBackdrop"
/>
<div
id="main-content"
className="relative h-full w-full overflow-y-auto ps-2 lg:ps-24 py-4 lg:ml-64 "
className="relative h-full w-full overflow-y-auto ps-2 lg:ps-24 py-4 lg:ml-64 mt-[90px] lg:mt-0"
>
<nav className="w-max rounded-lg align-middle p-2 font-sans text-2xl capitalize md:p-3">
<ol className="flex ">
Expand Down
Loading

0 comments on commit 541f2e1

Please sign in to comment.