Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -0,0 +1,87 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { act, fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { SidebarWithSections } from ".";
describe("SidebarWithSections navigation motion", () => {
it("uses caller-provided translated names for logo navigation", () => {
const onLogoClick = vi.fn();
const { rerender } = render(
<SidebarWithSections logoHref="/dashboard" logoLabel="Übersicht" />,
);
expect(screen.getByRole("link", { name: "Übersicht" })).toHaveAttribute("href", "/dashboard");
rerender(
<SidebarWithSections logoLabel="Zur Übersicht" onLogoClick={onLogoClick} />,
);
fireEvent.click(screen.getByRole("button", { name: "Zur Übersicht" }));
expect(onLogoClick).toHaveBeenCalledOnce();
});
it("smoothly transitions the full item scale in both directions", () => {
const { container } = render(<SidebarWithSections.NavItem>Dashboard</SidebarWithSections.NavItem>);
const itemSurface = container.querySelector('[data-slot="app-sidebar-nav-item-surface"]');
expect(itemSurface).toHaveClass(
"pointer-events-none",
"scale-100",
"transition-[background-color,scale]",
"duration-150",
"ease-[cubic-bezier(0.4,0,0.2,1)]",
"motion-reduce:transition-none",
"group-hover/2713e17b:scale-[1.065]",
"data-[sidebar-sweep-hover=true]:scale-[1.065]",
);
});
it("pulses items crossed between fast pointer samples", () => {
vi.useFakeTimers();
try {
const { container } = render(
<SidebarWithSections>
<SidebarWithSections.NavItem>CRM</SidebarWithSections.NavItem>
<SidebarWithSections.NavItem>Leads</SidebarWithSections.NavItem>
<SidebarWithSections.NavItem>Boards</SidebarWithSections.NavItem>
</SidebarWithSections>,
);
const sidebar = container.querySelector("nav");
const items = container.querySelectorAll<HTMLElement>('[data-sidebar-hover-item="true"]');
const surfaces = container.querySelectorAll<HTMLElement>('[data-sidebar-hover-surface="true"]');
expect(sidebar).not.toBeNull();
expect(items).toHaveLength(3);
items.forEach((item, index) => {
const top = index * 40;
vi.spyOn(item, "getBoundingClientRect").mockReturnValue({
top,
bottom: top + 40,
left: 0,
right: 200,
width: 200,
height: 40,
x: 0,
y: top,
toJSON: () => ({}),
});
});
const movePointerTo = (clientY: number) => {
const event = new Event("pointermove", { bubbles: true });
Object.defineProperty(event, "clientY", { value: clientY });
fireEvent(sidebar!, event);
};
movePointerTo(20);
movePointerTo(100);
expect(surfaces[1]).toHaveAttribute("data-sidebar-sweep-hover", "true");
act(() => vi.advanceTimersByTime(150));
expect(surfaces[1]).not.toHaveAttribute("data-sidebar-sweep-hover");
} finally {
vi.useRealTimers();
}
});
});
@@ -12,6 +12,7 @@ import { FeatherSidebarClose } from "@subframe/core";
import { FeatherSidebarOpen } from "@subframe/core";
import * as SubframeCore from "@subframe/core";
import * as SubframeUtils from "../../utils";
import { useSidebarHoverSweep } from "../../sidebar-hover-sweep";
import { IconButton } from "../IconButton";
import { Logo } from "../Logo";
@@ -37,34 +38,37 @@ const NavItem = React.forwardRef<HTMLDivElement, NavItemProps>(function NavItem(
return (
<div
className={SubframeUtils.twClassNames(
// @subframe/sync-disable -- local fix: keep the item left-anchored on collapse (no items-center flip) so the icon does not jump horizontally.
"group/2713e17b flex w-full cursor-pointer flex-col items-start gap-2 pt-2",
{ "items-center": variant === "icon-only" },
className
)}
ref={ref}
data-sidebar-hover-item="true"
{...otherProps}
>
<div
className={SubframeUtils.twClassNames(
// @subframe/sync-disable -- local fix: no items-center flip on collapse (keeps subitem behaviour, drops icon-only centering).
"flex w-full flex-col items-start gap-2",
{
"items-end justify-center": variant === "subitem",
"items-center": variant === "icon-only",
}
)}
>
<div
className={SubframeUtils.twClassNames(
"flex w-full items-center gap-2.5 rounded-md px-3 py-2 group-hover/2713e17b:bg-surface-neutral-tertiary",
// @subframe/sync-disable -- local fix: icon-only keeps the same left-aligned row (w-full px-3) as the expanded state and only hides the label, so the icon stays at a constant horizontal position through the width animation.
// @subframe/sync-disable -- local fix: same hover lift as the inner sidebar (SidebarInside.NavItem) so both rails react identically.
"pointer-events-none flex w-full origin-center scale-100 items-center gap-2.5 rounded-md px-3 py-2 transition-[background-color,scale] duration-150 ease-[cubic-bezier(0.4,0,0.2,1)] will-change-[scale] motion-reduce:transition-none group-hover/2713e17b:scale-[1.065] data-[sidebar-sweep-hover=true]:scale-[1.065] group-hover/2713e17b:bg-surface-neutral-tertiary",
{
"w-52 flex-none group-active/2713e17b:w-full group-active/2713e17b:max-w-[208px] group-active/2713e17b:flex-none group-active/2713e17b:justify-end":
variant === "subitem",
"w-auto flex-none items-start justify-center px-2.5 py-2.5":
variant === "icon-only",
"bg-surface-neutral-tertiary group-hover/2713e17b:bg-surface-neutral-modal group-active/2713e17b:bg-surface-neutral-tertiary":
selected,
}
)}
data-slot="app-sidebar-nav-item-surface"
data-sidebar-hover-surface="true"
>
{icon ? (
<SubframeCore.IconWrapper className="inline-flex h-5 w-5 flex-none items-center justify-center leading-none text-body-large font-body-large text-icon-neutral-primary group-active/2713e17b:text-icon-neutral-on-subtle [&>svg]:h-full [&>svg]:w-full">
@@ -200,12 +204,20 @@ const NavDivider = React.forwardRef<HTMLDivElement, NavDividerProps>(
export interface SubcomponentProps
extends React.HTMLAttributes<HTMLDivElement> {
sidebarButton?: "close" | "open";
buttonLabel?: string;
onToggle?: () => void;
className?: string;
}
const Subcomponent = React.forwardRef<HTMLDivElement, SubcomponentProps>(
function Subcomponent(
{ sidebarButton = "close", className, ...otherProps }: SubcomponentProps,
{
sidebarButton = "close",
buttonLabel,
onToggle,
className,
...otherProps
}: SubcomponentProps,
ref
) {
return (
@@ -228,6 +240,8 @@ const Subcomponent = React.forwardRef<HTMLDivElement, SubcomponentProps>(
<FeatherSidebarClose />
)
}
aria-label={buttonLabel}
onClick={onToggle}
/>
</div>
);
@@ -242,6 +256,16 @@ export interface SidebarWithSectionsRootProps
className?: string;
// @subframe/sync-disable -- local fix: Collapse-Toggle verdrahtbar machen (App steuert open/closed).
onToggleCollapse?: () => void;
// @subframe/sync-disable -- local fix: native collapse button needs an accessible, translated name.
toggleLabel?: string;
// @subframe/sync-disable -- local fix: make the logo a link (click -> dashboard, same target as the Dashboard nav item).
logoHref?: string;
// @subframe/sync-disable -- logo navigation needs the caller's translated accessible name.
logoLabel?: string;
// @subframe/sync-disable -- branded surfaces can replace the default mark without forking the canonical sidebar.
logoContent?: React.ReactNode;
// @subframe/sync-disable -- callback-owned surfaces keep logo navigation client-side.
onLogoClick?: () => void;
}
const SidebarWithSectionsRoot = React.forwardRef<
@@ -254,26 +278,38 @@ const SidebarWithSectionsRoot = React.forwardRef<
children,
className,
onToggleCollapse,
toggleLabel,
logoHref,
logoLabel,
logoContent,
onLogoClick,
onPointerMove,
onPointerLeave,
...otherProps
}: SidebarWithSectionsRootProps,
ref
) {
const { handlePointerMove, handlePointerLeave } = useSidebarHoverSweep({ onPointerMove, onPointerLeave });
return (
<nav
className={SubframeUtils.twClassNames(
// @subframe/sync-disable -- local fix: animierbare Breite (w-16 statt w-auto) + smoother Collapse-Animation.
"group/f4047c8b flex h-full w-60 flex-col items-start rounded-l-md border-r border-solid border-border-default bg-surface-neutral-secondary relative transition-[width] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width]",
// @subframe/sync-disable -- local fix: explicit w-16 width and a smooth collapse transition.
"group/f4047c8b flex h-full w-60 shrink-0 flex-col items-start rounded-l-md border-r border-solid border-border-default bg-surface-neutral-secondary relative transition-[width] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width]",
{ "w-16": variant === "closed" },
className
)}
ref={ref}
onPointerMove={handlePointerMove}
onPointerLeave={handlePointerLeave}
{...otherProps}
>
{/* @subframe/sync-disable -- local fix: Collapse-Toggle verdrahtet (onClick -> onToggleCollapse) statt nur dekorativ. */}
<Subcomponent
className="absolute -right-[17px] top-[40px] z-40 cursor-pointer"
sidebarButton={variant === "closed" ? "open" : "close"}
onClick={onToggleCollapse}
buttonLabel={toggleLabel}
onToggle={onToggleCollapse}
/>
<div
className={SubframeUtils.twClassNames(
@@ -282,11 +318,41 @@ const SidebarWithSectionsRoot = React.forwardRef<
)}
>
<div className="flex items-center justify-center gap-2">
<Logo
size="32"
showIcon={variant === "closed" ? true : undefined}
hideText={variant === "closed" ? true : undefined}
/>
{/* @subframe/sync-disable -- local fix: logo links to the dashboard when logoHref is set (mirrors the Dashboard nav item). */}
{onLogoClick ? (
<button
type="button"
aria-label={logoLabel}
className="border-0 bg-transparent p-0"
onClick={onLogoClick}
>
{logoContent ?? (
<Logo
size="32"
showIcon={variant === "closed" ? true : undefined}
hideText={variant === "closed" ? true : undefined}
/>
)}
</button>
) : logoHref ? (
<a href={logoHref} aria-label={logoLabel} className="no-underline">
{logoContent ?? (
<Logo
size="32"
showIcon={variant === "closed" ? true : undefined}
hideText={variant === "closed" ? true : undefined}
/>
)}
</a>
) : (
logoContent ?? (
<Logo
size="32"
showIcon={variant === "closed" ? true : undefined}
hideText={variant === "closed" ? true : undefined}
/>
)
)}
</div>
</div>
{children ? (