From 84a66a188c42aea3be9b0c37a9a6fe13fd6c701d Mon Sep 17 00:00:00 2001 From: Balazs Bajorics <2226774+balazsbajorics@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:46:26 +0200 Subject: [PATCH 1/2] basic label hover interaction --- .../canvas/controls/grid-controls.tsx | 91 +++++++++++-------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/editor/src/components/canvas/controls/grid-controls.tsx b/editor/src/components/canvas/controls/grid-controls.tsx index 0ca1c10c48db..38cb7d2ce7f4 100644 --- a/editor/src/components/canvas/controls/grid-controls.tsx +++ b/editor/src/components/canvas/controls/grid-controls.tsx @@ -126,6 +126,7 @@ interface GridResizingControlProps { setResizingIndex: (v: number | null) => void resizeLocked: boolean stripedAreaLength: number | null + labelsHovered: [boolean, React.Dispatch>] } const GridResizingControl = React.memo((props: GridResizingControlProps) => { @@ -211,6 +212,12 @@ const GridResizingControl = React.memo((props: GridResizingControlProps) => { [scale, props.padding], ) + const [labelsHovered, setLabelsHovered] = props.labelsHovered + + const onMouseOver = React.useCallback(() => { + setLabelsHovered(true) + }, [setLabelsHovered]) + return (
{ ? gridEdgeToCSSCursor(props.axis === 'column' ? 'column-start' : 'row-start') : 'default', pointerEvents: 'initial', + width: labelsHovered ? `calc-size(min-content, size)` : 10, // FIXME + overflow: 'hidden', + transition: 'width 0.2s ease', }} onMouseDown={mouseDownHandler} onMouseMove={onMouseMove} + onMouseOver={onMouseOver} > {getLabelForAxis(props.dimension, props.dimensionIndex, props.fromPropsAxisValues)}
@@ -314,6 +325,7 @@ interface GridResizingProps { padding: Sides | null justifyContent: string | null alignContent: string | null + labelsHovered: [boolean, React.Dispatch>] } const GridResizing = React.memo((props: GridResizingProps) => { @@ -440,6 +452,7 @@ const GridResizing = React.memo((props: GridResizingProps) => { ? props.padding.top ?? 0 : props.padding.left ?? 0 } + labelsHovered={props.labelsHovered} /> ) })} @@ -519,44 +532,50 @@ export const GridRowColumnResizingControlsComponent = ({ }) }, [scale, grids]) + const labelsHovered = React.useState(false) + return ( - {gridsWithVisibleResizeControls.flatMap((grid) => { - return ( - - ) - })} - {gridsWithVisibleResizeControls.flatMap((grid) => { - return ( - - ) - })} +
labelsHovered[1](false)}> + {gridsWithVisibleResizeControls.flatMap((grid) => { + return ( + + ) + })} + {gridsWithVisibleResizeControls.flatMap((grid) => { + return ( + + ) + })} +
) } From c40d2edca92f78af731f46aed916e36eb581d67d Mon Sep 17 00:00:00 2001 From: Balazs Bajorics <2226774+balazsbajorics@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:03:18 +0200 Subject: [PATCH 2/2] proto progress --- .../canvas/controls/grid-controls.tsx | 62 ++++++++++++------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/editor/src/components/canvas/controls/grid-controls.tsx b/editor/src/components/canvas/controls/grid-controls.tsx index 6b061a4a6a76..055b6413e673 100644 --- a/editor/src/components/canvas/controls/grid-controls.tsx +++ b/editor/src/components/canvas/controls/grid-controls.tsx @@ -232,31 +232,49 @@ const GridResizingControl = React.memo((props: GridResizingControlProps) => { }} >
- {getLabelForAxis(props.dimension, props.dimensionIndex, props.fromPropsAxisValues)} +
+ {!labelsHovered + ? '' + : getLabelForAxis(props.dimension, props.dimensionIndex, props.fromPropsAxisValues)} +
{when( props.resizing !== 'not-resizing',