Skip to content

Commit 3b3e87c

Browse files
refactor(components): Move SVG fudge to <svg> element (#18938)
## Overview Goes towards EXEC-1278. ## Changelog The SVG graphic of the Flex Stacker is not visually aligned with the underlying module geometry. We need to shift it slightly to compensate. Previously, we did that by fudging the whole `<Module>` component's position. One disadvantage to that approach is that all the callers of `<Module>` need to individually remember to special-case the stacker, and I suspect some of those callers did forget. Another disadvantage is that it doesn't compose well: the adjustment would apply to `<Labware>` inside the `<Module>`, but we want it to only apply to the SVG of the module itself. To solve both, this moves the adjustment onto the underlying `<svg>` element.
1 parent bccb83f commit 3b3e87c

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

app/src/molecules/ModuleInfo/ModuleInfo.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
RobotCoordsForeignObject,
1313
SPACING,
1414
STACKER_HOPPER_LABWARE_X_OFFSET,
15-
STACKER_HOPPER_LABWARE_Y_OFFSET,
1615
TYPOGRAPHY,
1716
} from '@opentrons/components'
1817
import {
@@ -67,11 +66,7 @@ export const ModuleInfo = (props: ModuleInfoProps): JSX.Element => {
6766
? STACKER_HOPPER_LABWARE_X_OFFSET
6867
: 0
6968
}
70-
y={
71-
moduleDef.moduleType === FLEX_STACKER_MODULE_TYPE
72-
? STACKER_HOPPER_LABWARE_Y_OFFSET
73-
: 0
74-
}
69+
y={0}
7570
height={labwareInterfaceYDimension ?? yDimension}
7671
width={labwareInterfaceXDimension ?? xDimension}
7772
flexProps={{

app/src/organisms/Desktop/Devices/ProtocolRun/SetupLabware/SetupLabwareMap.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
Flex,
88
SPACING,
99
STACKER_HOPPER_LABWARE_X_OFFSET,
10-
STACKER_HOPPER_LABWARE_Y_OFFSET,
1110
} from '@opentrons/components'
1211
import {
1312
FLEX_ROBOT_TYPE,
@@ -141,11 +140,6 @@ export function SetupLabwareMap({
141140
? STACKER_HOPPER_LABWARE_X_OFFSET
142141
: 0
143142
}
144-
yOffset={
145-
moduleType === FLEX_STACKER_MODULE_TYPE
146-
? STACKER_HOPPER_LABWARE_Y_OFFSET
147-
: 0
148-
}
149143
/>
150144
) : null}
151145
</g>

components/src/hardware-sim/BaseDeck/BaseDeck.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ export interface HopperLabwareProps {
8888

8989
// these ugly consts are unfortunately necessary as the hopper location exists
9090
// outside of our deck definition so the render doesn't follow our normal conventions
91-
export const STACKER_MODULE_Y_OFFSET = -6
9291
// todo(mm, 2025-07-16): 17.5 mm is a by-eye adjustment that takes us from a little bit
9392
// left of the hopper to inside the hopper. The fact that we were 17.5 mm left in the
9493
// first place is weird, and suggests we're doing wrong math somewhere. A more normal
9594
// thing to expect here would be starting at the extended shuttle position and needing
9695
// an offset of hundreds of mm to go from there to inside the hopper.
9796
export const STACKER_HOPPER_LABWARE_X_OFFSET = 17.5
98-
export const STACKER_HOPPER_LABWARE_Y_OFFSET = 6
9997
export const STACKER_DECK_VIEW_BOX_EXPANSION = 220
10098

10199
interface BaseDeckProps {
@@ -334,7 +332,7 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
334332
key={`${moduleModel} ${moduleLocation.slotName}`}
335333
def={moduleDef}
336334
x={slotPosition[0]}
337-
y={slotPosition[1] + STACKER_MODULE_Y_OFFSET}
335+
y={slotPosition[1]}
338336
orientation={inferModuleOrientationFromXCoordinate(
339337
slotPosition[0]
340338
)}
@@ -346,7 +344,7 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
346344
{nestedLabwareDef != null ? (
347345
<g
348346
cursor={onLabwareClick != null ? 'pointer' : ''}
349-
transform={`translate(${STACKER_HOPPER_LABWARE_X_OFFSET}, ${STACKER_HOPPER_LABWARE_Y_OFFSET})`}
347+
transform={`translate(${STACKER_HOPPER_LABWARE_X_OFFSET}, 0)`}
350348
>
351349
<LabwareRender
352350
definition={nestedLabwareDef}

components/src/hardware-sim/Module/FlexStacker.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
export function FlexStacker(): JSX.Element {
2+
// The given SVG is visually a little misaligned from where we expect it to be.
3+
// Translate it, by eye, to compensate.
4+
return (
5+
<g transform="translate(0, -6)">
6+
<UnadjustedSVG />
7+
</g>
8+
)
9+
}
10+
11+
// The unadjusted SVG, straight from design.
12+
function UnadjustedSVG(): JSX.Element {
213
return (
314
<svg
415
width="374"

0 commit comments

Comments
 (0)