Skip to content

Commit

Permalink
ui: Redesign the settings page and move it to its own layout
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Oct 27, 2024
1 parent 801ba36 commit eb7da99
Show file tree
Hide file tree
Showing 23 changed files with 165 additions and 65 deletions.
60 changes: 0 additions & 60 deletions apps/web/app/dashboard/settings/page.tsx

This file was deleted.

5 changes: 5 additions & 0 deletions apps/web/app/settings/ai/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import AISettings from "@/components/settings/AISettings";

export default function AISettingsPage() {
return <AISettings />;
}
9 changes: 9 additions & 0 deletions apps/web/app/settings/api-keys/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ApiKeySettings from "@/components/settings/ApiKeySettings";

export default async function ApiKeysPage() {
return (
<div className="rounded-md border bg-background p-4">
<ApiKeySettings />
</div>
);
}
9 changes: 9 additions & 0 deletions apps/web/app/settings/import/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ImportExport from "@/components/settings/ImportExport";

export default function ImportSettingsPage() {
return (
<div className="rounded-md border bg-background p-4">
<ImportExport />
</div>
);
}
11 changes: 11 additions & 0 deletions apps/web/app/settings/info/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ChangePassword } from "@/components/settings/ChangePassword";
import UserDetails from "@/components/settings/UserDetails";

export default async function InfoPage() {
return (
<div className="rounded-md border bg-background p-4">
<UserDetails />
<ChangePassword />
</div>
);
}
34 changes: 34 additions & 0 deletions apps/web/app/settings/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Header from "@/components/dashboard/header/Header";
import DemoModeBanner from "@/components/DemoModeBanner";
import MobileSidebar from "@/components/settings/sidebar/ModileSidebar";
import Sidebar from "@/components/settings/sidebar/Sidebar";
import { Separator } from "@/components/ui/separator";
import ValidAccountCheck from "@/components/utils/ValidAccountCheck";

import serverConfig from "@hoarder/shared/config";

export default async function SettingsLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<div>
<Header />
<div className="flex min-h-[calc(100vh-64px)] w-screen flex-col sm:h-[calc(100vh-64px)] sm:flex-row">
<ValidAccountCheck />
<div className="hidden flex-none sm:flex">
<Sidebar />
</div>
<main className="flex-1 bg-muted sm:overflow-y-auto">
{serverConfig.demoMode && <DemoModeBanner />}
<div className="block w-full sm:hidden">
<MobileSidebar />
<Separator />
</div>
<div className="min-h-30 container p-4">{children}</div>
</main>
</div>
</div>
);
}
6 changes: 6 additions & 0 deletions apps/web/app/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { redirect } from "next/navigation";

export default function SettingsHomepage() {
redirect("/settings/info");
return null;
}
2 changes: 1 addition & 1 deletion apps/web/components/dashboard/header/ProfileOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function SidebarProfileOptions() {
</div>
<Separator className="my-2" />
<DropdownMenuItem asChild>
<Link href="/dashboard/settings">
<Link href="/settings">
<Settings className="mr-2 size-4" />
User Settings
</Link>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/dashboard/sidebar/AllLists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useCallback } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import SidebarItem from "@/components/shared/sidebar/SidebarItem";
import { Button } from "@/components/ui/button";
import { CollapsibleTriggerTriangle } from "@/components/ui/collapsible";
import { MoreHorizontal, Plus } from "lucide-react";
Expand All @@ -13,7 +14,6 @@ import { ZBookmarkListTreeNode } from "@hoarder/shared/utils/listUtils";
import { CollapsibleBookmarkLists } from "../lists/CollapsibleBookmarkLists";
import { EditListModal } from "../lists/EditListModal";
import { ListOptions } from "../lists/ListOptions";
import SidebarItem from "./SidebarItem";

export default function AllLists({
initialData,
Expand Down
3 changes: 1 addition & 2 deletions apps/web/components/dashboard/sidebar/ModileSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import MobileSidebarItem from "@/components/shared/sidebar/ModileSidebarItem";
import HoarderLogoIcon from "@/public/icons/logo-icon.svg";
import { ClipboardList, Search, Tag } from "lucide-react";

import MobileSidebarItem from "./ModileSidebarItem";

export default async function MobileSidebar() {
return (
<aside className="w-full">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/dashboard/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { redirect } from "next/navigation";
import SidebarItem from "@/components/shared/sidebar/SidebarItem";
import { Separator } from "@/components/ui/separator";
import { api } from "@/server/api/client";
import { getServerAuthSession } from "@/server/auth";
Expand All @@ -7,7 +8,6 @@ import { Archive, Home, Search, Tag } from "lucide-react";
import serverConfig from "@hoarder/shared/config";

import AllLists from "./AllLists";
import SidebarItem from "./SidebarItem";

export default async function Sidebar() {
const session = await getServerAuthSession();
Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions apps/web/components/settings/sidebar/ModileSidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import MobileSidebarItem from "@/components/shared/sidebar/ModileSidebarItem";

import { settingsSidebarItems } from "./items";

export default async function MobileSidebar() {
return (
<aside className="w-full">
<ul className="flex justify-between space-x-2 border-b-black px-5 py-2 pt-5">
{settingsSidebarItems.map((item) => (
<MobileSidebarItem
key={item.name}
logo={item.icon}
path={item.path}
/>
))}
</ul>
</aside>
);
}
34 changes: 34 additions & 0 deletions apps/web/components/settings/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { redirect } from "next/navigation";
import SidebarItem from "@/components/shared/sidebar/SidebarItem";
import { getServerAuthSession } from "@/server/auth";

import serverConfig from "@hoarder/shared/config";

import { settingsSidebarItems } from "./items";

export default async function Sidebar() {
const session = await getServerAuthSession();
if (!session) {
redirect("/");
}

return (
<aside className="flex h-[calc(100vh-64px)] w-60 flex-col gap-5 border-r p-4 ">
<div>
<ul className="space-y-2 text-sm font-medium">
{settingsSidebarItems.map((item) => (
<SidebarItem
key={item.name}
logo={item.icon}
name={item.name}
path={item.path}
/>
))}
</ul>
</div>
<div className="mt-auto flex items-center border-t pt-2 text-sm text-gray-400">
Hoarder v{serverConfig.serverVersion}
</div>
</aside>
);
}
34 changes: 34 additions & 0 deletions apps/web/components/settings/sidebar/items.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";
import { ArrowLeft, Download, KeyRound, Sparkles, User } from "lucide-react";

export const settingsSidebarItems: {
name: string;
icon: JSX.Element;
path: string;
}[] = [
{
name: "Back To App",
icon: <ArrowLeft size={18} />,
path: "/dashboard/bookmarks",
},
{
name: "User Info",
icon: <User size={18} />,
path: "/settings/info",
},
{
name: "AI Settings",
icon: <Sparkles size={18} />,
path: "/settings/ai",
},
{
name: "Import / Export",
icon: <Download size={18} />,
path: "/settings/import",
},
{
name: "API Keys",
icon: <KeyRound size={18} />,
path: "/settings/api-keys",
},
];

0 comments on commit eb7da99

Please sign in to comment.