Skip to content

Commit 92509de

Browse files
authored
refactor: rename short variable names to be descriptive (#251)
1 parent c681a62 commit 92509de

File tree

13 files changed

+55
-37
lines changed

13 files changed

+55
-37
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ E2E tests (`pnpm test` at root) run Playwright against the `e2e-playground` Vite
124124
### Key commands reference
125125

126126
See root `package.json` scripts and `CONTRIBUTING.md` for the full list. Quick reference:
127+
127128
- **Install**: `ni` (or `pnpm install`)
128129
- **Build**: `nr build` (or `pnpm build`)
129130
- **Dev watch**: `nr dev` (or `pnpm dev`) — watches core packages

packages/design-system/src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,7 +2572,6 @@ const StateCard = (props: StateCardProps) => {
25722572
visible={true}
25732573
status={currentProps().status}
25742574
hasAgent={currentProps().hasAgent}
2575-
25762575
isPromptMode={currentProps().isPromptMode}
25772576
inputValue={currentProps().inputValue}
25782577
replyToPrompt={currentProps().replyToPrompt}

packages/react-grab/e2e/fixtures.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ const createReactGrabPageObject = (page: Page): ReactGrabPageObject => {
352352
return new Promise<Record<string, string>>((resolve) => {
353353
const originalSetData = DataTransfer.prototype.setData;
354354
const clipboardWrites: Record<string, string> = {};
355-
DataTransfer.prototype.setData = function (type: string, value: string) {
355+
DataTransfer.prototype.setData = function (
356+
type: string,
357+
value: string,
358+
) {
356359
clipboardWrites[type] = value;
357360
return originalSetData.call(this, type, value);
358361
};

packages/react-grab/src/components/selection-label/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ export const SelectionLabel: Component<SelectionLabelProps> = (props) => {
192192
(previousResult: PositionResult): PositionResult => {
193193
viewportVersion();
194194
const currentElementIdentity = elementIdentity();
195-
const didReset = currentElementIdentity !== previousResult.elementIdentity;
195+
const didReset =
196+
currentElementIdentity !== previousResult.elementIdentity;
196197
const cached = didReset
197198
? {
198199
position: DEFAULT_OFFSCREEN_POSITION,

packages/react-grab/src/components/toolbar/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,10 @@ export const Toolbar: Component<ToolbarProps> = (props) => {
562562
let newRatio = positionRatio();
563563

564564
if (wasCollapsed) {
565-
const { position: newPos, ratio } =
566-
getExpandedFromCollapsed(currentPosition(), snapEdge());
565+
const { position: newPos, ratio } = getExpandedFromCollapsed(
566+
currentPosition(),
567+
snapEdge(),
568+
);
567569
newRatio = ratio;
568570
setPosition(newPos);
569571
setPositionRatio(newRatio);

packages/react-grab/src/components/toolbar/toolbar-menu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ export const ToolbarMenu: Component<ToolbarMenuProps> = (props) => {
9999
<For each={props.actions}>
100100
{(action) => {
101101
const isToggleAction = action.isActive !== undefined;
102-
const isActionEnabled = () => resolveToolbarActionEnabled(action);
102+
const isActionEnabled = () =>
103+
resolveToolbarActionEnabled(action);
103104
const isToggleActive = () => {
104105
void toggleRefreshCounter();
105106
return Boolean(action.isActive?.());

packages/react-grab/src/core/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ export const init = (rawOptions?: Options): ReactGrabAPI => {
236236
const didJustCopy = createMemo(() => store.current.state === "justCopied");
237237
const isPromptMode = createMemo(
238238
() =>
239-
store.current.state === "active" &&
240-
Boolean(store.current.isPromptMode),
239+
store.current.state === "active" && Boolean(store.current.isPromptMode),
241240
);
242241
const isCommentMode = createMemo(
243242
() => store.pendingCommentMode || isPromptMode(),
@@ -3143,7 +3142,9 @@ export const init = (rawOptions?: Options): ReactGrabAPI => {
31433142
if (!isThemeEnabled()) return [];
31443143
if (!pluginRegistry.store.theme.grabbedBoxes.enabled) return [];
31453144
void store.viewportVersion;
3146-
const currentIds = new Set(store.labelInstances.map((i) => i.id));
3145+
const currentIds = new Set(
3146+
store.labelInstances.map((instance) => instance.id),
3147+
);
31473148
for (const cachedId of labelInstanceCache.keys()) {
31483149
if (!currentIds.has(cachedId)) {
31493150
labelInstanceCache.delete(cachedId);

packages/react-grab/src/utils/create-anchored-dropdown.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export const createAnchoredDropdown = (
5454
};
5555

5656
const handleViewportChange = () => {
57-
setViewportVersion((previousViewportVersion) => previousViewportVersion + 1);
57+
setViewportVersion(
58+
(previousViewportVersion) => previousViewportVersion + 1,
59+
);
5860
measure();
5961
};
6062

@@ -93,8 +95,14 @@ export const createAnchoredDropdown = (
9395

9496
onCleanup(() => {
9597
window.removeEventListener("resize", handleViewportChange);
96-
window.visualViewport?.removeEventListener("resize", handleViewportChange);
97-
window.visualViewport?.removeEventListener("scroll", handleViewportChange);
98+
window.visualViewport?.removeEventListener(
99+
"resize",
100+
handleViewportChange,
101+
);
102+
window.visualViewport?.removeEventListener(
103+
"scroll",
104+
handleViewportChange,
105+
);
98106
});
99107
});
100108

packages/react-grab/src/utils/create-element-bounds.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,20 @@ export const createElementBounds = (element: Element): OverlayBounds => {
7979
let bounds: OverlayBounds;
8080

8181
if (transform !== "none" && element instanceof HTMLElement) {
82-
const ow = element.offsetWidth;
83-
const oh = element.offsetHeight;
82+
const offsetWidth = element.offsetWidth;
83+
const offsetHeight = element.offsetHeight;
8484

85-
if (ow > 0 && oh > 0) {
85+
if (offsetWidth > 0 && offsetHeight > 0) {
8686
const centerX = rect.left + rect.width * 0.5;
8787
const centerY = rect.top + rect.height * 0.5;
8888

8989
bounds = {
9090
borderRadius: style.borderRadius || "0px",
91-
height: oh,
91+
height: offsetHeight,
9292
transform,
93-
width: ow,
94-
x: centerX - ow * 0.5,
95-
y: centerY - oh * 0.5,
93+
width: offsetWidth,
94+
x: centerX - offsetWidth * 0.5,
95+
y: centerY - offsetHeight * 0.5,
9696
};
9797
} else {
9898
bounds = {

packages/react-grab/src/utils/create-toolbar-drag.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ interface ToolbarDragResult {
3333
isDragging: Accessor<boolean>;
3434
isSnapping: Accessor<boolean>;
3535
handlePointerDown: (event: PointerEvent) => void;
36-
createDragAwareHandler: (
37-
callback: () => void,
38-
) => (event: MouseEvent) => void;
36+
createDragAwareHandler: (callback: () => void) => (event: MouseEvent) => void;
3937
}
4038

41-
export const createToolbarDrag = (config: ToolbarDragConfig): ToolbarDragResult => {
39+
export const createToolbarDrag = (
40+
config: ToolbarDragConfig,
41+
): ToolbarDragResult => {
4242
const [isDragging, setIsDragging] = createSignal(false);
4343
const [isSnapping, setIsSnapping] = createSignal(false);
4444
const [hasDragMoved, setHasDragMoved] = createSignal(false);
@@ -69,10 +69,8 @@ export const createToolbarDrag = (config: ToolbarDragConfig): ToolbarDragResult
6969
const deltaTime = now - lastPointerPosition.time;
7070

7171
if (deltaTime > 0) {
72-
const newVelocityX =
73-
(event.clientX - lastPointerPosition.x) / deltaTime;
74-
const newVelocityY =
75-
(event.clientY - lastPointerPosition.y) / deltaTime;
72+
const newVelocityX = (event.clientX - lastPointerPosition.x) / deltaTime;
73+
const newVelocityY = (event.clientY - lastPointerPosition.y) / deltaTime;
7674
setVelocity({ x: newVelocityX, y: newVelocityY });
7775
}
7876

0 commit comments

Comments
 (0)