Skip to content

Commit

Permalink
Tweak design when resizing grid stretching items (#6718)
Browse files Browse the repository at this point in the history
**Problem:**

When resizing a stretching grid item there should be no blue translucent
overlay and the cursor should stay consistent during the interaction.

**Fix:**

Do that.

| Before | After |
|---------|--------------|
| ![Kapture 2024-12-10 at 13 18
45](https://github.com/user-attachments/assets/091ae790-ebab-4289-8345-45dd803c390d)
| ![Kapture 2024-12-10 at 13 17
39](https://github.com/user-attachments/assets/2a859957-8b80-4bf9-a062-5cf524930f44)
|

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Play mode

Fixes #6717
  • Loading branch information
ruggi authored Dec 10, 2024
1 parent 544461a commit e34fdc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
import { gridContainerIdentifier, gridItemIdentifier } from '../../../editor/store/editor-state'
import { cssKeyword } from '../../../inspector/common/css-utils'
import { isFillOrStretchModeAppliedOnAnySide } from '../../../inspector/inspector-common'
import { CSSCursor } from '../../canvas-types'
import { setCursorCommand } from '../../commands/set-cursor-command'
import {
controlsForGridPlaceholders,
gridEdgeToEdgePosition,
Expand Down Expand Up @@ -172,9 +174,18 @@ export const gridResizeElementStrategy: CanvasStrategyFactory = (
),
}

const cursor =
interactionSession.activeControl.edge === 'column-start' ||
interactionSession.activeControl.edge === 'column-end'
? CSSCursor.ColResize
: CSSCursor.RowResize

return strategyApplicationResult(
getCommandsForGridItemPlacement(selectedElement, gridTemplate, gridProps),
[EP.parentPath(selectedElement), selectedElement],
[
...getCommandsForGridItemPlacement(selectedElement, gridTemplate, gridProps),
setCursorCommand(cursor),
],
[(EP.parentPath(selectedElement), selectedElement)],
)
},
}
Expand Down
3 changes: 1 addition & 2 deletions editor/src/components/canvas/controls/grid-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,6 @@ interface GridResizeControlProps {

export const GridResizeControlsComponent = ({ target }: GridResizeControlProps) => {
const gridTarget = getGridIdentifierContainerOrComponentPath(target)
const colorTheme = useColorTheme()

const element = useEditorState(
Substores.metadata,
Expand Down Expand Up @@ -1854,7 +1853,7 @@ export const GridResizeControlsComponent = ({ target }: GridResizeControlProps)
left: bounds?.x ?? element.globalFrame.x,
width: bounds?.width ?? element.globalFrame.width,
height: bounds?.height ?? element.globalFrame.height,
backgroundColor: isResizing ? colorTheme.primary25.value : 'transparent',
backgroundColor: 'transparent',
}}
>
<div
Expand Down

0 comments on commit e34fdc3

Please sign in to comment.