-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: folder structure and codebase setup
- Loading branch information
1 parent
b4d6b1e
commit 7564000
Showing
61 changed files
with
3,786 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
Oops, something went wrong.