diff --git a/protocol-designer/src/components/SelectablePlate.js b/protocol-designer/src/components/SelectablePlate.js index eaee78c8931..f670b93d649 100644 --- a/protocol-designer/src/components/SelectablePlate.js +++ b/protocol-designer/src/components/SelectablePlate.js @@ -18,8 +18,10 @@ import { } from '@opentrons/components' import {WELL_LABEL_OFFSET} from '../constants' -import SingleLabware from '../components/SingleLabware' -import SelectionRect from '../components/SelectionRect.js' +import SingleLabware from './SingleLabware' +import SelectionRect from './SelectionRect.js' +import WellTooltip from './labware/WellTooltip' +import type {WellIngredientNames} from '../steplist/types' import type {ContentsByWell} from '../labware-ingred/types' import type {RectEvent} from '../collision-types' import styles from './SelectablePlate.css' @@ -35,6 +37,7 @@ export type Props = { hoverable?: boolean, makeOnMouseOverWell?: (well: string) => (e: SyntheticMouseEvent<*>) => mixed, onMouseExitWell?: (e: SyntheticMouseEvent<*>) => mixed, + liquidNamesById: WellIngredientNames, onSelectionMove: RectEvent, onSelectionDone: RectEvent, @@ -59,6 +62,7 @@ export default function SelectablePlate (props: Props) { hoverable = true, makeOnMouseOverWell, onMouseExitWell, + liquidNamesById, } = props // NOTE: LabwareOnDeck is not selectable or hoverable @@ -99,21 +103,6 @@ export default function SelectablePlate (props: Props) { ) } else { // NOTE: Currently only selectable and hoverable (bound to redux) in LiquidPlacementModal - const getWellProps = (wellName) => { - const well = wellContents[wellName] - return { - onMouseOver: makeOnMouseOverWell && makeOnMouseOverWell(wellName), - onMouseLeave: onMouseExitWell, - selectable, - wellName, - highlighted: well.highlighted, - selected: well.selected, - error: well.error, - maxVolume: well.maxVolume, - fillColor: ingredIdsToColor(well.groupIds), - } - } - // FIXME: SelectionRect is somehow off by one in the x axis, hence the magic number return ( @@ -122,8 +111,38 @@ export default function SelectablePlate (props: Props) { originXOffset={WELL_LABEL_OFFSET - 1} originYOffset={WELL_LABEL_OFFSET} {...{onSelectionMove, onSelectionDone}}> - - + + {({makeHandleMouseOverWell, handleMouseLeaveWell}) => ( + + { + const well = wellContents[wellName] + return { + onMouseOver: (e: SyntheticMouseEvent<*>) => { + makeOnMouseOverWell && makeOnMouseOverWell(wellName)(e) + if (well.ingreds) { + makeHandleMouseOverWell(wellName, well.ingreds)(e) + } + }, + onMouseLeave: (e: SyntheticMouseEvent<*>) => { + onMouseExitWell && onMouseExitWell(e) + handleMouseLeaveWell(e) + }, + selectable, + wellName, + highlighted: well.highlighted, + selected: well.selected, + error: well.error, + maxVolume: well.maxVolume, + fillColor: ingredIdsToColor(well.groupIds), + } + }} + getTipProps={getTipProps} /> + + + )} + ) diff --git a/protocol-designer/src/components/labware/WellTooltip.js b/protocol-designer/src/components/labware/WellTooltip.js index c3828089ed7..09d1bd4c358 100644 --- a/protocol-designer/src/components/labware/WellTooltip.js +++ b/protocol-designer/src/components/labware/WellTooltip.js @@ -10,7 +10,8 @@ import {Portal} from '../portals/TopPortal' import styles from './labware.css' -const TOOLTIP_OFFSET = 22 +const DEFAULT_TOOLTIP_OFFSET = 22 +const WELL_BORDER_WIDTH = 4 type WellTooltipParams = { makeHandleMouseOverWell: (wellName: string, wellIngreds: LocationLiquidState) => (e: SyntheticMouseEvent<*>) => void, @@ -28,12 +29,14 @@ type State = { tooltipY: ?number, tooltipWellName: ?string, tooltipWellIngreds: ?LocationLiquidState, + tooltipOffset: ?number, } const initialState: State = { tooltipX: null, tooltipY: null, tooltipWellName: null, tooltipWellIngreds: null, + tooltipOffset: DEFAULT_TOOLTIP_OFFSET, } class WellTooltip extends React.Component { @@ -50,6 +53,7 @@ class WellTooltip extends React.Component { tooltipY: top + (height / 2), tooltipWellName: wellName, tooltipWellIngreds: wellIngreds, + tooltipOffset: height / 2, }) } } @@ -60,7 +64,7 @@ class WellTooltip extends React.Component { } render () { - const {tooltipX, tooltipY} = this.state + const {tooltipX, tooltipY, tooltipOffset} = this.state return ( @@ -81,7 +85,7 @@ class WellTooltip extends React.Component { tooltipWellName: this.state.tooltipWellName, })} {this.state.tooltipWellName && - + {({ref, style, placement, arrowProps}) => { return ( diff --git a/protocol-designer/src/containers/SelectablePlate.js b/protocol-designer/src/containers/SelectablePlate.js index fb84fba80ad..cdf5cb013bc 100644 --- a/protocol-designer/src/containers/SelectablePlate.js +++ b/protocol-designer/src/containers/SelectablePlate.js @@ -65,6 +65,7 @@ function mapStateToProps (state: BaseState, ownProps: OP): SP { wellContents: {}, containerType: '', selectable: selectable, + liquidNamesById: {}, } } @@ -142,6 +143,7 @@ function mapStateToProps (state: BaseState, ownProps: OP): SP { getTipProps: getTipProps || noop, containerType: labware ? labware.type : 'missing labware', selectable, + liquidNamesById: selectors.getLiquidNamesById(state), } } diff --git a/protocol-designer/src/top-selectors/well-contents/wellContentsAllLabware.js b/protocol-designer/src/top-selectors/well-contents/wellContentsAllLabware.js index 745975f8b6e..7e23772cedd 100644 --- a/protocol-designer/src/top-selectors/well-contents/wellContentsAllLabware.js +++ b/protocol-designer/src/top-selectors/well-contents/wellContentsAllLabware.js @@ -48,6 +48,7 @@ const _getWellContents = ( selected: selectedWells ? wellName in selectedWells : false, maxVolume: well['total-liquid-volume'] || Infinity, groupIds, + ingreds: __ingredientsForContainer && __ingredientsForContainer[wellName], }, } }, {})