-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace FlexTrash with TrashBinFixture in configurator
- Loading branch information
1 parent
ae7701f
commit 3fd5d16
Showing
3 changed files
with
101 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
components/src/hardware-sim/DeckConfigurator/TrashBinFixture.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import * as React from 'react' | ||
|
||
import { | ||
getDeckDefFromRobotType, | ||
FLEX_ROBOT_TYPE, | ||
} from '@opentrons/shared-data' | ||
|
||
import { Icon } from '../../icons' | ||
import { Btn, Flex, Text } from '../../primitives' | ||
import { ALIGN_CENTER, DISPLAY_FLEX, JUSTIFY_CENTER } from '../../styles' | ||
import { BORDERS, COLORS, SPACING, TYPOGRAPHY } from '../../ui-style-constants' | ||
import { RobotCoordsForeignObject } from '../Deck/RobotCoordsForeignObject' | ||
|
||
// TODO: replace stubs with JSON definitions when available | ||
const trashBinDef = { | ||
schemaVersion: 1, | ||
version: 1, | ||
namespace: 'opentrons', | ||
metadata: { | ||
displayName: 'Trash bin', | ||
}, | ||
parameters: { | ||
loadName: 'trash_bin', | ||
}, | ||
boundingBox: { | ||
xDimension: 246.5, | ||
yDimension: 106.0, | ||
zDimension: 0, | ||
}, | ||
} | ||
|
||
interface TrashBinFixtureProps { | ||
fixtureLocation: string | ||
handleClickRemove?: (fixtureLocation: string) => void | ||
} | ||
|
||
export function TrashBinFixture(props: TrashBinFixtureProps): JSX.Element { | ||
const { handleClickRemove, fixtureLocation } = props | ||
const deckDef = getDeckDefFromRobotType(FLEX_ROBOT_TYPE) | ||
|
||
// TODO: migrate to fixture location for v4 | ||
const trashBinSlot = deckDef.locations.orderedSlots.find( | ||
slot => slot.id === fixtureLocation | ||
) | ||
const [xSlotPosition = 0, ySlotPosition = 0] = trashBinSlot?.position ?? [] | ||
// TODO: remove adjustment when reading from fixture position | ||
// adjust x differently for right side/left side | ||
const isLeftSideofDeck = | ||
fixtureLocation === 'A1' || | ||
fixtureLocation === 'B1' || | ||
fixtureLocation === 'C1' || | ||
fixtureLocation === 'D1' | ||
const xAdjustment = isLeftSideofDeck ? -101.5 : -17 | ||
const x = xSlotPosition + xAdjustment | ||
const yAdjustment = -10 | ||
const y = ySlotPosition + yAdjustment | ||
|
||
const { xDimension, yDimension } = trashBinDef.boundingBox | ||
|
||
return ( | ||
<RobotCoordsForeignObject | ||
width={xDimension} | ||
height={yDimension} | ||
x={x} | ||
y={y} | ||
flexProps={{ flex: '1' }} | ||
foreignObjectProps={{ flex: '1' }} | ||
> | ||
<Flex | ||
alignItems={ALIGN_CENTER} | ||
backgroundColor={COLORS.grey2} | ||
borderRadius={BORDERS.radiusSoftCorners} | ||
color={COLORS.white} | ||
gridGap={SPACING.spacing8} | ||
justifyContent={JUSTIFY_CENTER} | ||
width="100%" | ||
> | ||
{} | ||
<Text css={TYPOGRAPHY.bodyTextSemiBold}> | ||
{trashBinDef.metadata.displayName} | ||
</Text> | ||
{handleClickRemove != null ? ( | ||
<Btn | ||
display={DISPLAY_FLEX} | ||
justifyContent={JUSTIFY_CENTER} | ||
onClick={() => handleClickRemove(fixtureLocation)} | ||
> | ||
<Icon name="remove" color={COLORS.white} height="2.25rem" /> | ||
</Btn> | ||
) : null} | ||
</Flex> | ||
</RobotCoordsForeignObject> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters