Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): alignment in thermocycler card cycle info #5320

Merged
merged 4 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions app/src/components/ModuleLiveStatusCards/ThermocyclerCard.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// @flow
import * as React from 'react'
import { addSeconds, format } from 'date-fns'
import cx from 'classnames'
import { LabeledValue } from '@opentrons/components'
import { getModuleDisplayName } from '@opentrons/shared-data'

import type { ThermocyclerModule, ModuleCommand } from '../../modules/types'
import { formatSeconds } from '../../robot/selectors' // TODO: move helper from robot selector to helper file
import { TemperatureControl, TemperatureData } from '../ModuleControls'

import { StatusCard } from './StatusCard'
import { StatusItem } from './StatusItem'
import styles from './styles.css'

import type { ThermocyclerModule, ModuleCommand } from '../../modules/types'

const TimeRemaining = ({
holdTime,
title,
Expand All @@ -23,10 +23,7 @@ const TimeRemaining = ({
className={cx(styles.inline_labeled_value, styles.time_remaining_wrapper)}
>
<p className={styles.time_remaining_label}>Time remaining for step:</p>
<p>
{// convert duration to seconds from epoch (midnight), then format
format(addSeconds(0, holdTime ?? 0), 'HH:mm:ss')}
</p>
<p>{formatSeconds(holdTime ?? 0)}</p>
</span>
)

Expand All @@ -53,19 +50,31 @@ const CycleInfo = ({
return null
}
return (
<div className={styles.card_row}>
<LabeledValue
label="Cycle #"
className={styles.compact_labeled_value}
value={`${currentCycleIndex} / ${totalCycleCount}`}
/>
<LabeledValue
label="Step #"
className={styles.compact_labeled_value}
value={`${currentStepIndex} / ${totalStepCount}`}
/>
<TimeRemaining holdTime={holdTime} title="Time remaining for step:" />
</div>
<>
<div className={styles.card_row}>
<div className={styles.cycle_info_wrapper}>
<div className={styles.cycle_info_counts}>
<LabeledValue
label="Cycle #"
className={cx(
styles.compact_labeled_value,
styles.cycle_data_item
)}
value={`${currentCycleIndex} / ${totalCycleCount}`}
/>
<LabeledValue
label="Step #"
className={cx(
styles.compact_labeled_value,
styles.cycle_data_item
)}
value={`${currentStepIndex} / ${totalStepCount}`}
/>
</div>
<TimeRemaining holdTime={holdTime} title="Time remaining for step:" />
</div>
</div>
</>
)
}

Expand Down
12 changes: 12 additions & 0 deletions app/src/components/ModuleLiveStatusCards/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ updated component library cards after redesign/refactor
max-width: 7rem;
}

.cycle_data_item,
.temp_data_item {
flex: 1 1 0;
}
Expand All @@ -72,3 +73,14 @@ updated component library cards after redesign/refactor
.status_item_wrapper {
flex: 1 1 0;
}

.cycle_info_wrapper {
display: flex;
flex-direction: column;
align-items: stretch;
}

.cycle_info_counts {
display: flex;
flex-direction: row;
}
16 changes: 9 additions & 7 deletions app/src/robot/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,18 @@ export const getRunSeconds = createSelector(
}
)

export function formatSeconds(runSeconds: number): string {
const hours = padStart(`${Math.floor(runSeconds / 3600)}`, 2, '0')
const minutes = padStart(`${Math.floor(runSeconds / 60) % 60}`, 2, '0')
const seconds = padStart(`${runSeconds % 60}`, 2, '0')

return `${hours}:${minutes}:${seconds}`
}

// $FlowFixMe: (mc, 2019-04-17): untyped RPC state selector
export const getRunTime = createSelector(
getRunSeconds,
(runSeconds): string => {
const hours = padStart(`${Math.floor(runSeconds / 3600)}`, 2, '0')
const minutes = padStart(`${Math.floor(runSeconds / 60) % 60}`, 2, '0')
const seconds = padStart(`${runSeconds % 60}`, 2, '0')

return `${hours}:${minutes}:${seconds}`
}
formatSeconds
)

export function getCalibrationRequest(state: State) {
Expand Down