-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol-designer): deck setup skeleton for redesign (#15899)
closes AUTH-635
- Loading branch information
Showing
11 changed files
with
834 additions
and
6 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
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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ | ||
"add_labware": "Add labware", | ||
"edit": "Edit", | ||
"protocol_overview": "Protocol overview" | ||
} |
89 changes: 89 additions & 0 deletions
89
protocol-designer/src/pages/ProtocolOverview/DeckSetup/ControlSelect.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,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> | ||
) | ||
} |
25 changes: 25 additions & 0 deletions
25
protocol-designer/src/pages/ProtocolOverview/DeckSetup/DeckSetup.module.css
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,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; | ||
} | ||
} |
Oops, something went wrong.