Skip to content

Commit

Permalink
fix(components,-protocol-designer): fix order and border radius logic…
Browse files Browse the repository at this point in the history
… for DeckLabelSet (#17230)

This PR updates the order in which elements of a module/adapter/labware
stack are displayed. The correct order should be top-down, reflecting
the physical orientation of the elements on the deck. Also, this PR
fixes the border radii of each label in the set according to designs.

Closes RQA-3736
  • Loading branch information
ncdiehl11 authored Jan 14, 2025
1 parent 573c669 commit 18f9fb4
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
8 changes: 4 additions & 4 deletions components/src/organisms/DeckLabelSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ const StyledBox = styled(Box)<StyledBoxProps>`

const LabelContainer = styled.div`
padding-left: ${SPACING.spacing12};
& > *:not(:first-child):not(:last-child) {
& > *:first-child {
border-bottom-right-radius: ${BORDERS.borderRadius4};
border-top-right-radius: ${BORDERS.borderRadius4};
}
& > *:first-child {
& > *:not(:first-child) {
border-top-right-radius: ${BORDERS.borderRadius4};
border-bottom-right-radius: ${BORDERS.borderRadius4};
}
& > *:last-child {
border-bottom-left-radius: ${BORDERS.borderRadius4};
border-bottom-right-radius: ${BORDERS.borderRadius4};
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ export const ModuleLabel = (props: ModuleLabelProps): JSX.Element => {
<DeckLabelSet
ref={labelContainerRef}
deckLabels={[
...labwareInfos,
{
text: labelName ?? def?.displayName,
isSelected,
isLast,
moduleModel: def?.model,
isZoomed: isZoomed,
},
...labwareInfos,
]}
x={
position[0] +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,20 @@ export const SelectedHoveredItems = (
const labwareInfos: DeckLabelProps[] = []

if (
selectedLabwareDefUri != null &&
(hoveredLabware == null || hoveredLabware !== selectedLabwareDefUri)
(hoveredLabware != null ||
selectedLabwareDefUri === hoveredLabware ||
selectedNestedLabwareDefUri === hoveredLabware) &&
hoveredLabwareDef != null
) {
const def =
defs[selectedLabwareDefUri] ?? customLabwareDefs[selectedLabwareDefUri]
const selectedLabwareLabel = {
text: def.metadata.displayName,
isSelected: true,
isLast: hoveredLabware == null && selectedNestedLabwareDefUri == null,
const hoverlLabwareLabel = {
text: hoveredLabwareDef.metadata.displayName,
isSelected: false,
isLast: true,
isZoomed: true,
}
labwareInfos.push(selectedLabwareLabel)
labwareInfos.push(hoverlLabwareLabel)
}

if (selectedNestedLabwareDef != null && hoveredLabware == null) {
const selectedNestedLabwareLabel = {
text: selectedNestedLabwareDef.metadata.displayName,
Expand All @@ -129,18 +130,18 @@ export const SelectedHoveredItems = (
labwareInfos.push(selectedNestedLabwareLabel)
}
if (
(hoveredLabware != null ||
selectedLabwareDefUri === hoveredLabware ||
selectedNestedLabwareDefUri === hoveredLabware) &&
hoveredLabwareDef != null
selectedLabwareDefUri != null &&
(hoveredLabware == null || hoveredLabware !== selectedLabwareDefUri)
) {
const hoverLabelLabel = {
text: hoveredLabwareDef.metadata.displayName,
isSelected: false,
isLast: true,
const def =
defs[selectedLabwareDefUri] ?? customLabwareDefs[selectedLabwareDefUri]
const selectedLabwareLabel = {
text: def.metadata.displayName,
isSelected: true,
isLast: hoveredLabware == null && selectedNestedLabwareDefUri == null,
isZoomed: true,
}
labwareInfos.push(hoverLabelLabel)
labwareInfos.push(selectedLabwareLabel)
}

return (
Expand Down Expand Up @@ -199,6 +200,7 @@ export const SelectedHoveredItems = (
slotPosition={slotPosition}
moduleModel={selectedModuleModel}
hoveredLabware={hoveredLabware}
showLabel={selectedNestedLabwareDef == null}
/>
<SelectedLabwareRender
labwareOnDeck={matchingSelectedNestedLabwareOnDeck}
Expand All @@ -208,8 +210,7 @@ export const SelectedHoveredItems = (
hoveredLabware={hoveredLabware}
nestedLabwareInfo={[
{
text:
selectedNestedLabwareDef?.metadata.displayName ?? 'unknown name',
text: selectedLabwareDef?.metadata.displayName ?? 'unknown name',
isSelected: true,
isLast: true,
isZoomed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface SelectedLabwareRenderProps {
hoveredLabware: string | null
labwareOnDeck?: LabwareOnDeck
nestedLabwareInfo?: DeckLabelProps[] | undefined
showLabel?: boolean
}
export function SelectedLabwareRender(
props: SelectedLabwareRenderProps
Expand All @@ -27,6 +28,7 @@ export function SelectedLabwareRender(
moduleModel,
hoveredLabware,
nestedLabwareInfo,
showLabel = true,
} = props

return (labwareOnDeck != null || labwareDef != null) &&
Expand All @@ -48,9 +50,9 @@ export function SelectedLabwareRender(
labwareOnDeck={labwareOnDeck}
/>
) : null}
{labwareDef != null ? (
{labwareDef != null && showLabel ? (
<LabwareLabel
isLast={true}
isLast
isSelected={true}
labwareDef={labwareDef}
position={slotPosition}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('SelectedHoveredItems', () => {
screen.getAllByText(
'Fixture Opentrons Universal Flat Heater-Shaker Adapter'
)
).toHaveLength(3)
).toHaveLength(2)
})
it('renders nothing when there is a hovered module but selected fixture', () => {
props.hoveredModule = HEATERSHAKER_MODULE_V1
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/pages/Designer/LabwareLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export const LabwareLabel = (props: LabwareLabelProps): JSX.Element => {
const [labelContainerHeight, setLabelContainerHeight] = useState(0)

const deckLabels = [
...nestedLabwareInfo,
{
text: labelText,
isSelected: isSelected,
isLast: isLast,
isZoomed: designerTab === 'startingDeck',
},
...nestedLabwareInfo,
]

useEffect(() => {
Expand Down

0 comments on commit 18f9fb4

Please sign in to comment.