Skip to content

Commit

Permalink
fix(app): Stop long labware names overflowing calibration screens (#3715
Browse files Browse the repository at this point in the history
)

* fix(app): Stop long labware names overflowing calibration screens
  • Loading branch information
mcous authored and btmorr committed Jul 12, 2019
1 parent 31e21e0 commit 22fd8ad
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 41 deletions.
38 changes: 21 additions & 17 deletions app/src/components/CalibrateLabware/InfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ import {
} from '../../robot'

import { getLabwareDisplayName } from '@opentrons/shared-data'
import { PrimaryButton } from '@opentrons/components'
import CalibrationInfoBox from '../CalibrationInfoBox'
import CalibrationInfoContent from '../CalibrationInfoContent'
import { Icon, PrimaryButton } from '@opentrons/components'
import styles from './styles.css'

import type { Mount, Labware, LabwareType } from '../../robot'
import type { State, Dispatch } from '../../types'

// TODO(mc, 2018-02-05): match screens instead of using this old component
// import ConfirmCalibrationPrompt from '../deck/ConfirmCalibrationPrompt'

type OP = {| labware: ?Labware |}

type SP = {|
Expand Down Expand Up @@ -78,18 +74,26 @@ function InfoBox(props: Props) {
}
}

const iconName = confirmed ? 'check-circle' : 'checkbox-blank-circle-outline'

return (
<CalibrationInfoBox confirmed={confirmed} title={title}>
<CalibrationInfoContent
leftChildren={<p>{description}</p>}
rightChildren={
button &&
showButton && (
<PrimaryButton onClick={button.onClick}>{buttonText}</PrimaryButton>
)
}
/>
</CalibrationInfoBox>
<div className={styles.info_box}>
<div className={styles.info_box_left}>
<h2 className={styles.info_box_title}>
<Icon name={iconName} className={styles.info_box_icon} />
{title}
</h2>
<div className={styles.info_box_description}>{description}</div>
</div>
{button && showButton && (
<PrimaryButton
className={styles.info_box_button}
onClick={button.onClick}
>
{buttonText}
</PrimaryButton>
)}
</div>
)
}

Expand Down
39 changes: 39 additions & 0 deletions app/src/components/CalibrateLabware/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,45 @@
right: 0;
}

.info_box {
display: flex;
align-items: center;
margin: 1rem;
padding: 1.5rem;
border: var(--bd-light);
}

.info_box_left {
margin-right: 1rem;
}

.info_box_title {
@apply --font-header-dark;

display: flex;
align-items: center;
margin-bottom: 1rem;
}

.info_box_description {
@apply --font-body-2-dark;
}

.info_box_icon {
flex: none;
width: 1.5rem;
height: 1.5rem;
margin-right: 1rem;
}

.info_box_button {
flex: none;
width: auto;
margin-left: auto;
padding-left: 2rem;
padding-right: 2rem;
}

.modal_contents {
background-color: white;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/CalibratePanel/LabwareList.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function LabwareList(props: Props) {
const { labware, disabled, setLabware } = props

return (
<TitledList title="labware" disabled={disabled}>
<TitledList title="labware">
{labware.map(lw => (
<LabwareListItem
{...lw}
Expand Down
43 changes: 22 additions & 21 deletions app/src/components/CalibratePanel/LabwareListItem.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import * as React from 'react'
import cx from 'classnames'

import { getLabwareDisplayName } from '@opentrons/shared-data'
import { ListItem, HoverTooltip } from '@opentrons/components'
Expand Down Expand Up @@ -32,31 +33,31 @@ export default function LabwareListItem(props: LabwareListItemProps) {

return (
<ListItem
isDisabled={isDisabled}
url={url}
onClick={onClick}
url={!isDisabled ? url : undefined}
onClick={!isDisabled ? onClick : undefined}
iconName={iconName}
className={cx({ [styles.disabled]: isDisabled })}
activeClassName={styles.active}
>
<div className={styles.item_info}>
<span className={styles.item_info_location}>Slot {slot}</span>
{isTiprack && (
<span className={styles.tiprack_item_mount}>
{calibratorMount && calibratorMount.charAt(0).toUpperCase()}
</span>
<HoverTooltip
placement="bottom-end"
tooltipComponent={
<LabwareNameTooltip name={name} displayName={displayName} />
}
>
{handlers => (
<div {...handlers} className={styles.item_info}>
<span className={styles.item_info_location}>Slot {slot}</span>
{isTiprack && (
<span className={styles.tiprack_item_mount}>
{calibratorMount && calibratorMount.charAt(0).toUpperCase()}
</span>
)}

<span className={styles.labware_item_name}>{displayName}</span>
</div>
)}
<HoverTooltip
tooltipComponent={
<LabwareNameTooltip name={name} displayName={displayName} />
}
>
{handlers => (
<span {...handlers} className={styles.labware_item_name}>
{displayName}
</span>
)}
</HoverTooltip>
</div>
</HoverTooltip>
</ListItem>
)
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/components/CalibratePanel/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
width: 100%;
}

/*
* TODO(mc, 2019-07-11): Copy-pasted from components/src/lists/lists.css
* as a workaround to fix HoverTooltip not working on ListItems due to
* pointer-events: none
*/
.disabled * {
color: var(--c-font-disabled);
}

.item_info_tooltip {
@apply --font-body-1-light;

Expand Down
4 changes: 4 additions & 0 deletions components/src/lists/lists.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
}

.disabled {
/*
* TODO(mc, 2019-07-11): pointer-events: none should probably be delegated
* to the component user (causes hovertooltip problems)
*/
pointer-events: none;
background-color: transparent;

Expand Down
10 changes: 8 additions & 2 deletions components/src/tooltips/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ export default function Tooltip<ChildProps: {}>(
positionFixed={props.positionFixed}
>
{({ ref, style, placement, arrowProps }) => {
// remove optional -start and -end modifiers for arrow style
// https://popper.js.org/popper-documentation.html#Popper.placements
const arrowPlacement = placement
? placement.replace(/-(?:start|end)/, '')
: ''

let { style: arrowStyle } = arrowProps
if (placement === 'left' || placement === 'right') {
if (arrowPlacement === 'left' || arrowPlacement === 'right') {
arrowStyle = { top: '0.6em' }
}
const tooltipContents = (
Expand All @@ -78,7 +84,7 @@ export default function Tooltip<ChildProps: {}>(
>
{props.tooltipComponent}
<div
className={cx(styles.arrow, styles[placement])}
className={cx(styles.arrow, styles[arrowPlacement])}
ref={arrowProps.ref}
style={arrowStyle}
/>
Expand Down

0 comments on commit 22fd8ad

Please sign in to comment.