diff --git a/libs/components/editor-blocks/src/blocks/grid/Grid.tsx b/libs/components/editor-blocks/src/blocks/grid/Grid.tsx index daaddfba5..77a83ff59 100644 --- a/libs/components/editor-blocks/src/blocks/grid/Grid.tsx +++ b/libs/components/editor-blocks/src/blocks/grid/Grid.tsx @@ -26,14 +26,14 @@ export const Grid: FC = function (props) { const { block, editor } = props; const [isOnDrag, setIsOnDrag] = useState(false); const isSetMouseUp = useRef(false); - const GridContainerRef = useRef(); + const gridContainerRef = useRef(); const mouseStartPoint = useRef(); const gridItemCountRef = useRef(); const originalLeftWidth = useRef(GRID_ITEM_MIN_WIDTH); const originalRightWidth = useRef(GRID_ITEM_MIN_WIDTH); const getLeftRightGridItemDomByIndex = (index: number) => { - const gridItems = Array.from(GridContainerRef.current?.children).filter( + const gridItems = Array.from(gridContainerRef.current?.children).filter( child => { return child.classList.contains(GRID_ITEM_CLASS_NAME); } @@ -138,14 +138,14 @@ export const Grid: FC = function (props) { leftGrid && rightGrid && mouseStartPoint.current && - GridContainerRef.current + gridContainerRef.current ) { const currentMousePoint = new Point(e.clientX, e.clientY); const totalWidth = Number(removePercent(leftGrid.style.width)) + Number(removePercent(rightGrid.style.width)); const containerWidth = domToRect( - GridContainerRef.current + gridContainerRef.current ).width; const xDistance = mouseStartPoint.current.xDistance(currentMousePoint); @@ -203,7 +203,8 @@ export const Grid: FC = function (props) { <> {children} @@ -214,17 +215,24 @@ export const Grid: FC = function (props) { ); }; -const GridContainer = styled('div')({ - position: 'relative', - display: 'flex', - alignItems: 'stretch', - borderRadius: '10px', - border: '1px solid #FFF', - minWidth: `${GRID_ITEM_MIN_WIDTH}%`, - [`&:hover .${GRID_ITEM_CONTENT_CLASS_NAME}`]: { - borderColor: '#E0E6EB', - }, -}); +const GridContainer = styled('div')<{ isOnDrag: boolean }>( + ({ isOnDrag, theme }) => ({ + position: 'relative', + display: 'flex', + alignItems: 'stretch', + borderRadius: '10px', + border: '1px solid #FFF', + minWidth: `${GRID_ITEM_MIN_WIDTH}%`, + [`&:hover .${GRID_ITEM_CONTENT_CLASS_NAME}`]: { + borderColor: theme.affine.palette.borderColor, + }, + ...(isOnDrag && { + [`& .${GRID_ITEM_CONTENT_CLASS_NAME}`]: { + borderColor: theme.affine.palette.borderColor, + }, + }), + }) +); const GridMask = styled('div')({ position: 'fixed',