@noya-app/noya-designsystem 0.1.87 → 0.1.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ import { afterEach, describe, expect, test } from "bun:test";
2
+ import { cleanup, render } from "@testing-library/react";
3
+ import React from "react";
4
+ import { cssVarNames } from "../../theme";
5
+ import { AppToolbar } from "../AppToolbar";
6
+ import { Toolbar } from "../Toolbar";
7
+
8
+ afterEach(cleanup);
9
+
10
+ describe("Toolbar", () => {
11
+ test("renders the floating toolbar surface with transparent controls", () => {
12
+ const { getByRole } = render(
13
+ <Toolbar aria-label="Canvas tools">Controls</Toolbar>
14
+ );
15
+ const toolbar = getByRole("toolbar", { name: "Canvas tools" });
16
+
17
+ expect(toolbar.classList.contains("n-bg-popover-background")).toBe(true);
18
+ expect(toolbar.classList.contains("n-shadow-popover")).toBe(true);
19
+ expect(toolbar.classList.contains("n-gap-toolbar-separator")).toBe(true);
20
+ expect(toolbar.classList.contains("n-p-2")).toBe(true);
21
+ expect(
22
+ toolbar.style.getPropertyValue(cssVarNames.colors.buttonBackground)
23
+ ).toBe("transparent");
24
+ expect(
25
+ toolbar.style.getPropertyValue(cssVarNames.colors.inputBackground)
26
+ ).toBe("transparent");
27
+ });
28
+
29
+ test("supports compact spacing and consumer style overrides", () => {
30
+ const { getByRole } = render(
31
+ <Toolbar
32
+ aria-label="Selection tools"
33
+ size="small"
34
+ style={{ backgroundColor: "transparent" }}
35
+ />
36
+ );
37
+ const toolbar = getByRole("toolbar", { name: "Selection tools" });
38
+
39
+ expect(toolbar.classList.contains("n-gap-1")).toBe(true);
40
+ expect(toolbar.classList.contains("n-p-1")).toBe(true);
41
+ expect(toolbar.style.backgroundColor).toBe("transparent");
42
+ });
43
+ });
44
+
45
+ describe("AppToolbar", () => {
46
+ test("renders menu-driven application actions", () => {
47
+ const { getByRole } = render(
48
+ <AppToolbar
49
+ leftMenuItems={[{ title: "Undo", value: "undo" }]}
50
+ shouldBindKeyboardShortcuts={false}
51
+ />
52
+ );
53
+
54
+ expect(getByRole("button", { name: "Undo" })).toBeTruthy();
55
+ });
56
+ });
@@ -12,6 +12,7 @@ import {
12
12
  DragStartEvent,
13
13
  Over,
14
14
  PointerSensor,
15
+ PointerSensorProps,
15
16
  pointerWithin,
16
17
  useSensor,
17
18
  useSensors,
@@ -54,6 +55,41 @@ export type SharedDragProviderProps = {
54
55
  itemHitSlop?: Insets;
55
56
  };
56
57
 
58
+ export class ContinuousPointerSensor extends PointerSensor {
59
+ constructor(props: PointerSensorProps) {
60
+ const ownerDocument =
61
+ props.event.target instanceof Node
62
+ ? (props.event.target.ownerDocument ?? document)
63
+ : document;
64
+ let latestCoordinates: Point | null = null;
65
+
66
+ const trackPointer = (event: PointerEvent) => {
67
+ latestCoordinates = { x: event.clientX, y: event.clientY };
68
+ };
69
+ const cleanup = () => {
70
+ ownerDocument.removeEventListener("pointermove", trackPointer, true);
71
+ ownerDocument.removeEventListener("pointerup", cleanup, true);
72
+ ownerDocument.removeEventListener("pointercancel", cleanup, true);
73
+ };
74
+
75
+ ownerDocument.addEventListener("pointermove", trackPointer, true);
76
+ ownerDocument.addEventListener("pointerup", cleanup, true);
77
+ ownerDocument.addEventListener("pointercancel", cleanup, true);
78
+
79
+ super({
80
+ ...props,
81
+ onStart(coordinates) {
82
+ cleanup();
83
+ props.onStart(coordinates);
84
+
85
+ if (latestCoordinates) {
86
+ props.onMove(latestCoordinates);
87
+ }
88
+ },
89
+ });
90
+ }
91
+ }
92
+
57
93
  export function SharedDragProvider({
58
94
  children,
59
95
  acceptsDrop,
@@ -65,7 +101,7 @@ export function SharedDragProvider({
65
101
  itemHitSlop,
66
102
  }: SharedDragProviderProps) {
67
103
  const sensors = useSensors(
68
- useSensor(PointerSensor, {
104
+ useSensor(ContinuousPointerSensor, {
69
105
  activationConstraint: {
70
106
  distance: 4,
71
107
  },
@@ -6,7 +6,7 @@ import { cssVarNames } from "../../theme";
6
6
  import { Button } from "../Button";
7
7
  import { Divider } from "../Divider";
8
8
  import { isSelectableMenuItem, MenuItem } from "../internal/Menu";
9
- import { ToolbarMenu } from "../Toolbar";
9
+ import { ToolbarMenu } from "../AppToolbar";
10
10
  import { EDITOR_PANEL_GROUP_ID } from "./constants";
11
11
  import { LayoutProps, PanelLayoutState } from "./types";
12
12
 
@@ -216,7 +216,7 @@ export const DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout<
216
216
  )}
217
217
 
218
218
  {/* Center content */}
219
- <div className="n-flex-1 n-flex n-relative n-min-h-0">
219
+ <div className="n-z-0 n-flex-1 n-flex n-relative n-min-h-0">
220
220
  {centerPanel}
221
221
  </div>
222
222
  </div>
@@ -2,7 +2,7 @@ import { memoGeneric } from "@noya-app/react-utils";
2
2
  import React, { ComponentProps, useMemo } from "react";
3
3
  import { cssVarNames } from "../../theme";
4
4
  import { MenuItem } from "../internal/Menu";
5
- import { ToolbarMenu } from "../Toolbar";
5
+ import { ToolbarMenu } from "../AppToolbar";
6
6
  import { Tooltip } from "../Tooltip";
7
7
 
8
8
  type VerticalTabMenuProps<TabValue extends string> = {
@@ -83,12 +83,14 @@ describe("DrawerWorkspaceLayout", () => {
83
83
  fireEvent.click(getByRole("button", { name: "Navigation" }));
84
84
  const action = getByRole("button", { name: "Drawer action" });
85
85
  const drawer = getByText("Drawer action").parentElement?.parentElement;
86
+ const center = getByText("Center content").parentElement;
86
87
 
87
88
  fireEvent.pointerDown(action, { pointerType: "touch" });
88
89
  fireEvent.pointerUp(action, { pointerType: "touch" });
89
90
  fireEvent.click(action);
90
91
 
91
92
  expect(drawer?.classList.contains("n-z-20")).toBe(true);
93
+ expect(center?.classList.contains("n-z-0")).toBe(true);
92
94
  expect(queryByRole("button", { name: "Close drawer" })).toBeNull();
93
95
  expect(touchCount).toBe(1);
94
96
  expect(leftSidebarRef.current?.isExpanded()).toBe(true);
package/src/index.css CHANGED
@@ -185,6 +185,12 @@
185
185
  }
186
186
  }
187
187
 
188
+ @media (max-width: 639px) {
189
+ :root {
190
+ --n-dialog-padding: 16px;
191
+ }
192
+ }
193
+
188
194
  [data-theme="dark"] {
189
195
  --n-background: #111111;
190
196
  --n-input-background: rgb(45 43 54);
package/src/index.tsx CHANGED
@@ -10,6 +10,7 @@ export * from "./components/Banner";
10
10
  export * from "./components/blocks/ImageBlockComponent";
11
11
  export * from "./components/Breadcrumbs";
12
12
  export * from "./components/Button";
13
+ export * from "./components/Card";
13
14
  export * from "./components/Checkbox";
14
15
  export * from "./components/Chip";
15
16
  export * from "./components/Collection";
@@ -21,6 +22,7 @@ export * from "./components/CommandPalette";
21
22
  export * from "./components/connected-users-menu/ConnectedUsersMenuLayout";
22
23
  export * from "./components/ContextMenu";
23
24
  export * from "./components/Dialog";
25
+ export * from "./components/DialogNavigator";
24
26
  export * from "./components/Divider";
25
27
  export * from "./components/DraggableMenuButton";
26
28
  export * from "./components/Drawer";
@@ -75,6 +77,7 @@ export * from "./components/sorting/Sortable";
75
77
  export * from "./components/sorting/sorting";
76
78
  export * from "./components/Spacer";
77
79
  export * from "./components/StackNavigator";
80
+ export * from "./components/StatCard";
78
81
  export * from "./components/Stepper";
79
82
  export * from "./components/Switch";
80
83
  export * from "./components/Tabs";
@@ -128,6 +131,7 @@ export * from "./components/DimensionInput";
128
131
  export * as InspectorPrimitives from "./components/InspectorPrimitives";
129
132
 
130
133
  export * from "./components/BaseToolbar";
134
+ export * from "./components/AppToolbar";
131
135
  export * from "./components/OverlayToolbar";
132
136
  export * from "./components/Toolbar";
133
137
  export * from "./components/ToolbarDrawer";