Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
refactor: re-arranged components
Browse files Browse the repository at this point in the history
  • Loading branch information
saeidex committed Oct 23, 2024
1 parent 23955ab commit 73e29ac
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 97 deletions.
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/_components/auth-showcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { signIn } from "@ubus/auth";
import { cn } from "@ubus/ui";
import { Button } from "@ubus/ui/button";

import { LogoIcon } from "./logo-icon";
import { LogoIcon } from "./logo";

interface IAuthShowcaseProps {
className?: string;
Expand Down
22 changes: 0 additions & 22 deletions apps/nextjs/src/app/_components/dashboard/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { IconMenu } from "@tabler/icons-react";
import { Button } from "@ubus/ui/button";

import { Logo } from "./logo";
import { NavBar } from "./navbar";
import { DashboardNavbar, LandingNavbar } from "./navbar";

export const Header = () => {
export const DashboardHeader = () => {
return <DashboardNavbar />;
};

export const LandingHeader = () => {
return (
<nav className="container border-outline">
<div className="mx-auto flex h-24 flex-wrap items-center justify-between">
Expand All @@ -30,7 +34,7 @@ export const Header = () => {
<IconMenu />
</Button>
</div>
<NavBar />
<LandingNavbar />
</div>
</nav>
);
Expand Down
22 changes: 0 additions & 22 deletions apps/nextjs/src/app/_components/landing-page/index.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions apps/nextjs/src/app/_components/logo-icon.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
import Image from "next/image";

import { useThemeBasedValue } from "@ubus/hooks";
import { cn } from "@ubus/ui";

export const LogoIcon = ({ className }: { className?: string }) => {
const logoSrc = useThemeBasedValue("ubus.svg", "ubus-dark.svg");

return (
<Image
width={48}
height={48}
src={logoSrc}
loading="lazy"
className={cn("mx-auto max-h-12 w-auto", className)}
alt="ubus logo"
/>
);
};

export const Logo = () => {
const logoSrc = useThemeBasedValue("ubus.svg", "ubus-dark.svg");
Expand Down
31 changes: 31 additions & 0 deletions apps/nextjs/src/app/_components/logout-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use server";

import { IconLogout } from "@tabler/icons-react";

import type { ButtonProps } from "@ubus/ui/button";
import { signOut } from "@ubus/auth";
import { Button } from "@ubus/ui/button";

interface LogoutButtonProps extends ButtonProps {
withIcon?: boolean;
}

export const LogoutButton = ({
withIcon = true,
...props
}: LogoutButtonProps) => {
return (
<form className="contents">
<Button
{...props}
formAction={async () => {
"use server";
await signOut();
}}
>
{withIcon && <IconLogout className="mr-2" />}
Log out
</Button>
</form>
);
};
29 changes: 29 additions & 0 deletions apps/nextjs/src/app/_components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { landingNavLinks } from "@ubus/configs";

import { LogoutButton } from "./logout-button";
import { NavLink } from "./navlink";
import { UserAvatar } from "./user-avatar";

export const DashboardNavbar = () => {
return (
<div className="container flex h-20 w-full justify-between">
UBus
<UserAvatar />
<LogoutButton />
</div>
);
};

export const LandingNavbar = () => {
return (
<div className="hidden w-full items-center justify-between md:order-1 md:flex md:w-auto">
<ul className="mt-4 flex flex-col rounded-lg p-4 font-medium md:mt-0 md:flex-row md:gap-8 md:p-0">
{landingNavLinks.map((link) => (
<li key={link.href}>
<NavLink className="px-0" link={link} />
</li>
))}
</ul>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,9 @@ import Link from "next/link";
import { usePathname } from "next/navigation";

import type { INavLink } from "@ubus/configs";
import { landingNavLinks } from "@ubus/configs";
import { cn } from "@ubus/ui";
import { Button } from "@ubus/ui/button";

export const NavBar = () => {
return (
<div className="hidden w-full items-center justify-between md:order-1 md:flex md:w-auto">
<ul className="mt-4 flex flex-col rounded-lg p-4 font-medium md:mt-0 md:flex-row md:gap-8 md:p-0">
{landingNavLinks.map((link) => (
<li key={link.href}>
<NavLink className="px-0" link={link} />
</li>
))}
</ul>
</div>
);
};

export const NavLink = ({
link,
className,
Expand Down
23 changes: 23 additions & 0 deletions apps/nextjs/src/app/_components/user-avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { cn } from "@ubus/ui";
import { Avatar, AvatarFallback, AvatarImage } from "@ubus/ui/avatar";
import { Label } from "@ubus/ui/label";

interface IUserAvatarProps {
className?: string;
}
export const UserAvatar = ({ className }: IUserAvatarProps) => {
return (
<div
className={cn(
"flex h-fit flex-nowrap items-center justify-center",
className,
)}
>
<Label>User Name</Label>
<Avatar>
<AvatarFallback>UN</AvatarFallback>
<AvatarImage src="" />
</Avatar>
</div>
);
};
7 changes: 7 additions & 0 deletions apps/nextjs/src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DashboardHeader } from "../_components/header";

const Dashboard = () => {
return <DashboardHeader />;
};

export default Dashboard;
32 changes: 20 additions & 12 deletions apps/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { auth } from "@ubus/auth";
import { Contact } from "./_components/contact";
import { EssentialFeatures, KeyFeatures } from "./_components/features";
import { Footer } from "./_components/footer";
import { LandingHeader } from "./_components/header";
import { Hero } from "./_components/hero";
import { OurTeam } from "./_components/our-team";
import { Testimonials } from "./_components/testimonials";

import { Dashboard } from "./_components/dashboard";
import LandingPage from "./_components/landing-page";

const HomePage = async () => {
const session = await auth();

if (!session) {
return <LandingPage />;
}

return <Dashboard />;
const HomePage = () => {
return (
<>
<LandingHeader />
<Hero />
<KeyFeatures />
<EssentialFeatures />
<Testimonials />
<OurTeam />
<Contact />
<Footer />
</>
);
};

export default HomePage;
2 changes: 1 addition & 1 deletion apps/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
".",
".next/types/**/*.ts",
"src/app/_components/auth-showcase.tsx",
"src/app/_components/logo-icon.tsx"
"src/app/_components/logo.tsx"
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lint:fix": "turbo run lint --continue -- --fix --cache --cache-location .cache/.eslintcache",
"lint:ws": "pnpm dlx sherif@latest",
"typecheck": "turbo run typecheck",
"turbo:restart": "turbo daemon restart",
"ui-add": "turbo run ui-add"
},
"prettier": "@ubus/prettier-config",
Expand Down

0 comments on commit 73e29ac

Please sign in to comment.