Skip to content

Commit

Permalink
[UI v2] feat: Scaffolds UX components for Settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
devinvillarosa committed Jan 30, 2025
1 parent a2362a2 commit af8362f
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 5 deletions.
27 changes: 27 additions & 0 deletions ui-v2/src/components/settings/heading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbList,
} from "@/components/ui/breadcrumb";

type HeadingProps = {
version: string;
};

export const Heading = ({ version }: HeadingProps) => {
return (
<div className="flex justify-between items-center">
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem className="text-xl font-semibold">
Settings
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
<div className="flex flex-col gap-1">
<div className="text-xs text-muted-foreground">Version</div>
<div className="text-xs">{version}</div>
</div>
</div>
);
};
14 changes: 14 additions & 0 deletions ui-v2/src/components/settings/server-settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type ServerSettingsProps = {
settings: Record<string, unknown>;
};

export const ServerSettings = ({ settings }: ServerSettingsProps) => {
return (
<div className="flex flex-col gap-1">
<label htmlFor="server-settings">Server Settings</label>
<div id="server-settings" className="p-2 bg-slate-100 rounded-sm">
TODO: {JSON.stringify(settings)}
</div>
</div>
);
};
20 changes: 20 additions & 0 deletions ui-v2/src/components/settings/settings-page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { buildGetSettingsQuery, buildGetVersionQuery } from "@/api/admin";

import { useSuspenseQuery } from "@tanstack/react-query";
import { Heading } from "./heading";
import { ServerSettings } from "./server-settings";
import { ThemeSwitch } from "./theme-switch";

export const SettingsPage = () => {
const { data: settingsData } = useSuspenseQuery(buildGetSettingsQuery());
const { data: versionData } = useSuspenseQuery(buildGetVersionQuery());

return (
<div className="flex flex-col gap-4">
<Heading version={versionData} />
<ThemeSwitch />
{/** nb: open API needs to update schema */}
<ServerSettings settings={settingsData as Record<string, unknown>} />
</div>
);
};
17 changes: 17 additions & 0 deletions ui-v2/src/components/settings/theme-switch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Icon } from "@/components/ui/icons";
import { Switch } from "@/components/ui/switch";

// TODO: Switch for dark mode provider

export const ThemeSwitch = () => {
return (
<div className="flex flex-col gap-1">
<label htmlFor="theme-switch">Theme</label>
<div className="flex gap-2 items-center">
<Icon id="Sun" className="h-4 w-4" />
<Switch />
<Icon id="Moon" className="h-7 w-4" />
</div>
</div>
);
};
4 changes: 4 additions & 0 deletions ui-v2/src/components/ui/icons/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
Cpu,
ExternalLink,
Loader2,
Moon,
MoreHorizontal,
MoreVertical,
PanelLeft,
Expand All @@ -26,6 +27,7 @@ import {
Rocket,
Search,
ServerCrash,
Sun,
Trash2,
Variable,
Workflow,
Expand All @@ -51,6 +53,7 @@ export const ICONS = {
Cpu,
ExternalLink,
Loader2,
Moon,
MoreHorizontal,
MoreVertical,
PanelLeft,
Expand All @@ -60,6 +63,7 @@ export const ICONS = {
Rocket,
Search,
ServerCrash,
Sun,
Trash2,
Variable,
Workflow,
Expand Down
7 changes: 2 additions & 5 deletions ui-v2/src/routes/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { buildGetSettingsQuery, buildGetVersionQuery } from "@/api/admin";
import { SettingsPage } from "@/components/settings/settings-page";
import { createFileRoute } from "@tanstack/react-router";

export const Route = createFileRoute("/settings")({
component: RouteComponent,
component: SettingsPage,
loader: ({ context }) =>
Promise.all([
context.queryClient.ensureQueryData(buildGetSettingsQuery()),
context.queryClient.ensureQueryData(buildGetVersionQuery()),
]),
wrapInSuspense: true,
});

function RouteComponent() {
return "🚧🚧 Pardon our dust! 🚧🚧";
}

0 comments on commit af8362f

Please sign in to comment.