Skip to content

Commit 153ef0e

Browse files
committed
feat: implement settings management with localStorage
1 parent 54319d4 commit 153ef0e

File tree

5 files changed

+353
-356
lines changed

5 files changed

+353
-356
lines changed

src/app/(dashboard)/layout.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Link from "next/link";
1919
import { usePathname, useRouter } from "next/navigation";
2020

2121
// -- React --
22-
import React, { useCallback, useMemo, useState } from "react";
22+
import React, { useCallback, useEffect, useMemo, useState } from "react";
2323

2424
// -- React-icon
2525
import { MdChevronRight, MdExitToApp, MdExpandMore } from "react-icons/md";
@@ -89,6 +89,15 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
8989
}
9090
};
9191

92+
useEffect(() => {
93+
if (hasChildren) {
94+
const childPaths = item.childrens!.map((child) => child.href);
95+
if (childPaths.includes(pathName)) {
96+
setIsExpanded(true);
97+
}
98+
}
99+
}, [pathName]);
100+
92101
const paddingLeft = 2 + level * 3;
93102

94103
return (

src/app/(dashboard)/project/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export default function ProjectPage() {
253253
</Box>
254254
</>
255255
) : (
256-
<Box sx={{ p: 3, minHeight: "100vh" }}>
256+
<Box sx={{ p: 3 }}>
257257
<Box
258258
sx={{
259259
display: "flex",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { ReactNode } from "react"
2+
import { Card, CardContent } from "@mui/material"
3+
import { IconType } from "react-icons"
4+
5+
interface Props {
6+
title: string
7+
description: string
8+
icon: IconType
9+
children: ReactNode
10+
}
11+
12+
export function SectionCard({
13+
title,
14+
description,
15+
icon: Icon,
16+
children,
17+
}: Props) {
18+
return (
19+
<Card className="rounded-2xl shadow-sm">
20+
<CardContent className="p-6 space-y-6">
21+
<div className="flex items-center gap-3">
22+
<div className="p-2 rounded-xl bg-indigo-500/10 text-indigo-600">
23+
<Icon size={18} />
24+
</div>
25+
<div>
26+
<h3 className="font-bold">{title}</h3>
27+
<p className="text-sm text-gray-500">{description}</p>
28+
</div>
29+
</div>
30+
31+
<div className="divide-y">{children}</div>
32+
</CardContent>
33+
</Card>
34+
)
35+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ReactNode } from "react"
2+
3+
interface Props {
4+
label: string
5+
description?: string
6+
children: ReactNode
7+
}
8+
9+
export function SettingRow({ label, description, children }: Props) {
10+
return (
11+
<div className="flex items-center justify-between gap-6 py-4">
12+
<div className="space-y-1">
13+
<p className="text-sm font-semibold">{label}</p>
14+
{description && (
15+
<p className="text-xs text-gray-500 max-w-md">
16+
{description}
17+
</p>
18+
)}
19+
</div>
20+
<div>{children}</div>
21+
</div>
22+
)
23+
}

0 commit comments

Comments
 (0)