Skip to content

Commit 08b5efb

Browse files
authored
ux imrovoements (#243)
1 parent a9db390 commit 08b5efb

23 files changed

+454
-400
lines changed

packages/react-grab/e2e/api-methods.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ test.describe("API Methods", () => {
212212
}) => {
213213
await reactGrab.updateOptions({ theme: { hue: 45 } });
214214
await reactGrab.updateOptions({
215-
theme: { crosshair: { enabled: false } },
215+
theme: { elementLabel: { enabled: false } },
216216
});
217217
await reactGrab.activate();
218218

packages/react-grab/e2e/event-callbacks.spec.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -361,23 +361,6 @@ test.describe("Event Callbacks", () => {
361361
expect(dragBoxCalls.length).toBeGreaterThan(0);
362362
});
363363

364-
test("onCrosshair should fire when crosshair moves", async ({
365-
reactGrab,
366-
}) => {
367-
await reactGrab.activate();
368-
await reactGrab.clearCallbackHistory();
369-
370-
await reactGrab.page.mouse.move(200, 200);
371-
await reactGrab.page.waitForTimeout(50);
372-
await reactGrab.page.mouse.move(300, 300);
373-
await reactGrab.page.waitForTimeout(100);
374-
375-
const history = await reactGrab.getCallbackHistory();
376-
const crosshairCalls = history.filter((c) => c.name === "onCrosshair");
377-
378-
expect(crosshairCalls.length).toBeGreaterThan(0);
379-
});
380-
381364
test("onGrabbedBox should fire when element is grabbed", async ({
382365
reactGrab,
383366
}) => {

packages/react-grab/e2e/fixtures.ts

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ interface ReactGrabState {
7070
labelInstances: LabelInstanceInfo[];
7171
}
7272

73-
interface CrosshairInfo {
74-
isVisible: boolean;
75-
position: { x: number; y: number } | null;
76-
}
77-
7873
interface GrabbedBoxInfo {
7974
count: number;
8075
boxes: Array<{
@@ -184,8 +179,6 @@ export interface ReactGrabPageObject {
184179
waitForSelectionLabel: () => Promise<void>;
185180
getLabelStatusText: () => Promise<string | null>;
186181

187-
getCrosshairInfo: () => Promise<CrosshairInfo>;
188-
isCrosshairVisible: () => Promise<boolean>;
189182
getGrabbedBoxInfo: () => Promise<GrabbedBoxInfo>;
190183
getLabelInstancesInfo: () => Promise<LabelInstanceInfo[]>;
191184
isGrabbedBoxVisible: () => Promise<boolean>;
@@ -1531,57 +1524,6 @@ const createReactGrabPageObject = (page: Page): ReactGrabPageObject => {
15311524
}, ATTRIBUTE_NAME);
15321525
};
15331526

1534-
const getCrosshairInfo = async (): Promise<CrosshairInfo> => {
1535-
return page.evaluate((attrName) => {
1536-
const host = document.querySelector(`[${attrName}]`);
1537-
const shadowRoot = host?.shadowRoot;
1538-
if (!shadowRoot) return { isVisible: false, position: null };
1539-
const root = shadowRoot.querySelector(`[${attrName}]`);
1540-
if (!root) return { isVisible: false, position: null };
1541-
1542-
const crosshairElements = Array.from(
1543-
root.querySelectorAll("div[style*='pointer-events: none']"),
1544-
);
1545-
for (let i = 0; i < crosshairElements.length; i++) {
1546-
const element = crosshairElements[i] as HTMLElement;
1547-
const style = element.style;
1548-
if (
1549-
style.position === "fixed" &&
1550-
(style.width === "1px" ||
1551-
style.height === "1px" ||
1552-
style.width === "100%" ||
1553-
style.height === "100%")
1554-
) {
1555-
const transform = style.transform;
1556-
const match = transform?.match(/translate\(([^,]+)px,\s*([^)]+)px\)/);
1557-
if (match) {
1558-
return {
1559-
isVisible: true,
1560-
position: { x: parseFloat(match[1]), y: parseFloat(match[2]) },
1561-
};
1562-
}
1563-
}
1564-
}
1565-
return { isVisible: false, position: null };
1566-
}, ATTRIBUTE_NAME);
1567-
};
1568-
1569-
const isCrosshairVisible = async (): Promise<boolean> => {
1570-
return page.evaluate(() => {
1571-
const api = (
1572-
window as {
1573-
__REACT_GRAB__?: {
1574-
getState: () => {
1575-
isCrosshairVisible: boolean;
1576-
};
1577-
};
1578-
}
1579-
).__REACT_GRAB__;
1580-
1581-
return api?.getState()?.isCrosshairVisible ?? false;
1582-
});
1583-
};
1584-
15851527
const getGrabbedBoxInfo = async (): Promise<GrabbedBoxInfo> => {
15861528
return page.evaluate(() => {
15871529
const api = (
@@ -1826,7 +1768,6 @@ const createReactGrabPageObject = (page: Page): ReactGrabPageObject => {
18261768
"onPromptModeChange",
18271769
"onSelectionBox",
18281770
"onDragBox",
1829-
"onCrosshair",
18301771
"onGrabbedBox",
18311772
"onContextMenu",
18321773
"onOpenFile",
@@ -2353,7 +2294,6 @@ const createReactGrabPageObject = (page: Page): ReactGrabPageObject => {
23532294
onPromptModeChange: trackCallback("onPromptModeChange"),
23542295
onSelectionBox: trackCallback("onSelectionBox"),
23552296
onDragBox: trackCallback("onDragBox"),
2356-
onCrosshair: trackCallback("onCrosshair"),
23572297
onGrabbedBox: trackCallback("onGrabbedBox"),
23582298
onContextMenu: trackCallback("onContextMenu"),
23592299
onOpenFile: trackCallback("onOpenFile"),
@@ -2496,8 +2436,6 @@ const createReactGrabPageObject = (page: Page): ReactGrabPageObject => {
24962436
waitForSelectionLabel,
24972437
getLabelStatusText,
24982438

2499-
getCrosshairInfo,
2500-
isCrosshairVisible,
25012439
getGrabbedBoxInfo,
25022440
getLabelInstancesInfo,
25032441
isGrabbedBoxVisible,

0 commit comments

Comments
 (0)