Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,44 @@
import { ReactNode } from "react";
import { useParams } from "react-router";
import BreadcrumbSimple from "../breadcrumbs/BreadcrumbSimple";
import Tabs, { TabItem } from "../tabs/Tabs";
import clsx from "clsx";
import { cn } from "~/lib/utils";
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
import UrlUtils from "~/utils/app/UrlUtils";
interface Props {
title?: ReactNode;
menu?: {
title: string;
routePath?: string;
}[];
buttons?: ReactNode;
children: ReactNode;
withHome?: boolean;
tabs?: TabItem[];
fullWidth?: boolean;
className?: string;
}
export default function EditPageLayout({ title, menu, buttons, children, withHome = true, tabs, fullWidth, className }: Props) {
const params = useParams();
const home = params.tenant ? UrlUtils.currentTenantUrl(params, "dashboard") : adminPath("dashboard", { mode: "host-aware" });
return (
<div className={cn(className, "mx-auto space-y-3 px-4 pt-3 sm:px-6 lg:px-8", fullWidth ? "w-full" : "max-w-5xl xl:max-w-7xl 2xl:max-w-(--breakpoint-2xl)")}>
{(title || buttons || menu || tabs) && (
<div className="space-y-1">
<div className="flex items-center justify-between space-x-2">
<h1 className="flex flex-1 items-center truncate text-xl font-medium">{title}</h1>
<div className="flex items-center space-x-2">{buttons}</div>
</div>
{menu && <BreadcrumbSimple home={withHome ? home : undefined} menu={menu} />}
{tabs && <Tabs tabs={tabs} className="grow" />}
</div>
)}
{children}
</div>
);
}
@@ -0,0 +1,40 @@
import { ReactNode } from "react";
import Breadcrumb from "../breadcrumbs/Breadcrumb";
import Tabs, { TabItem } from "../tabs/Tabs";
import BreadcrumbSimple from "../breadcrumbs/BreadcrumbSimple";
interface Props {
title?: ReactNode;
buttons?: ReactNode;
children: ReactNode;
tabs?: TabItem[];
breadcrumb?: { title: string; routePath?: string }[];
replaceTitleWithTabs?: boolean;
}
export default function IndexPageLayout({ title, buttons, children, tabs, breadcrumb, replaceTitleWithTabs }: Props) {
return (
<>
{(title || buttons || (replaceTitleWithTabs && tabs)) && (
<div className="border-border-default bg-surface-neutral-primary w-full border-b py-2 shadow-2xs">
<div className="mx-auto flex max-w-5xl items-center justify-between space-x-2 px-4 sm:px-6 lg:px-8 xl:max-w-full">
{replaceTitleWithTabs && tabs ? (
<Tabs tabs={tabs} exact className="grow" />
) : (
<div className="flex flex-1 items-center truncate font-bold">{title}</div>
)}
{buttons && <div className="flex items-center space-x-2">{buttons}</div>}
</div>
</div>
)}
{breadcrumb && <BreadcrumbSimple className="p-4" menu={breadcrumb} />}
{tabs && !replaceTitleWithTabs && (
<div className="w-full py-2">
<div className="mx-auto flex max-w-5xl items-center justify-between space-x-2 px-4 sm:px-6 lg:px-8 xl:max-w-full">
<Tabs tabs={tabs} className="grow" />
</div>
</div>
)}
<div className="mx-auto max-w-5xl space-y-2 px-4 pb-6 pt-2 sm:px-6 lg:px-8 xl:max-w-full">{children}</div>
</>
);
}
@@ -0,0 +1,30 @@
import { ReactNode } from "react";
import BreadcrumbSimple from "../breadcrumbs/BreadcrumbSimple";
import { cn } from "~/lib/utils";
interface Props {
title: string;
menu?: {
title: string;
routePath?: string;
}[];
buttons?: ReactNode;
children: ReactNode;
className?: string;
}
export default function NewPageLayout({ title, menu, buttons, children, className }: Props) {
return (
<div className={cn(className, "mx-auto max-w-2xl space-y-3 px-4 pb-6 pt-3 sm:px-6 lg:px-8")}>
<div className="space-y-1">
<div className="flex items-center justify-between space-x-2">
<h1 className="flex flex-1 items-center truncate text-xl font-medium">{title}</h1>
<div className="flex items-center space-x-2">{buttons}</div>
</div>
{menu && <BreadcrumbSimple menu={menu} />}
</div>
{children}
</div>
);
}
@@ -0,0 +1,77 @@
import { Link, useLocation } from "react-router";
import clsx from "clsx";
import { ReactNode } from "react";
import { useTranslation } from "react-i18next";
import Tabs from "../tabs/Tabs";
export default function SettingsLayout({
items,
children,
}: {
items: { name: string; description: string; routePath: string; icon: ReactNode }[];
children: ReactNode;
}) {
const { t } = useTranslation();
return (
<div className="flex flex-1 overflow-hidden">
<div className="flex flex-1 flex-col overflow-y-auto lg:overflow-hidden">
{/* Breadcrumb */}
<div className="p-3 lg:hidden">
<Tabs tabs={items} breakpoint="lg" asLinks={true} />
</div>
<div className="flex flex-1 lg:overflow-hidden">
{/* Secondary sidebar */}
<nav aria-label={t("components.settingsLayout.sections")} className="border-border-default bg-surface-neutral-primary hidden w-72 shrink-0 border-r lg:flex lg:flex-col">
<div className="border-border-default flex h-16 shrink-0 items-center border-b px-6">
<p className="text-text-neutral-primary text-lg font-medium">{t("settings.title")}</p>
</div>
<div className="min-h-screen flex-1 overflow-y-auto">
<SubNavigation items={items} />
</div>
</nav>
{children}
</div>
</div>
</div>
);
}
function SubNavigation({
items,
}: {
items: {
name: string;
description: string;
routePath: string;
icon: ReactNode;
}[];
}) {
const location = useLocation();
function isCurrent(idx: number) {
return currentTab() === items[idx];
}
const currentTab = () => {
return items.find((element) => element.routePath && (location.pathname + location.search).includes(element.routePath));
};
return (
<>
{items.map((item, idx) => (
<Link
key={item.name}
to={item.routePath}
className={clsx(isCurrent(idx) ? "bg-surface-neutral-secondary/50" : "hover:bg-surface-neutral-secondary/50", "border-border-default flex border-b px-6 py-3")}
aria-current={isCurrent(idx) ? "page" : undefined}
>
{item.icon}
<div className="ml-3 text-sm">
<p className="text-text-neutral-primary font-medium">{item.name}</p>
<p className="text-text-neutral-tertiary mt-1 text-xs">{item.description}</p>
</div>
</Link>
))}
</>
);
}
@@ -0,0 +1,154 @@
import { Link, useLocation } from "react-router";
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherSidebarClose, FeatherSidebarOpen } from "@subframe/core";
import UrlUtils from "~/utils/app/UrlUtils";
import Tabs from "../tabs/Tabs";
import EntityIcon from "~/components/layouts/icons/EntityIcon";
import { IconButton, SidebarInside } from "~/ui";
export type IconDto = {
name: string;
href: string;
prefetch?: "intent" | "render" | "none";
icon?: React.ReactNode;
iconSelected?: React.ReactNode;
bottom?: boolean;
exact?: boolean;
textIcon?: string;
textIconSelected?: string;
hidden?: boolean;
};
// Pro-User gemerkter Collapse-Zustand der Inner-Sidebar (Default: aufgeklappt).
const COLLAPSE_STORAGE_KEY = "hg.innerSidebar.collapsed";
export default function SidebarIconsLayout({
children,
items,
}: {
children: React.ReactNode;
items: IconDto[];
// Beibehalten für API-Kompatibilität der 17 Call-Sites; in Davids Inner-Sidebar nicht mehr nötig.
label?: {
align: "bottom" | "right";
};
scrollRestoration?: boolean;
}) {
const { t } = useTranslation();
const location = useLocation();
const mainElement = useRef<HTMLDivElement>(null);
// SSR-safe: Server rendert immer aufgeklappt, der gemerkte Zustand wird erst nach Hydration geladen.
const [collapsed, setCollapsed] = useState(false);
// Transitions erst NACH dem Restore aktivieren, sonst animiert der gemerkte Zustand bei jedem Seitenaufruf.
const [animate, setAnimate] = useState(false);
useEffect(() => {
try {
setCollapsed(window.localStorage.getItem(COLLAPSE_STORAGE_KEY) === "1");
} catch {
// localStorage nicht verfügbar (Privatmodus o.ä.) -> Default aufgeklappt
}
const id = window.requestAnimationFrame(() => setAnimate(true));
return () => window.cancelAnimationFrame(id);
}, []);
function toggleCollapsed() {
setCollapsed((prev) => {
const next = !prev;
try {
window.localStorage.setItem(COLLAPSE_STORAGE_KEY, next ? "1" : "0");
} catch {
// persistieren best-effort
}
return next;
});
}
function findExactRoute(element: IconDto) {
const hrefWithoutQuery = element.href.split("?")[0];
if (element.exact) {
return UrlUtils.stripTrailingSlash(location.pathname) === UrlUtils.stripTrailingSlash(hrefWithoutQuery);
}
return (location.pathname + location.search).includes(hrefWithoutQuery);
}
const currentTab = items.find((element) => findExactRoute(element));
function renderItem(item: IconDto, idx: number) {
const current = currentTab?.name === item.name;
const iconNode =
item.textIcon !== undefined ? (
<EntityIcon className="h-5 w-5" icon={current ? item.textIconSelected ?? item.textIcon : item.textIcon} />
) : current ? (
item.iconSelected ?? item.icon
) : (
item.icon
);
// Eingeklappt: Davids zentrierte icon-only-Variant (Icon mittig, Text aus, Selected-Bg als sauberes
// Quadrat). Der Link zentriert das w-auto-Item in der schmalen Rail (justify-center), sonst klebt das
// Icon links. Aufgeklappt: icon-and-text, w-full -> linksbündig wie gehabt. Die Width bleibt animiert.
return (
<Link key={idx} prefetch={item.prefetch} to={item.href} className="flex w-full justify-center" title={item.name}>
<SidebarInside.NavItem icon={iconNode} selected={current} variant={collapsed ? "icon-only" : "icon-and-text"}>
{item.name}
</SidebarInside.NavItem>
</Link>
);
}
const topItems = items.filter((f) => !f.bottom && !f.hidden);
const bottomItems = items.filter((f) => f.bottom && !f.hidden);
return (
<div className="sm:flex sm:flex-row">
{/* Desktop: Inner-Sidebar in Davids Optik, echt einklappbar (Width-Transition) */}
<div className="relative hidden sm:flex">
<SidebarInside
visible={true}
variant="open"
className={`min-h-[calc(100vh-70px)] min-w-0 overflow-hidden ${animate ? "transition-[width] duration-200 ease-in-out" : ""} ${
collapsed ? "w-12" : "w-[208px]"
}`}
>
{topItems.map(renderItem)}
{bottomItems.length > 0 && (
<div className="mt-auto flex w-full flex-col">
<SidebarInside.NavDivider />
{bottomItems.map(renderItem)}
</div>
)}
</SidebarInside>
{/* Eigener sichtbarer Toggle: Davids interner Button wird vom overflow-hidden der Bar verdeckt. */}
<div className="absolute -right-[17px] top-[26px] z-20 flex h-8 w-8 items-center justify-center">
<IconButton
variant="tertiary"
size="extra-small"
square={true}
icon={collapsed ? <FeatherSidebarOpen /> : <FeatherSidebarClose />}
onClick={toggleCollapsed}
aria-label={t("components.sidebar.toggle")}
/>
</div>
</div>
{/* Mobile: Tabs-Leiste (unverändert) */}
<div className="border-border-default bg-surface-neutral-primary w-full border-b py-2 shadow-2xs sm:hidden">
<div className="mx-auto flex max-w-5xl items-center justify-between gap-2 px-4 sm:px-6 lg:px-8 xl:max-w-7xl 2xl:max-w-(--breakpoint-2xl)">
<Tabs
tabs={items
.filter((f) => !f.hidden)
.map((i) => {
return { name: i.name, routePath: i.href };
})}
className="grow"
/>
</div>
</div>
{/* Hauptbereich */}
<div ref={mainElement} className="w-full overflow-x-hidden">
{children}
</div>
</div>
);
}