Merge pull request 'UI: sidebar add icons to sections' (#2605) from hsjobeki/clan-core:hsjobeki-main into main
This commit is contained in:
@@ -8,9 +8,11 @@ import { SidebarHeader } from "./SidebarHeader";
|
|||||||
import { SidebarListItem } from "./SidebarListItem";
|
import { SidebarListItem } from "./SidebarListItem";
|
||||||
import { Typography } from "../Typography";
|
import { Typography } from "../Typography";
|
||||||
import "./css/sidebar.css";
|
import "./css/sidebar.css";
|
||||||
|
import Icon, { IconVariant } from "../icon";
|
||||||
|
|
||||||
export const SidebarSection = (props: {
|
export const SidebarSection = (props: {
|
||||||
title: string;
|
title: string;
|
||||||
|
icon: IconVariant;
|
||||||
children: JSX.Element;
|
children: JSX.Element;
|
||||||
}) => {
|
}) => {
|
||||||
const { title, children } = props;
|
const { title, children } = props;
|
||||||
@@ -19,7 +21,7 @@ export const SidebarSection = (props: {
|
|||||||
<details class="sidebar__section accordeon" open>
|
<details class="sidebar__section accordeon" open>
|
||||||
<summary class="accordeon__header">
|
<summary class="accordeon__header">
|
||||||
<Typography
|
<Typography
|
||||||
class="uppercase"
|
class="inline-flex w-full gap-2 uppercase"
|
||||||
tag="p"
|
tag="p"
|
||||||
hierarchy="body"
|
hierarchy="body"
|
||||||
size="xs"
|
size="xs"
|
||||||
@@ -27,7 +29,9 @@ export const SidebarSection = (props: {
|
|||||||
color="tertiary"
|
color="tertiary"
|
||||||
inverted={true}
|
inverted={true}
|
||||||
>
|
>
|
||||||
|
<Icon icon={props.icon} />
|
||||||
{title}
|
{title}
|
||||||
|
<Icon icon="CaretDown" class="ml-auto" />
|
||||||
</Typography>
|
</Typography>
|
||||||
</summary>
|
</summary>
|
||||||
<div class="accordeon__body">{children}</div>
|
<div class="accordeon__body">{children}</div>
|
||||||
@@ -64,7 +68,7 @@ export const Sidebar = (props: RouteSectionProps) => {
|
|||||||
{(meta) => <SidebarHeader clanName={meta().name} />}
|
{(meta) => <SidebarHeader clanName={meta().name} />}
|
||||||
</Show>
|
</Show>
|
||||||
<div class="sidebar__body max-h-[calc(100vh-4rem)] overflow-scroll">
|
<div class="sidebar__body max-h-[calc(100vh-4rem)] overflow-scroll">
|
||||||
<For each={routes.filter((r) => !r.hidden && r.path != "/clans")}>
|
<For each={routes.filter((r) => !r.hidden)}>
|
||||||
{(route: AppRoute) => (
|
{(route: AppRoute) => (
|
||||||
<Show
|
<Show
|
||||||
when={route.children}
|
when={route.children}
|
||||||
@@ -73,7 +77,10 @@ export const Sidebar = (props: RouteSectionProps) => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
{(children) => (
|
{(children) => (
|
||||||
<SidebarSection title={route.label}>
|
<SidebarSection
|
||||||
|
title={route.label}
|
||||||
|
icon={route.icon || "Paperclip"}
|
||||||
|
>
|
||||||
<ul>
|
<ul>
|
||||||
<For each={children().filter((r) => !r.hidden)}>
|
<For each={children().filter((r) => !r.hidden)}>
|
||||||
{(child) => (
|
{(child) => (
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const icons = {
|
|||||||
Update,
|
Update,
|
||||||
};
|
};
|
||||||
|
|
||||||
type IconVariant = keyof typeof icons;
|
export type IconVariant = keyof typeof icons;
|
||||||
|
|
||||||
interface IconProps extends JSX.SvgSVGAttributes<SVGElement> {
|
interface IconProps extends JSX.SvgSVGAttributes<SVGElement> {
|
||||||
icon: IconVariant;
|
icon: IconVariant;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { ModuleList } from "./routes/modules/list";
|
|||||||
import { ModuleDetails } from "./routes/modules/details";
|
import { ModuleDetails } from "./routes/modules/details";
|
||||||
import { ModuleDetails as AddModule } from "./routes/modules/add";
|
import { ModuleDetails as AddModule } from "./routes/modules/add";
|
||||||
import { ApiTester } from "./api_test";
|
import { ApiTester } from "./api_test";
|
||||||
|
import { IconVariant } from "./components/icon";
|
||||||
|
|
||||||
export const client = new QueryClient();
|
export const client = new QueryClient();
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if (import.meta.env.DEV) {
|
|||||||
|
|
||||||
export type AppRoute = Omit<RouteDefinition, "children"> & {
|
export type AppRoute = Omit<RouteDefinition, "children"> & {
|
||||||
label: string;
|
label: string;
|
||||||
icon?: string;
|
icon?: IconVariant;
|
||||||
children?: AppRoute[];
|
children?: AppRoute[];
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
};
|
};
|
||||||
@@ -55,7 +56,7 @@ export const routes: AppRoute[] = [
|
|||||||
{
|
{
|
||||||
path: "/machines",
|
path: "/machines",
|
||||||
label: "Machines",
|
label: "Machines",
|
||||||
icon: "devices_other",
|
icon: "Grid",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
@@ -78,7 +79,8 @@ export const routes: AppRoute[] = [
|
|||||||
{
|
{
|
||||||
path: "/clans",
|
path: "/clans",
|
||||||
label: "Clans",
|
label: "Clans",
|
||||||
icon: "groups",
|
hidden: true,
|
||||||
|
icon: "List",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
@@ -101,7 +103,7 @@ export const routes: AppRoute[] = [
|
|||||||
{
|
{
|
||||||
path: "/modules",
|
path: "/modules",
|
||||||
label: "Modules",
|
label: "Modules",
|
||||||
icon: "apps",
|
icon: "Search",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
@@ -125,33 +127,38 @@ export const routes: AppRoute[] = [
|
|||||||
{
|
{
|
||||||
path: "/tools",
|
path: "/tools",
|
||||||
label: "Tools",
|
label: "Tools",
|
||||||
icon: "bolt",
|
icon: "Folder",
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "/flash",
|
path: "/flash",
|
||||||
label: "Clan Installer",
|
label: "Flash Installer",
|
||||||
component: () => <Flash />,
|
component: () => <Flash />,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/hosts",
|
|
||||||
label: "Local Hosts",
|
|
||||||
component: () => <HostList />,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/welcome",
|
path: "/welcome",
|
||||||
label: "",
|
label: "",
|
||||||
hidden: false,
|
hidden: true,
|
||||||
component: () => <Welcome />,
|
component: () => <Welcome />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/internal-dev",
|
||||||
|
label: "Internal (Only visible in dev mode)",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "/hosts",
|
||||||
|
label: "Local Hosts",
|
||||||
|
component: () => <HostList />,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/api_testing",
|
path: "/api_testing",
|
||||||
label: "api_testing",
|
label: "api_testing",
|
||||||
icon: "bolt",
|
|
||||||
hidden: false,
|
hidden: false,
|
||||||
component: () => <ApiTester />,
|
component: () => <ApiTester />,
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
render(
|
render(
|
||||||
|
|||||||
Reference in New Issue
Block a user