From f02c187fc51df927dc04d299b5234709745e2dfd Mon Sep 17 00:00:00 2001 From: koji Date: Mon, 28 Oct 2024 14:13:50 -0400 Subject: [PATCH] fix(protocol-designer): fix deck view size issue in new pd fix deck view size issue in new pd close RQA- RQA- --- .../RobotCoordinateSpaceWithRef.tsx | 49 +++++++++++++++---- .../organisms/SlotDetailsContainer/index.tsx | 2 +- .../Designer/DeckSetup/DeckSetupContainer.tsx | 9 +++- .../src/pages/Designer/index.tsx | 2 +- .../pages/ProtocolOverview/DeckThumbnail.tsx | 12 ++++- 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/components/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpaceWithRef.tsx b/components/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpaceWithRef.tsx index c1986711ed2..156868d1a48 100644 --- a/components/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpaceWithRef.tsx +++ b/components/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpaceWithRef.tsx @@ -1,5 +1,6 @@ import * as React from 'react' -import { Svg } from '../../primitives' +import { css } from 'styled-components' +import { Flex, Svg } from '../../primitives' import type { DeckDefinition, DeckSlot } from '@opentrons/shared-data' export interface RobotCoordinateSpaceWithRefRenderProps { @@ -10,13 +11,14 @@ interface RobotCoordinateSpaceWithRefProps extends React.ComponentProps { viewBox?: string | null deckDef?: DeckDefinition + zoomed: boolean children?: (props: RobotCoordinateSpaceWithRefRenderProps) => React.ReactNode } export function RobotCoordinateSpaceWithRef( props: RobotCoordinateSpaceWithRefProps ): JSX.Element | null { - const { children, deckDef, viewBox, ...restProps } = props + const { children, deckDef, viewBox, zoomed, ...restProps } = props const wrapperRef = React.useRef(null) if (deckDef == null && viewBox == null) return null @@ -31,16 +33,43 @@ export function RobotCoordinateSpaceWithRef( (acc, deckSlot) => ({ ...acc, [deckSlot.id]: deckSlot }), {} ) - wholeDeckViewBox = `${viewBoxOriginX} ${viewBoxOriginY} ${deckXDimension} ${deckYDimension}` + + wholeDeckViewBox = `${viewBoxOriginX} ${-deckYDimension} ${deckXDimension} ${deckYDimension}` + + // wholeDeckViewBox = `${viewBoxOriginX} ${viewBoxOriginY} ${deckXDimension} ${deckYDimension}` + // Add padding to prevent clipping and better center the content + const padding = 20 + wholeDeckViewBox = `${viewBoxOriginX - padding} ${ + viewBoxOriginY - padding + } ${deckXDimension + padding * 2} ${deckYDimension + padding * 2}` + // Invert Y-axis by setting min-y to negative of deckYDimension } + console.log('wholeDeckViewBox', wholeDeckViewBox) + console.log('viewBox', viewBox) + console.log(viewBox || wholeDeckViewBox) return ( - - {children?.({ deckSlotsById })} - + + {children?.({ deckSlotsById })} + + ) } diff --git a/protocol-designer/src/organisms/SlotDetailsContainer/index.tsx b/protocol-designer/src/organisms/SlotDetailsContainer/index.tsx index 7e2d215cd31..bf0b29b9284 100644 --- a/protocol-designer/src/organisms/SlotDetailsContainer/index.tsx +++ b/protocol-designer/src/organisms/SlotDetailsContainer/index.tsx @@ -105,7 +105,7 @@ export function SlotDetailsContainer( return location.pathname === '/designer' && slot !== 'offDeck' ? ( diff --git a/protocol-designer/src/pages/Designer/DeckSetup/DeckSetupContainer.tsx b/protocol-designer/src/pages/Designer/DeckSetup/DeckSetupContainer.tsx index 20ad1307919..b84804a010b 100644 --- a/protocol-designer/src/pages/Designer/DeckSetup/DeckSetupContainer.tsx +++ b/protocol-designer/src/pages/Designer/DeckSetup/DeckSetupContainer.tsx @@ -1,5 +1,6 @@ import { useMemo, useState, Fragment } from 'react' import { useDispatch, useSelector } from 'react-redux' +import { css } from 'styled-components' import { ALIGN_CENTER, BORDERS, @@ -176,9 +177,12 @@ export function DeckSetupContainer(props: DeckSetupTabType): JSX.Element { backgroundColor={COLORS.white} borderRadius={BORDERS.borderRadius12} width="100%" - height={zoomIn.slot != null ? '75vh' : '65vh'} + height={zoomIn.slot != null ? '75vh' : '70vh'} flexDirection={DIRECTION_COLUMN} padding={SPACING.spacing40} + css={css` + outline: green solid 1px; + `} > {() => ( <> diff --git a/protocol-designer/src/pages/Designer/index.tsx b/protocol-designer/src/pages/Designer/index.tsx index 6dfd952ba97..f17ca343b0a 100644 --- a/protocol-designer/src/pages/Designer/index.tsx +++ b/protocol-designer/src/pages/Designer/index.tsx @@ -201,7 +201,7 @@ export function Designer(): JSX.Element { padding={zoomIn.slot != null ? '0' : SPACING.spacing80} height="calc(100vh - 64px)" > - + {zoomIn.slot == null ? (