-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#123 new sidebar #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| bun run build | ||
| git pull --rebase origin main | ||
| bun run build | ||
| # git pull --rebase origin main |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # #!/bin/sh | ||
| # . "$(dirname "$0")/_/husky.sh" | ||
|
|
||
| # # Get the current branch name before rebase | ||
| # current_branch=$(git rev-parse --abbrev-ref HEAD) | ||
|
|
||
| # # Fetch latest changes from origin/main | ||
| # git fetch origin main | ||
|
|
||
| # # Count the number of commits ahead of origin/main | ||
| # commit_count=$(git rev-list --count origin/main..HEAD) | ||
|
|
||
| # # If more than one commit exists, abort rebase | ||
| # if [ "$commit_count" -gt 1 ]; then | ||
| # echo "❌ Rebase aborted: More than one commit ahead of origin/main ($commit_count commits)." | ||
| # echo "🔄 Please squash your commits first, then run 'git rebase'." | ||
| # exit 1 | ||
| # fi | ||
|
|
||
| # # Ensure we stay on the correct branch | ||
| # git checkout "$current_branch" 2>/dev/null || true | ||
|
|
||
| # echo "✅ Rebase can proceed. Only one or no commits ahead of main." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| "use client"; | ||
|
|
||
| import * as React from "react"; | ||
|
|
||
| //components ui | ||
| import { | ||
| Sidebar, | ||
| SidebarContent, | ||
| SidebarHeader, | ||
| SidebarRail, | ||
| useSidebar, | ||
| } from "@repo/ui/components/sidebar"; | ||
|
|
||
| //icons | ||
| import BoxPackage from "@repo/icons/box-package"; | ||
| import ChartBarPopular from "@repo/icons/chart-bar-popular"; | ||
| import LayoutDashboard from "@repo/icons/layout-dashboard"; | ||
| import ReportMoney from "@repo/icons/report-money"; | ||
| import Usericon from "@repo/icons/user"; | ||
|
|
||
| //components sidebar | ||
| import Settingsicon from "@repo/icons/settings"; | ||
| import { LogoIconSwitcher } from "./logo-icon-switcher"; | ||
| import { NavMain } from "./nav-main"; | ||
|
|
||
| // This is items of dashboard. | ||
| const data = { | ||
| navMain: [ | ||
| { | ||
| title: "Dashboard", | ||
| url: "/dashboard", | ||
| icon: LayoutDashboard, | ||
| }, | ||
| { | ||
| title: "Products", | ||
| url: "/products", | ||
| icon: BoxPackage, | ||
| }, | ||
| { | ||
| title: "Sales", | ||
| url: "/sales", | ||
| icon: ChartBarPopular, | ||
| }, | ||
| { | ||
| title: "Profile", | ||
| url: "/profile", | ||
| icon: Usericon, | ||
| }, | ||
| { | ||
| title: "Payouts", | ||
| url: "/payouts", | ||
| icon: ReportMoney, | ||
| }, | ||
| { | ||
| title: "Settings", | ||
| url: "/settings", | ||
| icon: Settingsicon, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) { | ||
| const { open, isMobile } = useSidebar(); | ||
|
|
||
| return ( | ||
| <Sidebar collapsible="icon" className="" {...props}> | ||
| <SidebarHeader className="pt-5 pb-6"> | ||
| <LogoIconSwitcher /> | ||
| </SidebarHeader> | ||
| <SidebarContent> | ||
| <NavMain items={data.navMain} /> | ||
| </SidebarContent> | ||
| <SidebarRail /> | ||
| </Sidebar> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||
| import * as React from "react"; | ||||||
| import { motion, AnimatePresence } from "framer-motion"; | ||||||
|
|
||||||
| // UI components | ||||||
| import { | ||||||
| SidebarMenu, | ||||||
| SidebarMenuItem, | ||||||
| useSidebar, | ||||||
| } from "@repo/ui/components/sidebar"; | ||||||
|
|
||||||
| // Logo | ||||||
| import PixelIcon from "@repo/icons/pxiel"; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in import path There's a typo in the import path: -import PixelIcon from "@repo/icons/pxiel";
+import PixelIcon from "@repo/icons/pixel";📝 Committable suggestion
Suggested change
|
||||||
| import { cn } from "@repo/ui/lib/utils"; | ||||||
|
|
||||||
| export function LogoIconSwitcher() { | ||||||
| const { open } = useSidebar(); | ||||||
|
|
||||||
| return ( | ||||||
| <SidebarMenu> | ||||||
| <SidebarMenuItem | ||||||
| className={"flex items-center flex-1 space-x-2 pl-2"} | ||||||
| style={{ | ||||||
| justifyContent: open ? "flex-start" : "center", | ||||||
| }} | ||||||
| > | ||||||
| {/* Ensure icon remains centered */} | ||||||
| <div className="flex aspect-square relative z-50 size-9 shrink-0 items-center justify-center rounded-lg text-sidebar-primary-foreground"> | ||||||
| <PixelIcon size={46} color="currentColor" /> | ||||||
| </div> | ||||||
|
|
||||||
| {/* Animate text visibility but maintain spacing */} | ||||||
| <AnimatePresence> | ||||||
| {open && ( | ||||||
| <motion.div | ||||||
| className="grid absolute left-12 flex-shrink text-left text-lg leading-tight overflow-hidden" | ||||||
| exit={{ opacity: 0, scale: 0 }} | ||||||
| transition={{ duration: 0.2 }} | ||||||
| > | ||||||
| <span className="truncate font-semibold">PixelGenius</span> | ||||||
| </motion.div> | ||||||
| )} | ||||||
| </AnimatePresence> | ||||||
| </SidebarMenuItem> | ||||||
| </SidebarMenu> | ||||||
| ); | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SidebarGroup, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SidebarMenu, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SidebarMenuButton, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SidebarMenuItem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "@repo/ui/components/sidebar"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { usePathname } from "next/navigation"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function NavMain({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| items, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| items: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| icon: React.ElementType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pathname = usePathname(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <SidebarGroup> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <SidebarMenu> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {items.map((item) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <SidebarMenuItem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={`${pathname === item.url ? "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]" : ""}`} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key={item.title} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <SidebarMenuButton asChild> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <a className="py-6" href={item.url}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <item.icon /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span>{item.title}</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </a> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </SidebarMenuButton> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+24
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enhance accessibility and UX The navigation items need accessibility improvements and better active state handling. Apply these changes: <SidebarMenuItem
- className={`${pathname === item.url ? "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]" : ""}`}
+ className={cn(
+ "transition-colors duration-200",
+ pathname === item.url && "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]"
+ )}
key={item.title}
>
<SidebarMenuButton asChild>
- <a className="py-6" href={item.url}>
+ <a
+ className="py-6"
+ href={item.url}
+ aria-current={pathname === item.url ? 'page' : undefined}
+ role="menuitem"
+ >
<item.icon />
- <span>{item.title}</span>
+ <span className="sr-only md:not-sr-only">{item.title}</span>
</a>
</SidebarMenuButton>
</SidebarMenuItem>📝 Committable suggestion
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please used cn function
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mrbadri, here’s an updated snippet that applies the cn function and adds Next.js-friendly accessibility attributes: TypeScript JSX code: import { cn } from "@/lib/utils"; // or wherever your cn helper is defined <SidebarMenuItem {item.title} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </SidebarMenuItem> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </SidebarMenu> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </SidebarGroup> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { SidebarTrigger } from "@repo/ui/components/sidebar"; | ||
|
|
||
| const NavbarDashboard = () => { | ||
| return ( | ||
| <nav className="bg-sidebar flex items-center justify-between"> | ||
| <div className="w-full"> | ||
| <SidebarTrigger /> | ||
| </div> | ||
| </nav> | ||
| ); | ||
| }; | ||
|
|
||
| export default NavbarDashboard; |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,15 +1,20 @@ | ||||||||||
| import React from "react"; | ||||||||||
| import SideBarDashboard from "./_compnents/sidebar"; | ||||||||||
| import { SidebarProvider } from "@repo/ui/components/sidebar"; | ||||||||||
| import { AppSidebar } from "./_compnents/app-sidebar"; | ||||||||||
| import NavbarDashboard from "./_compnents/navbar-dashboard"; | ||||||||||
|
Comment on lines
+3
to
+4
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the typos in import paths The directory name Suggested change: -import { AppSidebar } from "./_compnents/app-sidebar";
-import NavbarDashboard from "./_compnents/navbar-dashboard";
+import { AppSidebar } from "./_components/app-sidebar";
+import NavbarDashboard from "./_components/navbar-dashboard";📝 Committable suggestion
Suggested change
|
||||||||||
|
|
||||||||||
| export default function DashboardLayout({ | ||||||||||
| children, | ||||||||||
| }: { | ||||||||||
| children: React.ReactNode; | ||||||||||
| }): JSX.Element { | ||||||||||
| return ( | ||||||||||
| <div className="flex h-full"> | ||||||||||
| <SideBarDashboard /> | ||||||||||
| <div className="flex-1">{children}</div> | ||||||||||
| </div> | ||||||||||
| <SidebarProvider className="flex h-full "> | ||||||||||
| <AppSidebar /> | ||||||||||
| <main className="flex-1"> | ||||||||||
| <NavbarDashboard /> | ||||||||||
| {children} | ||||||||||
| </main> | ||||||||||
| </SidebarProvider> | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,11 +9,11 @@ export function middleware(request: NextRequest) { | |||||||||||||||||||||
| const isDashboard = pathname.startsWith("/dashboard"); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Redirect to login if unauthenticated | ||||||||||||||||||||||
| if (isDashboard) { | ||||||||||||||||||||||
| if (!accessToken || !refreshToken) { | ||||||||||||||||||||||
| return NextResponse.redirect(new URL("/auth/login", request.url)); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| // if (isDashboard) { | ||||||||||||||||||||||
| // if (!accessToken || !refreshToken) { | ||||||||||||||||||||||
| // return NextResponse.redirect(new URL("/auth/login", request.url)); | ||||||||||||||||||||||
| // } | ||||||||||||||||||||||
| // } | ||||||||||||||||||||||
|
Comment on lines
+12
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CRITICAL: Restore authentication checks for dashboard routes. Commenting out the authentication middleware for dashboard routes creates a significant security vulnerability by allowing unauthorized access to potentially sensitive dashboard content. This change doesn't appear to be necessary for implementing the new sidebar feature. Please restore the authentication checks by removing the comments: - // if (isDashboard) {
- // if (!accessToken || !refreshToken) {
- // return NextResponse.redirect(new URL("/auth/login", request.url));
- // }
- // }
+ if (isDashboard) {
+ if (!accessToken || !refreshToken) {
+ return NextResponse.redirect(new URL("/auth/login", request.url));
+ }
+ }If there's a specific reason why authentication needs to be disabled for the dashboard, please:
📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Allow access to protected routes if authenticated | ||||||||||||||||||||||
| return NextResponse.next(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,11 +2,12 @@ | |||||
|
|
||||||
| // https://s3-alpha-sig.figma.com/img/ce79/f737/ea54458a8146c4935 | ||||||
| //https://images.unsplash.com/photo-1730292422804-5bbb2bd2d3f0?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D | ||||||
| // https://github.com/shadcn.png | ||||||
| // config src image | ||||||
| const nextConfig = { | ||||||
| transpilePackages: ["@repo/ui"], | ||||||
| images: { | ||||||
| domains: ["images.unsplash.com"], | ||||||
| domains: ["images.unsplash.com", "github.com/shadcn.png"], | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the incorrect domain format for GitHub images. The domain "github.com/shadcn.png" is incorrectly formatted as it includes the full path. Next.js domains should only include the hostname. Apply this diff to fix the domain: - domains: ["images.unsplash.com", "github.com/shadcn.png"],
+ domains: ["images.unsplash.com", "github.com", "avatars.githubusercontent.com"],📝 Committable suggestion
Suggested change
|
||||||
| }, | ||||||
| output: "standalone", | ||||||
| }; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove unused destructured variables.
The
openandisMobilevariables are destructured fromuseSidebarbut never used.export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) { - const { open, isMobile } = useSidebar(); + useSidebar(); // Remove if not needed, or keep only required variables📝 Committable suggestion