Skip to content

Commit

Permalink
feat(protocol-designer): deck setup skeleton for redesign (#15899)
Browse files Browse the repository at this point in the history
closes AUTH-635
  • Loading branch information
jerader authored Aug 8, 2024
1 parent cd54d90 commit 3a27f06
Show file tree
Hide file tree
Showing 11 changed files with 834 additions and 6 deletions.
2 changes: 1 addition & 1 deletion protocol-designer/src/components/DeckSetup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
)
}

export const DeckSetup = (): JSX.Element => {
export const LegacyDeckSetup = (): JSX.Element => {
const drilledDown =
useSelector(labwareIngredSelectors.getDrillDownLabwareId) != null
const selectedTerminalItemId = useSelector(getSelectedTerminalItemId)
Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/components/DeckSetupManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getBatchEditSelectedStepTypes,
getHoveredItem,
} from '../ui/steps/selectors'
import { DeckSetup } from './DeckSetup'
import { LegacyDeckSetup } from './DeckSetup'
import { NullDeckState } from './DeckSetup/NullDeckState'
import { OffDeckLabwareButton } from './OffDeckLabwareButton'

Expand All @@ -17,7 +17,7 @@ export const DeckSetupManager = (): JSX.Element => {
return (
<>
<OffDeckLabwareButton />
<DeckSetup />
<LegacyDeckSetup />
</>
)
} else {
Expand Down
2 changes: 2 additions & 0 deletions protocol-designer/src/localization/en/protocol_overview.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"add_labware": "Add labware",
"edit": "Edit",
"protocol_overview": "Protocol overview"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import * as React from 'react'
import { useTranslation } from 'react-i18next'
import cx from 'classnames'
import { css } from 'styled-components'
import { useSelector } from 'react-redux'
import {
Flex,
LegacyStyledText,
RobotCoordsForeignDiv,
} from '@opentrons/components'
import { START_TERMINAL_ITEM_ID } from '../../../steplist'
import { getDeckSetupForActiveItem } from '../../../top-selectors/labware-locations'

import type { CoordinateTuple, Dimensions } from '@opentrons/shared-data'
import type { TerminalItemId } from '../../../steplist'

import styles from './DeckSetup.module.css'

interface ControlSelectProps {
slotPosition: CoordinateTuple | null
slotBoundingBox: Dimensions
slotId: string
addEquipment: (slotId: string) => void
hover: string | null
setHover: React.Dispatch<React.SetStateAction<string | null>>
slotTopLayerId: string // can be AddressableAreaName, moduleId, labwareId
selectedTerminalItemId?: TerminalItemId | null
}

export const ControlSelect = (
props: ControlSelectProps
): JSX.Element | null => {
const {
slotBoundingBox,
slotPosition,
slotId,
selectedTerminalItemId,
addEquipment,
hover,
setHover,
slotTopLayerId,
} = props
const { t } = useTranslation('protocol_overview')
const activeDeckSetup = useSelector(getDeckSetupForActiveItem)
const moduleId = Object.keys(activeDeckSetup.modules).find(
moduleId => slotTopLayerId === moduleId
)

if (selectedTerminalItemId !== START_TERMINAL_ITEM_ID || slotPosition == null)
return null

return (
<RobotCoordsForeignDiv
x={slotPosition[0]}
y={slotPosition[1]}
width={slotBoundingBox.xDimension}
height={slotBoundingBox.yDimension}
innerDivProps={{
// TODO(ja, 8/6/24): refactor to not require className? and update styling to match designs
className: cx(styles.slot_overlay, styles.appear_on_mouseover),
onMouseEnter: () => {
setHover(slotId)
},
onMouseLeave: () => {
setHover(null)
},
onClick: () => {
addEquipment(slotId)
},
}}
>
<Flex
css={css`
opacity: ${hover != null && hover === slotId ? `1` : `0`};
`}
>
<a
onClick={() => {
addEquipment(slotId)
}}
>
<LegacyStyledText>
{moduleId != null ? t('add_labware') : t('edit')}
</LegacyStyledText>
</a>
</Flex>
</RobotCoordsForeignDiv>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.slot_overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
padding: 0.5rem;
background-color: color-mod(var(--c-black) alpha(0.75));
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: flex-start;
color: white;
font-size: var(--fs-body-1);
border-radius: 0.5rem;
}

.appear_on_mouseover {
opacity: 0;

&:hover {
opacity: 1;
}
}
Loading

0 comments on commit 3a27f06

Please sign in to comment.