Skip to content

Commit

Permalink
feat: setting tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed May 19, 2024
1 parent 50e0407 commit eda249c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 11 deletions.
12 changes: 11 additions & 1 deletion src/renderer/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,17 @@ const router = createBrowserRouter([
},
{
path: "settings",
lazy: () => import("./pages/settings"),
lazy: () => import("./pages/settings/layout"),
children: [
{
path: "",
lazy: () => import("./pages/settings/index"),
},
{
path: "profile",
lazy: () => import("./pages/settings/profile"),
},
],
},
{
path: "debug",
Expand Down
10 changes: 0 additions & 10 deletions src/renderer/src/pages/settings.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions src/renderer/src/pages/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function Component() {
return <>general</>
}
50 changes: 50 additions & 0 deletions src/renderer/src/pages/settings/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { cn } from "@renderer/lib/utils"
import { Link, Outlet, useLocation } from "react-router-dom"

const tabs = [
{
name: "General",
path: "",
className: "i-mingcute-settings-7-line",
},
{
name: "Profile",
path: "profile",
className: "i-mingcute-user-setting-line",
},
]

export function Component() {
const location = useLocation()
const tab = location.pathname.replace(/^\/settings\/?/, "")

return (
<div className="flex flex-col h-screen">
<div
className="h-10 border-b flex items-center pl-20 text-sm font-medium"
aria-hidden
>
Follow Settings
</div>
<div className="flex flex-1">
<div className="border-r w-44 p-2">
{tabs.map((t) => (
<Link
key={t.path}
className={`flex items-center h-9 text-[15px] rounded transition-colors p-2 text-zinc-600 ${
tab === t.path ? "bg-zinc-200 text-zinc-900" : ""
}`}
to={`/settings/${t.path}`}
>
<i className={cn("m-2", t.className)}></i>
{t.name}
</Link>
))}
</div>
<div className="p-2">
<Outlet />
</div>
</div>
</div>
)
}
3 changes: 3 additions & 0 deletions src/renderer/src/pages/settings/profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function Component() {
return <>profile</>
}

0 comments on commit eda249c

Please sign in to comment.