-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UI v2] feat: Scaffolds UX components for Settings page
- Loading branch information
1 parent
a2362a2
commit af8362f
Showing
6 changed files
with
84 additions
and
5 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,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> | ||
); | ||
}; |
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,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> | ||
); | ||
}; |
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,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> | ||
); | ||
}; |
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,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> | ||
); | ||
}; |
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 |
---|---|---|
@@ -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! 🚧🚧"; | ||
} |