Skip to content

Commit

Permalink
chore: folder structure and codebase setup
Browse files Browse the repository at this point in the history
  • Loading branch information
WomB0ComB0 committed Dec 6, 2023
1 parent b4d6b1e commit 7564000
Show file tree
Hide file tree
Showing 61 changed files with 3,786 additions and 42 deletions.
16 changes: 16 additions & 0 deletions frontend/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/styles/global/globals.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
37 changes: 36 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,58 @@
"preview": "vite preview"
},
"dependencies": {
"@hookform/resolvers": "^3.3.2",
"@nextui-org/react": "^2.2.9",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-aspect-ratio": "^1.0.3",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-context-menu": "^2.1.5",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-menubar": "^1.0.4",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-toggle": "^1.0.3",
"@radix-ui/react-toggle-group": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.7",
"@tailwindcss/typography": "^0.5.10",
"axios": "^1.6.2",
"cheerio": "^1.0.0-rc.12",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"cmdk": "^0.2.0",
"date-fns": "^2.30.0",
"express": "^4.18.2",
"framer-motion": "^10.16.5",
"lucide-react": "^0.292.0",
"react": "^18.2.0",
"react-day-picker": "^8.9.1",
"react-dom": "^18.2.0",
"react-hook-form": "^7.48.2",
"sonner": "^1.2.2",
"styled-components": "^6.1.1",
"tailwind-container-break-out": "^2.0.6",
"tailwind-merge": "^2.0.0",
"tailwind-merge": "^2.1.0",
"tailwindcss-animate": "^1.0.7",
"usehooks-ts": "^2.9.1",
"vite3-plugin-express": "^0.1.3",
"zod": "^3.22.4",
"zustand": "^4.4.6"
},
"devDependencies": {
Expand Down
File renamed without changes.
47 changes: 47 additions & 0 deletions frontend/src/components/build/nav/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use client"

import { Logo } from "@/components/logo";
import { CustomPopover } from "@/components/custom/Popover";
import { Nav, Div } from "../template/index";
import { MobileSidebar } from "./mobile-sidebar";
import { ModeToggle } from "../custom/ThemeButton";
import { Hint } from "../../custom/Hint";

export const Navbar = () => {
const { user } = useContext(UserContext);
return (
<Nav className="fixed z-50 top-0 px-4 w-full h-14 border-b shadow-sm flex items-center bg-background">
<MobileSidebar />
<Div className="flex items-center gap-x-4 justify-center">
<Div className="hidden md:flex items-center">
<Logo ContainerClassName={`pr-2`} />
<p
className={`
text-xl font-bold text-primary
`}
>
Next-Firebase
</p>
</Div>
</Div>
<Div className="ml-auto flex items-center gap-x-2">
<Hint
description="Toggle theme"
sideOffset={10}
>
<ModeToggle />
</Hint>
{user.name !== '' ? (
<CustomPopover>
<Hint
description="User profile"
sideOffset={10}
>
<UserAvatar />
</Hint>
</CustomPopover>
) : (null)}
</Div>
</Nav>
);
};
56 changes: 56 additions & 0 deletions frontend/src/components/build/nav/mobile-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"use client";

import { Menu } from "lucide-react";
import { useEffect, useState } from "react";
//
import { usePathname } from "next/navigation";

import { useMobileSidebar } from "@/hooks/use-mobile-sidebar";
import { Button } from "@/components/ui/button";
import { Sheet, SheetContent } from "@/components/ui/sheet";

import { Sidebar } from "./sidebar";

export const MobileSidebar = () => {
const pathname = usePathname();
const [isMounted, setIsMounted] = useState(false);

const onOpen = useMobileSidebar((state) => state.onOpen);
const onClose = useMobileSidebar((state) => state.onClose);
const isOpen = useMobileSidebar((state) => state.isOpen);

useEffect(() => {
setIsMounted(true);
}, []);

useEffect(() => {
onClose();
}, [pathname, onClose]);

if (!isMounted) {
return null;
}

return (
<>
<Button
onClick={onOpen}
className="block md:hidden mr-2"
variant="ghost"
size="sm"
>
<Menu className="h-4 w-4" />
</Button>
<Sheet open={isOpen} onOpenChange={onClose}>
<SheetContent
side="left"
className="p-2 pt-10"
>
<Sidebar
storageKey="t-sidebar-mobile-state"
/>
</SheetContent>
</Sheet>
</>
)
}
76 changes: 76 additions & 0 deletions frontend/src/components/build/nav/nav-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"use client";

//
import { useRouter, usePathname } from "next/navigation";
import {
Home,
Layout,
Settings,
} from "lucide-react";
import { Div } from "../template/index";
import { cn } from "@/lib/utils";
import {
AccordionContent,
AccordionItem,
AccordionTrigger
} from "@/components/ui/accordion";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { NavItems } from "@/components/NavItems";

interface NavItemProps {
isExpanded: boolean;
isActive: boolean;
onExpand: (id: string) => void;
};

export const NavItem = ({
isExpanded,
isActive,
onExpand,
}: NavItemProps) => {
const { user } = useContext(UserContext);

return (
<AccordionItem
value={user.id}
className="border-none"
>
<AccordionTrigger
onClick={() => onExpand(user.id)}
className={cn(
"flex items-center gap-x-2 p-1.5 text-neutral-700 rounded-md hover:bg-neutral-500/10 transition text-start no-underline hover:no-underline",
isActive && !isExpanded && "bg-sky-500/10 text-sky-700"
)}
>
<Div className="flex items-center gap-x-2">
<Div className="w-7 h-7 relative">
<Image
fill
src={user.avatar}
alt="User avatar"
className="rounded-sm object-cover"
/>
</Div>
<span className="font-medium text-sm">
{user.name}
</span>
</Div>
</AccordionTrigger>
<AccordionContent className="pt-1 text-neutral-700">
<NavItems />
</AccordionContent>
</AccordionItem>
);
};

NavItem.Skeleton = function SkeletonNavItem() {
return (
<Div className="flex items-center gap-x-2">
<Div className="w-10 h-10 relative shrink-0">
<Skeleton className="h-full w-full absolute" />
</Div>
<Skeleton className="h-10 w-full" />
</Div>
);
};
59 changes: 59 additions & 0 deletions frontend/src/components/build/nav/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"use client";

import { useLocalStorage } from "usehooks-ts";

import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { Accordion } from "@/components/ui/accordion";

import { NavItem } from "./nav-item";

interface SidebarProps {
storageKey?: string;
};

export const Sidebar = ({
storageKey = "t-sidebar-state",
}: SidebarProps) => {
const [expanded, setExpanded] = useLocalStorage<Record<string, any>>(
storageKey,
{}
);


const defaultAccordionValue: string[] = Object.keys(expanded)
.reduce((acc: string[], key: string) => {
if (expanded[key]) {
acc.push(key);
}

return acc;
}, []);

const onExpand = (id: string) => {
setExpanded((curr) => ({
...curr,
[id]: !expanded[id],
}));
};

return (
<>
<Accordion
type="multiple"
defaultValue={defaultAccordionValue}
className="space-y-2"
>
<>
{/* */}
<NavItem
key={user.id}
isActive={true}
isExpanded={expanded[user.id]}
onExpand={onExpand}
/>
</>
</Accordion>
</>
);
};
1 change: 1 addition & 0 deletions frontend/src/components/constants/Motion.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { motion } from "framer-motion";

export const MotionArticle = motion.article;
export const MotionDiv = motion.div;
export const MotionFigure = motion.figure
Expand Down
37 changes: 37 additions & 0 deletions frontend/src/components/custom/Hint.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger
} from "@/components/ui/tooltip";

interface HintProps {
children: React.ReactNode;
description: string;
side?: "left" | "right" | "top" | "bottom";
sideOffset?: number;
};

export const Hint = ({
children,
description,
side = "bottom",
sideOffset = 0
}: HintProps) => {
return (
<TooltipProvider>
<Tooltip delayDuration={0}>
<TooltipTrigger>
{children}
</TooltipTrigger>
<TooltipContent
sideOffset={sideOffset}
side={side}
className="text-xs max-w-[220px] break-words"
>
{description}
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
};
Loading

0 comments on commit 7564000

Please sign in to comment.