Skip to content

Commit

Permalink
refactor(protocol-designer): refactor PD labware components for reada…
Browse files Browse the repository at this point in the history
…bility

* Simplify & clean up LabwareOnDeck, labware overlays, and related compenents & types
  • Loading branch information
IanLondon committed Sep 28, 2018
1 parent 343e845 commit db28176
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 225 deletions.
2 changes: 0 additions & 2 deletions components/interfaces/DeckSlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import * as React from 'react'

export type DeckSlotProps = {
slot: string,
width: number,
height: number,
highlighted?: boolean,
containerType?: string,
children?: React.Node
Expand Down
9 changes: 6 additions & 3 deletions components/src/deck/LabwareContainer.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
// @flow
import * as React from 'react'
import {SLOT_HEIGHT_MM, SLOT_WIDTH_MM} from '@opentrons/shared-data'
import styles from './LabwareContainer.css'

const defs = {roundSlotClipPath: 'roundSlotClipPath'} // TODO: import these defs instead of hard-coding in applications? Or should they be passed to children?

type Props = {
x?: number,
y?: number,
height: number,
width: number,
height?: number,
width?: number,
highlighted?: boolean,
children?: React.Node,
}

export default function LabwareContainer (props: Props) {
const {x, y, height, width, highlighted, children} = props
const {x, y, highlighted, children} = props
const height = props.height || SLOT_HEIGHT_MM
const width = props.width || SLOT_WIDTH_MM

return (
<g>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type SP = {

function mapStateToProps (state: BaseState): SP {
return {
slot: labwareIngredSelectors.canAdd(state) || null,
slot: labwareIngredSelectors.selectedAddLabwareSlot(state) || null,
permittedTipracks: pipetteSelectors.permittedTipracks(state),
}
}
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/components/labware/ClickableText.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Props = {
height?: string | number,
text?: string,
iconName?: IconName,
onClick?: (e: SyntheticEvent<*>) => void,
onClick?: (e: SyntheticEvent<*>) => mixed,
}

const DEFAULT_HEIGHT = 15
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// @flow
import React from 'react'
import cx from 'classnames'
import {HandleKeypress, type DeckSlot} from '@opentrons/components'
import {HandleKeypress} from '@opentrons/components'
import styles from './labware.css'

type DisabledSelectSlotOverlayProps = {setMoveLabwareMode: (slot: ?DeckSlot) => void}
type DisabledSelectSlotOverlayProps = {
cancelMove: () => mixed,
}

class DisabledSelectSlotOverlay extends React.Component<DisabledSelectSlotOverlayProps> {
cancelMove = () => {
this.props.setMoveLabwareMode()
}
render () {
return (
<HandleKeypress preventDefault handlers={[{key: 'Escape', onPress: this.cancelMove}]}>
<HandleKeypress preventDefault handlers={[{key: 'Escape', onPress: this.props.cancelMove}]}>
<g className={cx(styles.slot_overlay, styles.disabled)}>
<rect className={styles.overlay_panel} />
<g className={styles.clickable_text}>
Expand Down
Loading

0 comments on commit db28176

Please sign in to comment.