Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app,components): add stacked badge to protocol setup labware maps #15925

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export function SetupLabwareMap({
labwareStackDetailsLabwareId,
setLabwareStackDetailsLabwareId,
] = React.useState<string | null>(null)
const [hoverLabwareId, setHoverLabwareId] = React.useState<string | null>(
null
)

if (protocolAnalysis == null) return null

Expand Down Expand Up @@ -81,14 +84,27 @@ export function SetupLabwareMap({
: {},

nestedLabwareDef: topLabwareDefinition,
highlightLabware:
topLabwareDefinition != null &&
topLabwareId != null &&
hoverLabwareId === topLabwareId,
stacked: topLabwareDefinition != null && topLabwareId != null,
moduleChildren: (
// open modal
<g
onClick={() => {
if (topLabwareDefinition != null) {
if (topLabwareDefinition != null && topLabwareId != null) {
setLabwareStackDetailsLabwareId(topLabwareId)
}
}}
onMouseEnter={() => {
if (topLabwareDefinition != null && topLabwareId != null) {
setHoverLabwareId(topLabwareId)
}
}}
onMouseLeave={() => {
setHoverLabwareId(null)
}}
cursor="pointer"
>
{topLabwareDefinition != null && topLabwareId != null ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function LabwareMapView(props: LabwareMapViewProps): JSX.Element {
: undefined,
highlightLabware: true,
moduleChildren: null,
stacked: topLabwareDefinition != null && topLabwareId != null,
}
})

Expand Down
21 changes: 21 additions & 0 deletions components/src/hardware-sim/BaseDeck/BaseDeck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import {
STAGING_AREA_SLOT_WITH_MAGNETIC_BLOCK_V1_FIXTURE,
} from '@opentrons/shared-data'

import { DeckInfoLabel } from '../../molecules/DeckInfoLabel'
import { RobotCoordinateSpace } from '../RobotCoordinateSpace'
import { Module } from '../Module'
import { LabwareRender } from '../Labware'
import { FlexTrash } from '../Deck/FlexTrash'
import { DeckFromLayers } from '../Deck/DeckFromLayers'
import { RobotCoordsForeignObject } from '../Deck/RobotCoordsForeignObject'
import { SlotLabels } from '../Deck'
import { COLORS } from '../../helix-design-system'

Expand Down Expand Up @@ -55,6 +57,7 @@ export interface LabwareOnDeck {
labwareChildren?: React.ReactNode
onLabwareClick?: () => void
highlight?: boolean
stacked?: boolean
}

export interface ModuleOnDeck {
Expand All @@ -67,6 +70,7 @@ export interface ModuleOnDeck {
moduleChildren?: React.ReactNode
onLabwareClick?: () => void
highlightLabware?: boolean
stacked?: boolean
}
interface BaseDeckProps {
deckConfig: DeckConfiguration
Expand Down Expand Up @@ -243,6 +247,7 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
moduleChildren,
onLabwareClick,
highlightLabware,
stacked = false,
}) => {
const slotPosition = getPositionFromSlotId(
moduleLocation.slotName,
Expand Down Expand Up @@ -273,6 +278,7 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
/>
) : null}
{moduleChildren}
{stacked ? <StackedBadge /> : null}
</Module>
) : null
}
Expand All @@ -286,6 +292,7 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
missingTips,
onLabwareClick,
highlight,
stacked = false,
}) => {
if (
labwareLocation === 'offDeck' ||
Expand Down Expand Up @@ -316,6 +323,7 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
highlight={highlight}
/>
{labwareChildren}
{stacked ? <StackedBadge /> : null}
</g>
) : null
}
Expand All @@ -325,3 +333,16 @@ export function BaseDeck(props: BaseDeckProps): JSX.Element {
</RobotCoordinateSpace>
)
}

function StackedBadge(): JSX.Element {
return (
<RobotCoordsForeignObject height="2.5rem" width="2.5rem" x={113} y={53}>
<DeckInfoLabel
height="1.25rem"
svgSize="0.875rem"
highlight
iconName="stacked"
/>
</RobotCoordsForeignObject>
)
}
9 changes: 5 additions & 4 deletions components/src/molecules/DeckInfoLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface HardwareIconProps extends StyleProps {
// type union requires one of deckLabel or iconName, but not both
export type DeckInfoLabelProps = (DeckLabelProps | HardwareIconProps) & {
highlight?: boolean
svgSize?: string | number
}

export const DeckInfoLabel = styled(DeckInfoLabelComponent)`
Expand All @@ -42,8 +43,8 @@ export const DeckInfoLabel = styled(DeckInfoLabelComponent)`
props.height ?? SPACING.spacing20}; // prevents the icon from being squished

> svg {
height: 0.875rem;
width: 0.875rem;
height: ${props => props.svgSize ?? '0.875rem'};
width: ${props => props.svgSize ?? '0.875rem'};
}

@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} {
Expand All @@ -53,8 +54,8 @@ export const DeckInfoLabel = styled(DeckInfoLabelComponent)`
${props =>
props.deckLabel != null ? SPACING.spacing8 : SPACING.spacing6};
> svg {
height: 1.25rem;
width: 1.25rem;
height: ${props => props.svgSize ?? '1.25rem'};
width: ${props => props.svgSize ?? '1.25rem'};
}
}
`
Expand Down
Loading