-
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.
🚀 feat: refactor sidebar components and implement theme toggle functi…
…onality
- Loading branch information
Showing
9 changed files
with
361 additions
and
172 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,104 @@ | ||
import { | ||
Collapsible, | ||
CollapsibleContent, | ||
CollapsibleTrigger, | ||
} from "@/components/ui/collapsible"; | ||
import { | ||
SidebarGroup, | ||
SidebarMenu, | ||
SidebarMenuButton, | ||
SidebarMenuItem, | ||
SidebarMenuSub, | ||
SidebarMenuSubButton, | ||
SidebarMenuSubItem, | ||
} from "@/components/ui/sidebar"; | ||
import { ROUTES } from "@/lib/router"; | ||
import { | ||
BookImage, | ||
BookOpen, | ||
Bookmark, | ||
ChevronRight, | ||
Newspaper, | ||
} from "lucide-react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
const items = [ | ||
{ | ||
title: "Bookmarks", | ||
url: "#bookmark", | ||
icon: Bookmark, | ||
isActive: true, | ||
items: [ | ||
{ | ||
title: "Articles", | ||
icon: Newspaper, | ||
url: `${ROUTES.BOOKMARKS}?type=bookmark&category=article`, | ||
}, | ||
{ | ||
title: "EPUBs", | ||
icon: BookOpen, | ||
url: `${ROUTES.BOOKMARKS}?type=bookmark&category=epub`, | ||
}, | ||
{ | ||
title: "PDFs", | ||
icon: BookImage, | ||
url: `${ROUTES.BOOKMARKS}?type=bookmark&category=pdf`, | ||
}, | ||
// { | ||
// title: "Videos", | ||
// url: `${ROUTES.BOOKMARKS}?type=bookmark&category=video`, | ||
// }, | ||
// { | ||
// title: "Podcasts", | ||
// url: `${ROUTES.BOOKMARKS}?type=bookmark&category=podcast`, | ||
// }, | ||
], | ||
}, | ||
// { | ||
// title: "Subscriptions", | ||
// url: `${ROUTES.BOOKMARKS}?type=feed`, | ||
// icon: Rss, | ||
// items: [], | ||
// } | ||
]; | ||
|
||
export function BookmarkSidebarContent() { | ||
return ( | ||
<SidebarGroup> | ||
<SidebarMenu> | ||
{items.map((item) => ( | ||
<Collapsible | ||
key={item.title} | ||
asChild | ||
defaultOpen={item.isActive} | ||
className="group/collapsible" | ||
> | ||
<SidebarMenuItem> | ||
<CollapsibleTrigger asChild> | ||
<SidebarMenuButton tooltip={item.title}> | ||
{item.icon && <item.icon />} | ||
<span>{item.title}</span> | ||
<ChevronRight className="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" /> | ||
</SidebarMenuButton> | ||
</CollapsibleTrigger> | ||
<CollapsibleContent> | ||
<SidebarMenuSub> | ||
{item.items?.map((subItem) => ( | ||
<SidebarMenuSubItem key={subItem.title}> | ||
<SidebarMenuSubButton asChild> | ||
<Link to={subItem.url}> | ||
{subItem.icon && <subItem.icon />} | ||
<span>{subItem.title}</span> | ||
</Link> | ||
</SidebarMenuSubButton> | ||
</SidebarMenuSubItem> | ||
))} | ||
</SidebarMenuSub> | ||
</CollapsibleContent> | ||
</SidebarMenuItem> | ||
</Collapsible> | ||
))} | ||
</SidebarMenu> | ||
</SidebarGroup> | ||
); | ||
} |
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,104 @@ | ||
import { | ||
Collapsible, | ||
CollapsibleContent, | ||
CollapsibleTrigger, | ||
} from "@/components/ui/collapsible"; | ||
import { | ||
SidebarGroup, | ||
SidebarMenu, | ||
SidebarMenuButton, | ||
SidebarMenuItem, | ||
SidebarMenuSub, | ||
SidebarMenuSubButton, | ||
SidebarMenuSubItem, | ||
} from "@/components/ui/sidebar"; | ||
import { ROUTES } from "@/lib/router"; | ||
import { | ||
BookImage, | ||
BookOpen, | ||
Bookmark, | ||
ChevronRight, | ||
Newspaper, | ||
} from "lucide-react"; | ||
import { Link } from "react-router-dom"; | ||
|
||
const items = [ | ||
{ | ||
title: "Bookmarks", | ||
url: "#bookmark", | ||
icon: Bookmark, | ||
isActive: true, | ||
items: [ | ||
{ | ||
title: "Articles", | ||
icon: Newspaper, | ||
url: `${ROUTES.BOOKMARKS}?type=bookmark&category=article`, | ||
}, | ||
{ | ||
title: "EPUBs", | ||
icon: BookOpen, | ||
url: `${ROUTES.BOOKMARKS}?type=bookmark&category=epub`, | ||
}, | ||
{ | ||
title: "PDFs", | ||
icon: BookImage, | ||
url: `${ROUTES.BOOKMARKS}?type=bookmark&category=pdf`, | ||
}, | ||
// { | ||
// title: "Videos", | ||
// url: `${ROUTES.BOOKMARKS}?type=bookmark&category=video`, | ||
// }, | ||
// { | ||
// title: "Podcasts", | ||
// url: `${ROUTES.BOOKMARKS}?type=bookmark&category=podcast`, | ||
// }, | ||
], | ||
}, | ||
// { | ||
// title: "Subscriptions", | ||
// url: `${ROUTES.BOOKMARKS}?type=feed`, | ||
// icon: Rss, | ||
// items: [], | ||
// } | ||
]; | ||
|
||
export function BookmarksSidebarContent() { | ||
return ( | ||
<SidebarGroup> | ||
<SidebarMenu> | ||
{items.map((item) => ( | ||
<Collapsible | ||
key={item.title} | ||
asChild | ||
defaultOpen={item.isActive} | ||
className="group/collapsible" | ||
> | ||
<SidebarMenuItem> | ||
<CollapsibleTrigger asChild> | ||
<SidebarMenuButton tooltip={item.title}> | ||
{item.icon && <item.icon />} | ||
<span>{item.title}</span> | ||
<ChevronRight className="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" /> | ||
</SidebarMenuButton> | ||
</CollapsibleTrigger> | ||
<CollapsibleContent> | ||
<SidebarMenuSub> | ||
{item.items?.map((subItem) => ( | ||
<SidebarMenuSubItem key={subItem.title}> | ||
<SidebarMenuSubButton asChild> | ||
<Link to={subItem.url}> | ||
{subItem.icon && <subItem.icon />} | ||
<span>{subItem.title}</span> | ||
</Link> | ||
</SidebarMenuSubButton> | ||
</SidebarMenuSubItem> | ||
))} | ||
</SidebarMenuSub> | ||
</CollapsibleContent> | ||
</SidebarMenuItem> | ||
</Collapsible> | ||
))} | ||
</SidebarMenu> | ||
</SidebarGroup> | ||
); | ||
} |
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,64 @@ | ||
import type * as React from "react"; | ||
|
||
import { NavUser } from "@/components/sidebar-nav-user"; | ||
import { | ||
Sidebar, | ||
SidebarContent, | ||
SidebarFooter, | ||
SidebarGroup, | ||
SidebarHeader, | ||
SidebarMenu, | ||
SidebarMenuButton, | ||
SidebarMenuItem, | ||
SidebarRail, | ||
} from "@/components/ui/sidebar"; | ||
import { ROUTES } from "@/lib/router"; | ||
import { Bookmark, Settings2 } from "lucide-react"; | ||
import { Link } from "react-router-dom"; | ||
import { BookmarksSidebarContent } from "./bookmarks-sidebar-content"; | ||
import ThemeToggle from "./theme-toggle"; | ||
|
||
export function BookmarksSidebar({ | ||
...props | ||
}: React.ComponentProps<typeof Sidebar>) { | ||
return ( | ||
<Sidebar collapsible="icon" {...props}> | ||
<SidebarHeader> | ||
<SidebarMenu> | ||
<SidebarMenuItem> | ||
<SidebarMenuButton size="lg" asChild> | ||
<Link to={ROUTES.HOME}> | ||
<div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground"> | ||
<Bookmark className="size-4" /> | ||
</div> | ||
<div className="flex flex-col gap-0.5 leading-none"> | ||
<span className="font-semibold">Vibrain</span> | ||
</div> | ||
</Link> | ||
</SidebarMenuButton> | ||
</SidebarMenuItem> | ||
</SidebarMenu> | ||
</SidebarHeader> | ||
<SidebarContent> | ||
<BookmarksSidebarContent /> | ||
<SidebarGroup className="mt-auto"> | ||
<SidebarMenu> | ||
<SidebarMenuItem key="preferences"> | ||
<SidebarMenuButton asChild> | ||
<Link to={ROUTES.SETTINGS}> | ||
<Settings2 /> | ||
<span>Preferences</span> | ||
</Link> | ||
</SidebarMenuButton> | ||
</SidebarMenuItem> | ||
<ThemeToggle /> | ||
</SidebarMenu> | ||
</SidebarGroup> | ||
</SidebarContent> | ||
<SidebarFooter> | ||
<NavUser /> | ||
</SidebarFooter> | ||
<SidebarRail /> | ||
</Sidebar> | ||
); | ||
} |
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
Oops, something went wrong.