Skip to content

Commit 82b379a

Browse files
committed
fix(protocol-designer): deck setup slot details responsiveness
closes RQA-3602 RQA-3327
1 parent 0110e17 commit 82b379a

File tree

9 files changed

+135
-165
lines changed

9 files changed

+135
-165
lines changed

components/src/atoms/ListItem/ListItemChildren/ListItemDescriptor.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Flex } from '../../../primitives'
22
import {
33
ALIGN_FLEX_START,
4+
DIRECTION_COLUMN,
45
DIRECTION_ROW,
6+
JUSTIFY_FLEX_START,
57
JUSTIFY_SPACE_BETWEEN,
68
} from '../../../styles'
79
import { SPACING } from '../../../ui-style-constants'
@@ -10,19 +12,27 @@ interface ListItemDescriptorProps {
1012
type: 'default' | 'large'
1113
description: JSX.Element
1214
content: JSX.Element
15+
changeFlexDirection?: boolean
1316
}
1417

1518
export const ListItemDescriptor = (
1619
props: ListItemDescriptorProps
1720
): JSX.Element => {
18-
const { description, content, type } = props
21+
const { description, content, type, changeFlexDirection = false } = props
22+
let justifyContent = 'none'
23+
if (type === 'default' && changeFlexDirection) {
24+
justifyContent = JUSTIFY_FLEX_START
25+
} else if (type === 'default') {
26+
justifyContent = JUSTIFY_SPACE_BETWEEN
27+
}
28+
1929
return (
2030
<Flex
21-
flexDirection={DIRECTION_ROW}
31+
flexDirection={changeFlexDirection ? DIRECTION_COLUMN : DIRECTION_ROW}
2232
gridGap={SPACING.spacing8}
2333
width="100%"
2434
alignItems={ALIGN_FLEX_START}
25-
justifyContent={type === 'default' ? JUSTIFY_SPACE_BETWEEN : 'none'}
35+
justifyContent={justifyContent}
2636
padding={type === 'default' ? SPACING.spacing4 : SPACING.spacing12}
2737
>
2838
{description}

components/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpaceWithRef.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,7 @@ export function RobotCoordinateSpaceWithRef(
3434
(acc, deckSlot) => ({ ...acc, [deckSlot.id]: deckSlot }),
3535
{}
3636
)
37-
38-
const PADDING = deckDef.otId === 'ot2_standard' ? 5 : 10
39-
if (deckDef.otId === 'ot2_standard') {
40-
wholeDeckViewBox = `${viewBoxOriginX - PADDING} ${
41-
viewBoxOriginY + PADDING * 5
42-
} ${deckXDimension + PADDING * 2} ${deckYDimension - PADDING * 10}`
43-
} else {
44-
wholeDeckViewBox = `${viewBoxOriginX + PADDING * 2} ${
45-
viewBoxOriginY - PADDING
46-
} ${deckXDimension + PADDING * 4} ${deckYDimension + PADDING * 3}`
47-
}
37+
wholeDeckViewBox = `${viewBoxOriginX} ${viewBoxOriginY} ${deckXDimension} ${deckYDimension}`
4838
}
4939

5040
return (

protocol-designer/src/organisms/SlotDetailsContainer/__tests__/utils.test.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

protocol-designer/src/organisms/SlotDetailsContainer/index.tsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import { useLocation } from 'react-router-dom'
21
import { useSelector } from 'react-redux'
32
import { useTranslation } from 'react-i18next'
43
import { getModuleDisplayName } from '@opentrons/shared-data'
5-
import { RobotCoordsForeignObject } from '@opentrons/components'
64
import * as wellContentsSelectors from '../../top-selectors/well-contents'
7-
import { getAdditionalEquipmentEntities } from '../../step-forms/selectors'
85
import { selectors } from '../../labware-ingred/selectors'
96
import { selectors as uiLabwareSelectors } from '../../ui/labware'
107
import { getDeckSetupForActiveItem } from '../../top-selectors/labware-locations'
118
import { SlotInformation } from '../../organisms/SlotInformation'
12-
import { getXPosition } from './utils'
139

1410
import type { DeckSlotId, RobotType } from '@opentrons/shared-data'
1511
import type { ContentsByWell } from '../../labware-ingred/types'
1612

17-
const SLOT_DETAIL_Y_POSITION = '-10'
1813
interface SlotDetailContainerProps {
1914
robotType: RobotType
2015
slot: DeckSlotId | null
@@ -26,17 +21,12 @@ export function SlotDetailsContainer(
2621
): JSX.Element | null {
2722
const { robotType, slot, offDeckLabwareId } = props
2823
const { t } = useTranslation('shared')
29-
const location = useLocation()
3024
const deckSetup = useSelector(getDeckSetupForActiveItem)
3125
const allWellContentsForActiveItem = useSelector(
3226
wellContentsSelectors.getAllWellContentsForActiveItem
3327
)
3428
const nickNames = useSelector(uiLabwareSelectors.getLabwareNicknamesById)
3529
const allIngredNamesIds = useSelector(selectors.allIngredientNamesIds)
36-
const additionalEquipment = useSelector(getAdditionalEquipmentEntities)
37-
const hasStagingArea = Object.values(additionalEquipment).some(
38-
item => item.name === 'stagingArea'
39-
)
4030

4131
if (slot == null || (slot === 'offDeck' && offDeckLabwareId == null)) {
4232
return null
@@ -108,24 +98,7 @@ export function SlotDetailsContainer(
10898
}
10999
}
110100

111-
return location.pathname === '/designer' && slot !== 'offDeck' ? (
112-
<RobotCoordsForeignObject
113-
width="15.8125rem"
114-
height="26.75rem"
115-
x={getXPosition(slot, robotType, hasStagingArea)}
116-
y={SLOT_DETAIL_Y_POSITION}
117-
>
118-
<SlotInformation
119-
location={slot}
120-
robotType={robotType}
121-
modules={moduleDisplayName != null ? [moduleDisplayName] : []}
122-
labwares={labwares}
123-
fixtures={fixtureDisplayNames}
124-
liquids={liquidNamesOnLabware}
125-
adapters={adapters}
126-
/>
127-
</RobotCoordsForeignObject>
128-
) : (
101+
return (
129102
<SlotInformation
130103
location={slot}
131104
robotType={robotType}

protocol-designer/src/organisms/SlotDetailsContainer/utils.ts

Lines changed: 0 additions & 82 deletions
This file was deleted.

protocol-designer/src/organisms/SlotInformation/index.tsx

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ import {
1212
StyledText,
1313
TYPOGRAPHY,
1414
} from '@opentrons/components'
15-
import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data'
15+
import {
16+
FLEX_ROBOT_TYPE,
17+
getModuleDisplayName,
18+
OT2_ROBOT_TYPE,
19+
THERMOCYCLER_MODULE_V1,
20+
THERMOCYCLER_MODULE_V2,
21+
} from '@opentrons/shared-data'
1622
import { LINE_CLAMP_TEXT_STYLE } from '../../atoms'
23+
import { useDeckSetupWindowBreakPoint } from '../../pages/Designer/DeckSetup/utils'
1724

1825
import type { FC } from 'react'
1926
import type { RobotType } from '@opentrons/shared-data'
@@ -38,15 +45,32 @@ export const SlotInformation: FC<SlotInformationProps> = ({
3845
fixtures = [],
3946
}) => {
4047
const { t } = useTranslation('shared')
48+
const breakPointSize = useDeckSetupWindowBreakPoint()
49+
const pathLocation = useLocation()
4150
const isOffDeck = location === 'offDeck'
51+
let modifiedLocation = location
52+
if (
53+
robotType === FLEX_ROBOT_TYPE &&
54+
modules.includes(getModuleDisplayName(THERMOCYCLER_MODULE_V2))
55+
) {
56+
modifiedLocation = 'A1+B1'
57+
} else if (
58+
robotType === OT2_ROBOT_TYPE &&
59+
(modules.includes(getModuleDisplayName(THERMOCYCLER_MODULE_V2)) ||
60+
modules.includes(getModuleDisplayName(THERMOCYCLER_MODULE_V1)))
61+
) {
62+
modifiedLocation = '7,8,10,11'
63+
}
64+
4265
return (
4366
<Flex
4467
flexDirection={DIRECTION_COLUMN}
4568
gridGap={SPACING.spacing12}
69+
maxWidth={pathLocation.pathname === '/designer' ? '23.4375rem' : '100%'}
4670
width="100%"
4771
>
4872
<Flex gridGap={SPACING.spacing8} alignItems={ALIGN_CENTER}>
49-
{isOffDeck ? null : <DeckInfoLabel deckLabel={location} />}
73+
{isOffDeck ? null : <DeckInfoLabel deckLabel={modifiedLocation} />}
5074
<StyledText desktopStyle="bodyLargeSemiBold">
5175
{t(isOffDeck ? 'labware_detail' : 'slot_detail')}
5276
</StyledText>
@@ -55,11 +79,16 @@ export const SlotInformation: FC<SlotInformationProps> = ({
5579
{liquids.length > 1 ? (
5680
<ListItem type="noActive" width="max-content">
5781
<ListItemDescriptor
82+
changeFlexDirection={breakPointSize === 'medium'}
5883
type="default"
5984
content={
6085
<StyledText
6186
desktopStyle="bodyDefaultRegular"
62-
textAlign={TYPOGRAPHY.textAlignRight}
87+
textAlign={
88+
breakPointSize === 'medium'
89+
? TYPOGRAPHY.textAlignLeft
90+
: TYPOGRAPHY.textAlignRight
91+
}
6392
css={LINE_CLAMP_TEXT_STYLE(2)}
6493
>
6594
{liquids.join(', ')}
@@ -92,11 +121,10 @@ interface StackInfoListProps {
92121
}
93122

94123
function StackInfoList({ title, items }: StackInfoListProps): JSX.Element {
95-
const pathLocation = useLocation()
96124
return (
97125
<Flex
98126
flexDirection={DIRECTION_COLUMN}
99-
width={pathLocation.pathname === '/designer' ? '15.8125rem' : '100%'}
127+
width="100%"
100128
gridGap={SPACING.spacing4}
101129
>
102130
{items.length > 0 ? (
@@ -121,20 +149,27 @@ interface StackInfoProps {
121149

122150
function StackInfo({ title, stackInformation }: StackInfoProps): JSX.Element {
123151
const { t } = useTranslation('shared')
152+
const breakPointSize = useDeckSetupWindowBreakPoint()
153+
124154
return (
125155
<ListItem type="noActive">
126156
<ListItemDescriptor
157+
changeFlexDirection={breakPointSize === 'medium'}
127158
type="default"
128159
content={
129160
<StyledText
130161
desktopStyle="bodyDefaultRegular"
131-
textAlign={TYPOGRAPHY.textAlignRight}
162+
textAlign={
163+
breakPointSize === 'medium'
164+
? TYPOGRAPHY.textAlignLeft
165+
: TYPOGRAPHY.textAlignRight
166+
}
132167
>
133168
{stackInformation ?? t('none')}
134169
</StyledText>
135170
}
136171
description={
137-
<Flex width="7.40625rem">
172+
<Flex>
138173
<StyledText desktopStyle="bodyDefaultRegular" color={COLORS.grey60}>
139174
{title}
140175
</StyledText>

0 commit comments

Comments
 (0)