Skip to content

Commit

Permalink
Grid controls design (#6489)
Browse files Browse the repository at this point in the history
Making some improvements to the visual design of canvas grid controls

- grid gap handles and canvas labels, are orange to match the orange
overlay pattern
- grid row/column resize handles are now labels with their width
(replacing the <-> arrows)
- grid row/column area names are now inside the highlight overlay when
being resized
- grid/row highlight is now a blue pattern instead of pink


![image](https://github.com/user-attachments/assets/7dd6256c-bfa9-4da1-93d1-a454fbc52c8a)

![image](https://github.com/user-attachments/assets/09fe10ed-0af5-469a-9a20-f208403f7033)

![image](https://github.com/user-attachments/assets/918ecc27-6d16-453a-a87d-edb90ecd6c89)

![image](https://github.com/user-attachments/assets/88de5103-0f81-4025-aa85-6b1caa94b80a)

---------

Co-authored-by: Balazs Bajorics <2226774+balazsbajorics@users.noreply.github.com>
  • Loading branch information
lankaukk and balazsbajorics authored Oct 9, 2024
1 parent 108b2c2 commit 4cdb407
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const setFlexGapStrategy: CanvasStrategyFactory = (
control: FloatingIndicator,
props: {
...props,
color: colorTheme.brandNeonPink.value,
color: colorTheme.brandNeonOrange.value,
},
key: 'padding-value-indicator-control',
show: 'visible-except-when-other-strategy-is-active',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const setGridGapStrategy: CanvasStrategyFactory = (
control: FloatingIndicator,
props: {
...maybeIndicatorProps,
color: colorTheme.brandNeonPink.value,
color: colorTheme.brandNeonOrange.value,
},
key: 'padding-value-indicator-control',
show: 'visible-except-when-other-strategy-is-active',
Expand Down
78 changes: 32 additions & 46 deletions editor/src/components/canvas/controls/grid-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,34 +254,22 @@ export const GridResizingControl = React.memo((props: GridResizingControlProps)
data-testid={labelId}
style={{
zoom: 1 / scale,
width: GRID_RESIZE_HANDLE_SIZE,
height: GRID_RESIZE_HANDLE_SIZE,
borderRadius: '100%',
border: `1px solid ${colorTheme.border0.value}`,
boxShadow: `${colorTheme.canvasControlsSizeBoxShadowColor50.value} 0px 0px
1px, ${colorTheme.canvasControlsSizeBoxShadowColor20.value} 0px 1px 2px 2px`,
background: colorTheme.white.value,
borderRadius: 3,
padding: '0 4px',
border: `.1px solid ${colorTheme.white.value}`,
background: colorTheme.primary.value,
color: colorTheme.white.value,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
cursor: gridEdgeToCSSCursor(props.axis === 'column' ? 'column-start' : 'row-start'),
fontSize: 8,
pointerEvents: 'initial',
}}
css={{
opacity: props.resizing !== 'not-resizing' ? 1 : 0.5,
':hover': {
opacity: 1,
},
}}
onMouseDown={mouseDownHandler}
onMouseMove={onMouseMove}
>
{props.axis === 'row' ? '↕' : '↔'}
{when(
props.dimension.areaName != null,
<span style={{ position: 'absolute', top: 12 }}>{props.dimension.areaName}</span>,
)}
{getLabelForAxis(props.dimension, props.dimensionIndex, props.fromPropsAxisValues)}
</div>
{when(
props.resizing !== 'not-resizing',
Expand All @@ -305,37 +293,34 @@ export const GridResizingControl = React.memo((props: GridResizingControlProps)
justifyContent: 'center',
border: `1px solid ${
props.resizeLocked
? colorTheme.brandNeonPink10.value
? colorTheme.primary10.value
: props.resizing === 'resize-target'
? colorTheme.brandNeonPink.value
: colorTheme.brandNeonPink60.value
? colorTheme.primary.value
: colorTheme.primary50.value
}`,
...(props.resizeLocked
? UtopiaStyles.backgrounds.stripedBackground(colorTheme.brandNeonPink10.value, scale)
? UtopiaStyles.backgrounds.stripedBackground(colorTheme.primary10.value, scale)
: props.resizing === 'resize-target'
? UtopiaStyles.backgrounds.stripedBackground(colorTheme.brandNeonPink60.value, scale)
: UtopiaStyles.backgrounds.stripedBackground(
colorTheme.brandNeonPink10.value,
scale,
)),
? UtopiaStyles.backgrounds.stripedBackground(colorTheme.primary50.value, scale)
: UtopiaStyles.backgrounds.stripedBackground(colorTheme.primary10.value, scale)),
}}
>
<CanvasLabel
value={getLabelForAxis(
props.dimension,
props.dimensionIndex,
props.fromPropsAxisValues,
)}
scale={scale}
color={
props.resizeLocked
? colorTheme.brandNeonPink10.value
: props.resizing === 'resize-target'
? colorTheme.brandNeonPink.value
: colorTheme.brandNeonPink60.value
}
textColor={colorTheme.white.value}
/>
{when(
props.dimension.areaName != null,
<div
style={{
position: 'absolute',
color: colorTheme.primary.value,
background: colorTheme.white.value,
top: 0,
left: 0,
padding: '0 4px',
borderRadius: '0 0 3px 0',
}}
>
{props.dimension.areaName}
</div>,
)}
</div>,
)}
</div>
Expand Down Expand Up @@ -948,15 +933,16 @@ export const GridControl = React.memo<GridControlProps>(({ grid }) => {
const countedColumn = Math.floor(cell % grid.columns) + 1
const id = gridCellTargetId(grid.elementPath, countedRow, countedColumn)
const borderID = `${id}-border`
const dotgridColor = activelyDraggingOrResizingCell != null ? `#00000033` : 'transparent'
const dotgridColor =
activelyDraggingOrResizingCell != null ? colorTheme.blackOpacity35.value : 'transparent'

const isActiveCell =
countedColumn === currentHoveredCell?.column && countedRow === currentHoveredCell?.row

const borderColor =
isActiveCell && targetsAreCellsWithPositioning
? colorTheme.brandNeonPink.value
: `#00000033`
: colorTheme.blackOpacity35.value
return (
<div
key={id}
Expand Down Expand Up @@ -1335,7 +1321,7 @@ const AbsoluteDistanceIndicators = React.memo(
return null
}

const backgroundColor = colorTheme.brandNeonPink.value
const backgroundColor = colorTheme.primary.value
const dashedBorder = `1px dashed ${backgroundColor}`

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ interface CanvasLabelProps {
scale: number
color: string
textColor: string
value: string | number
value: string | number | null
onMouseDown?: React.MouseEventHandler
testId?: string
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,15 @@ const GapControlSegment = React.memo<GapControlSegmentProps>((props) => {
<CanvasLabel
value={printCSSNumber(gapValue, null)}
scale={scale}
color={colorTheme.brandNeonPink.value}
color={colorTheme.brandNeonOrange.value}
textColor={colorTheme.white.value}
/>,
)}
</div>
<PillHandle
width={width}
height={height}
pillColor={colorTheme.brandNeonPink.value}
pillColor={colorTheme.brandNeonOrange.value}
borderWidth={borderWidth}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,15 @@ function GridGapHandle({
<CanvasLabel
value={printCSSNumber(gapValue, null)}
scale={scale}
color={colorTheme.brandNeonPink.value}
color={colorTheme.brandNeonOrange.value}
textColor={colorTheme.white.value}
/>,
)}
</div>
<PillHandle
width={width}
height={height}
pillColor={colorTheme.brandNeonPink.value}
pillColor={colorTheme.brandNeonOrange.value}
borderWidth={borderWidth}
/>
</div>
Expand Down
4 changes: 3 additions & 1 deletion editor/src/uuiui/styles/theme/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const darkBase = {
brandNeonPink10: createUtopiColor('oklch(78.64% 0.237 327.81 / 10%)'),
brandNeonPink60: createUtopiColor('oklch(78.64% 0.237 327.81 / 50%)'),
brandNeonGreen: createUtopiColor('oklch(86.6% 0.27 158.6)'),
brandNeonOrange: createUtopiColor('oklch(79% 0.19 70)'),
green: createUtopiColor('oklch(88% 0.2535 150)'),
green10: createUtopiColor('oklch(88% 0.2535 150 / 10%)'),
green20: createUtopiColor('oklch(88% 0.2535 150 / 20%)'),
Expand Down Expand Up @@ -133,6 +134,7 @@ const colorsWithOpacity = {
whiteOpacity20: createUtopiColor('oklch(100% 0 0 /20%)'),
whiteOpacity30: createUtopiColor('oklch(100% 0 0 /30%)'),
whiteOpacity35: createUtopiColor('oklch(100% 0 0 /35%)'),
blackOpacity35: createUtopiColor('oklch(0% 0 0 / 35%)'),
canvasControlsSizeBoxShadowColor20: createUtopiColor('rgba(255,255,255,0.20)'),
canvasControlsSizeBoxShadowColor50: createUtopiColor('rgba(255,255,255,0.5)'),
neutralInvertedBackground10: createUtopiColor('rgba(217, 220, 227, 0.1)'),
Expand Down Expand Up @@ -266,7 +268,7 @@ const darkTheme: typeof light = {
codeEditorGrid: createUtopiColor('#6d705b'),

// Gap controls
gapControlsBg: darkBase.brandNeonGreen,
gapControlsBg: darkBase.brandNeonOrange,
}

export const dark = enforceUtopiColorTheme(darkTheme)
4 changes: 3 additions & 1 deletion editor/src/uuiui/styles/theme/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const lightBase = {
brandNeonPink10: createUtopiColor('oklch(72.53% 0.353 331.69 / 10%)'),
brandNeonPink60: createUtopiColor('oklch(72.53% 0.353 331.69 / 30%)'),
brandNeonGreen: createUtopiColor('oklch(86.6% 0.27 158.6)'),
brandNeonOrange: createUtopiColor('oklch(79% 0.19 70)'),
green: createUtopiColor('oklch(64.6% 0.17 150.6)'),
green10: createUtopiColor('oklch(64.6% 0.17 150.6 / 10%)'),
green20: createUtopiColor('oklch(64.6% 0.17 150.6 / 20%)'),
Expand Down Expand Up @@ -134,6 +135,7 @@ const colorsWithOpacity = {
whiteOpacity20: createUtopiColor('oklch(100% 0 0 /20%)'),
whiteOpacity30: createUtopiColor('oklch(100% 0 0 /30%)'),
whiteOpacity35: createUtopiColor('oklch(100% 0 0 /35%)'),
blackOpacity35: createUtopiColor('oklch(0% 0 0 / 35%)'),
canvasControlsSizeBoxShadowColor20: createUtopiColor('rgba(0,0,0,0.20)'),
canvasControlsSizeBoxShadowColor50: createUtopiColor('rgba(0,0,0,0.5)'),
neutralInvertedBackground10: createUtopiColor('hsla(0,0%,0%,0.1)'),
Expand Down Expand Up @@ -266,7 +268,7 @@ const lightTheme = {
codeEditorGrid: createUtopiColor('#6d705b'),

// Gap controls
gapControlsBg: createUtopiColor('#FFA500'),
gapControlsBg: lightBase.brandNeonOrange,
}

// all values in light must be of the type UtopiColor! This will break if you made a mistake.
Expand Down

0 comments on commit 4cdb407

Please sign in to comment.