Skip to content

Commit

Permalink
feat(app): Show module name over labware on deckmaps (#1913)
Browse files Browse the repository at this point in the history
Closes #1739
  • Loading branch information
mcous authored Jul 23, 2018
1 parent f2e63e3 commit c40905b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 12 deletions.
9 changes: 7 additions & 2 deletions app/src/components/DeckMap/ConnectedSlotItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
type SessionModule
} from '../../robot'

import {getModulesOn} from '../../config'
import type {LabwareComponentProps} from '@opentrons/components'
import LabwareItem, {type LabwareItemProps} from './LabwareItem'
import ModuleItem from './ModuleItem'
Expand Down Expand Up @@ -44,6 +45,7 @@ function SlotItem (props: Props) {
{labware && (
<LabwareItem
labware={labware}
module={module}
slot={slot}
height={height}
width={width}
Expand All @@ -58,11 +60,14 @@ function mapStateToProps (state: State, ownProps: OP): SP {
const allLabware = robotSelectors.getLabware(state)
const tipracksConfirmed = robotSelectors.getTipracksConfirmed(state)
const labware = allLabware.find((lw) => lw.slot === slot)
const module = robotSelectors.getModulesBySlot(state)[slot]
const highlighted = slot === selectedSlot
const modulesEnabled = getModulesOn(state)
const module = modulesEnabled
? robotSelectors.getModulesBySlot(state)[slot]
: null

const stateProps: SP = {}

// bail out if it's an empty slot
if (labware) {
const {isTiprack, confirmed, calibratorMount} = labware

Expand Down
18 changes: 14 additions & 4 deletions app/src/components/DeckMap/LabwareItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react'
import cx from 'classnames'
import {Link} from 'react-router-dom'

import type {Labware} from '../../robot'
import type {Labware, SessionModule} from '../../robot'
import type {LabwareComponentProps} from '@opentrons/components'

import {
Expand All @@ -14,6 +14,7 @@ import {
} from '@opentrons/components'

import LabwareSpinner from './LabwareSpinner'
import ModuleNameOverlay from './ModuleNameOverlay'
import styles from './styles.css'

export type LabwareItemProps = LabwareComponentProps & {
Expand All @@ -23,11 +24,12 @@ export type LabwareItemProps = LabwareComponentProps & {
showSpinner?: boolean,
onClick?: () => void,
url?: string
}
},
module: ?SessionModule,
}

export default function LabwareItem (props: LabwareItemProps) {
const {width, height, labware} = props
const {width, height, labware, module} = props

const {
name,
Expand All @@ -47,7 +49,15 @@ export default function LabwareItem (props: LabwareItemProps) {
<Plate containerType={type} />

{!showSpinner && (
<ContainerNameOverlay title={humanizeLabwareType(type)} subtitle={name} />
<ContainerNameOverlay
title={humanizeLabwareType(type)}
subtitle={name}
/>
)}

{!showSpinner && module && (
// TODO(mc, 2018-07-23): displayName?
<ModuleNameOverlay name={module.name} />
)}

{showSpinner && (
Expand Down
29 changes: 29 additions & 0 deletions app/src/components/DeckMap/ModuleNameOverlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @flow
import * as React from 'react'

import styles from './styles.css'

type Props = {name: string}

const HEIGHT = 20
const PADDING_LEFT = 4

export default function ModuleNameOverlay (props: Props) {
return (
<React.Fragment>
<rect
className={styles.module_name_overlay}
width='100%'
height={HEIGHT}
/>
<text
className={styles.module_name_text}
dominantBaseline='central'
x={PADDING_LEFT}
y={HEIGHT / 2}
>
{props.name}
</text>
</React.Fragment>
)
}
4 changes: 3 additions & 1 deletion app/src/components/DeckMap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {Deck} from '@opentrons/components'
import ConnectedSlotItem from './ConnectedSlotItem'
import ModuleItem from './ModuleItem'
import LabwareItem from './LabwareItem'
import ModuleNameOverlay from './ModuleNameOverlay'

import styles from './styles.css'

export default function DeckMap () {
Expand All @@ -17,6 +19,6 @@ export default function DeckMap () {
)
}

export {LabwareItem, ModuleItem}
export {LabwareItem, ModuleItem, ModuleNameOverlay}
export type {LabwareItemProps} from './LabwareItem'
export type {ModuleItemProps} from './ModuleItem'
13 changes: 13 additions & 0 deletions app/src/components/DeckMap/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,16 @@
text-transform: uppercase;
white-space: pre;
}

.module_name_overlay {
color: var(--c-black);
opacity: 0.7;
}

.module_name_text {
fill: currentColor;
color: var(--c-white);
font-size: 0.5rem;
font-weight: var(--fw-semibold);
text-transform: uppercase;
}
16 changes: 11 additions & 5 deletions app/src/components/ReviewDeckModal/LabwareComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as React from 'react'
import {connect} from 'react-redux'

import {selectors as robotSelectors, type SessionModule} from '../../robot'
import {getModulesOn} from '../../config'

import type {LabwareComponentProps} from '@opentrons/components'
import type {LabwareItemProps} from '../DeckMap'
Expand All @@ -22,17 +23,20 @@ type Props = OP & SP
export default connect(mapStateToProps)(LabwareComponent)

function LabwareComponent (props: Props) {
const {labware, module} = props

return (
<React.Fragment>
{props.module && (
<ModuleItem module={props.module} />
{module && (
<ModuleItem module={module} />
)}
{props.labware && (
{labware && (
<LabwareItem
slot={props.slot}
width={props.width}
height={props.height}
labware={props.labware}
labware={labware}
module={module}
/>
)}
</React.Fragment>
Expand All @@ -45,6 +49,8 @@ function mapStateToProps (state, ownProps: OP): SP {

return {
labware: allLabware.find((lw) => lw.slot === slot),
module: robotSelectors.getModulesBySlot(state)[slot]
module: getModulesOn(state)
? robotSelectors.getModulesBySlot(state)[slot]
: null
}
}

0 comments on commit c40905b

Please sign in to comment.