Skip to content

Commit

Permalink
refactor(app): add selectors to Metadata Card and Robot Calibration S…
Browse files Browse the repository at this point in the history
…tep (#8426)

* refactor(app): add selectors to Metadata Card and Robot Calibration Step

fix #8336
  • Loading branch information
smb2268 authored Oct 4, 2021
1 parent 63eb764 commit 37e2a44
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 14 deletions.
4 changes: 3 additions & 1 deletion app/src/atoms/structure/LabeledValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { StyleProps } from '@opentrons/components'
interface Props extends StyleProps {
label: React.ReactNode
value: React.ReactNode
id?: string
labelProps?: React.ComponentProps<typeof Text>
valueProps?: React.ComponentProps<typeof Text>
}
Expand All @@ -19,12 +20,13 @@ export function LabeledValue(props: Props): JSX.Element {
const {
label,
value,
id,
labelProps = {},
valueProps = {},
...wrapperProps
} = props
return (
<Box css={FONT_BODY_1_DARK} lineHeight={1.5} {...wrapperProps}>
<Box css={FONT_BODY_1_DARK} lineHeight={1.5} {...wrapperProps} id={id}>
<Text
fontWeight={FONT_WEIGHT_SEMIBOLD}
margin="0 0 0.25rem"
Expand Down
11 changes: 10 additions & 1 deletion app/src/organisms/ProtocolSetup/MetadataCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,34 @@ export function MetadataCard(): JSX.Element {
flex={3}
label={t('organization_and_author')}
value={author || '-'}
id={'MetadataCard_protocolOrganizationAuthor'}
/>
<LabeledValue
flex={3}
label={t('last_updated')}
value={lastUpdated ? format(lastUpdated, DATE_FORMAT) : '-'}
id={'MetadataCard_protocolLastUpdated'}
/>
<LabeledValue
flex={2}
label={t('creation_method')}
value={method || '-'}
id={'MetadataCard_protocolCreationMethod'}
/>
</Flex>
<Flex marginTop={SPACING_2}>
<LabeledValue
flex={6}
label={t('description')}
value={description || '-'}
id={'MetadataCard_protocolDescription'}
/>
<LabeledValue
flex={2}
label={t('estimated_run_time')}
value={'-'}
id={'MetadataCard_protocolEstRunTime'}
/>
<LabeledValue flex={2} label={t('estimated_run_time')} value={'-'} />
</Flex>
</Card>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface CollapsibleStepProps {
title: string
description: string
label: string
id?: string
toggleExpanded: () => void
children: React.ReactNode
rightAlignedNode: React.ReactNode
Expand All @@ -30,6 +31,7 @@ export function CollapsibleStep({
title,
description,
label,
id,
toggleExpanded,
children,
rightAlignedNode,
Expand All @@ -46,7 +48,7 @@ export function CollapsibleStep({
>
{label}
</Text>
<Text as="h5" css={FONT_HEADER_DARK} marginTop={SPACING_2}>
<Text as="h5" css={FONT_HEADER_DARK} marginTop={SPACING_2} id={id}>
{title}
</Text>
<Text as="p" css={FONT_BODY_1_DARK} marginTop={SPACING_2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ interface Props {
index?: number
subText?: string
title?: string
id?: string
}

export function CalibrationItem(props: Props): JSX.Element | null {
const { index, title, subText, calibratedDate, button } = props
const { index, title, subText, calibratedDate, button, id } = props
const { t } = useTranslation('protocol_setup')
const backgroundColor =
index !== undefined && index % 2 === 0 ? C_NEAR_WHITE : C_WHITE
Expand All @@ -55,7 +56,7 @@ export function CalibrationItem(props: Props): JSX.Element | null {
/>
<span>
{title !== undefined && (
<Text role={'heading'} fontSize={FONT_SIZE_BODY_2}>
<Text role={'heading'} fontSize={FONT_SIZE_BODY_2} id={id}>
{title}
</Text>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,20 @@ export function DeckCalibration(props: Props): JSX.Element | null {
alignItems={ALIGN_CENTER}
justifyContent={JUSTIFY_SPACE_BETWEEN}
>
<Text as={'h2'} css={FONT_HEADER_THIN} paddingBottom={SPACING_2}>
<Text
as={'h2'}
css={FONT_HEADER_THIN}
paddingBottom={SPACING_2}
id={'DeckCalibration_deckCalibrationTitle'}
>
{t('deck_calibration_title')}
</Text>
<Link
role={'link'}
onClick={() => setHelpModalIsOpen(true)}
color={C_BLUE}
fontSize={FONT_SIZE_BODY_1}
id={'DeckCalibration_robotCalibrationHelpLink'}
>
{t('robot_cal_help_title')}
</Link>
Expand All @@ -91,7 +97,10 @@ export function DeckCalibration(props: Props): JSX.Element | null {
justifyContent={JUSTIFY_SPACE_BETWEEN}
>
<Text css={FONT_HEADER_DARK}>{t('robot_cal_help_title')}</Text>
<Box onClick={() => setHelpModalIsOpen(false)}>
<Box
onClick={() => setHelpModalIsOpen(false)}
id={'RobotCalModal_xButton'}
>
<Icon name={'close'} size={SIZE_2} />
</Box>
</Flex>
Expand All @@ -106,6 +115,7 @@ export function DeckCalibration(props: Props): JSX.Element | null {
href={robotCalHelpArticle}
target="_blank"
rel="noopener noreferrer"
id={'RobotCalModal_helpArticleLink'}
/>
),
}}
Expand Down Expand Up @@ -153,6 +163,7 @@ export function DeckCalibration(props: Props): JSX.Element | null {
width={SIZE_4}
backgroundColor={C_BLUE}
name="close"
id={'RobotCalModal_closeButton'}
>
{t('shared:close')}
</PrimaryBtn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function PipetteCalibration(props: Props): JSX.Element {
href={inexactPipetteSupportArticle}
color={C_BLUE}
marginRight={SPACING_3}
id={'PipetteCalibration_pipetteMismatchHelpLink'}
>
{t('pipette_compat_help')}
</Link>
Expand All @@ -109,7 +110,12 @@ export function PipetteCalibration(props: Props): JSX.Element {
>
{t('pipette_missing')}
</Text>
<PrimaryBtn as={RRDLink} to={pipettesPageUrl} backgroundColor={C_BLUE}>
<PrimaryBtn
as={RRDLink}
to={pipettesPageUrl}
backgroundColor={C_BLUE}
id={'PipetteCalibration_attachPipetteButton'}
>
{t('attach_pipette_cta')}
</PrimaryBtn>
</Flex>
Expand All @@ -122,6 +128,7 @@ export function PipetteCalibration(props: Props): JSX.Element {
<PrimaryBtn
backgroundColor={C_BLUE}
onClick={() => startPipetteOffsetCalibrationBlockModal(null)}
id={'PipetteCalibration_calibratePipetteButton'}
>
{t('calibrate_now_cta')}
</PrimaryBtn>
Expand Down Expand Up @@ -151,6 +158,7 @@ export function PipetteCalibration(props: Props): JSX.Element {
title={`${t('mount_title', { mount: mount.toUpperCase() })} ${
pipetteTipRackData.pipetteDisplayName
}`}
id={`PipetteCalibration_${mount}MountTitle`}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,16 @@ export function TipLengthCalibration({
onClick={() => confirm(true)}
textDecoration={TEXT_DECORATION_UNDERLINE}
css={FONT_BODY_2_DARK}
id={'TipRackCalibration_recalibrateTipRackLink'}
>
{t('recalibrate')}
</Link>
) : (
<PrimaryBtn backgroundColor={C_BLUE} onClick={() => handleStart()}>
<PrimaryBtn
backgroundColor={C_BLUE}
onClick={() => handleStart()}
id={'TipRackCalibration_calibrateTipRackButton'}
>
{t('calibrate_now_cta')}
</PrimaryBtn>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ export function RobotCalibration(props: Props): JSX.Element {
<>
<DeckCalibration robotName={robotName} />
<Divider marginY={SPACING_3} />
<Text as="h2" paddingBottom={SPACING_2} css={FONT_HEADER_THIN}>
<Text
as="h2"
paddingBottom={SPACING_2}
css={FONT_HEADER_THIN}
id={`PipetteCalibration_requiredPipettesTitle`}
>
{t('required_pipettes_title')}
</Text>
<div>
Expand All @@ -83,7 +88,11 @@ export function RobotCalibration(props: Props): JSX.Element {
})}
</div>
<Divider marginY={SPACING_3} />
<Text as="h2" css={FONT_HEADER_THIN}>
<Text
as="h2"
css={FONT_HEADER_THIN}
id={'TipRackCalibration_requiredTipLengthTitle'}
>
{t('required_tip_racks_title')}
</Text>
<div>
Expand Down Expand Up @@ -130,6 +139,7 @@ export function RobotCalibration(props: Props): JSX.Element {
onClick={() => expandStep(nextStep)}
backgroundColor={C_BLUE}
{...targetProps}
id={'RobotCalStep_proceedButton'}
>
{t(nextStepButtonKey)}
</PrimaryBtn>
Expand Down
14 changes: 12 additions & 2 deletions app/src/organisms/ProtocolSetup/RunSetupCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ export function RunSetupCard(): JSX.Element | null {
paddingY={SPACING_3}
backgroundColor={C_WHITE}
>
<Text as="h2" paddingX={SPACING_3} fontWeight={FONT_WEIGHT_SEMIBOLD}>
<Text
as="h2"
paddingX={SPACING_3}
fontWeight={FONT_WEIGHT_SEMIBOLD}
id={'RunSetupCard_setupForRun'}
>
{t('setup_for_run')}
</Text>
{stepsKeysInOrder.map((stepKey, index) => (
Expand All @@ -121,6 +126,7 @@ export function RunSetupCard(): JSX.Element | null {
expanded={stepKey === expandedStepKey}
label={t('step', { index: index + 1 })}
title={t(`${stepKey}_title`)}
id={`RunSetupCard_${stepKey}`}
description={StepDetailMap[stepKey].description}
toggleExpanded={() =>
stepKey === expandedStepKey
Expand All @@ -145,8 +151,12 @@ export function RunSetupCard(): JSX.Element | null {
? 'check-circle'
: 'alert-circle'
}
id={'RunSetupCard_calibrationIcon'}
/>
<Text fontSize={FONT_SIZE_BODY_1}>
<Text
fontSize={FONT_SIZE_BODY_1}
id={'RunSetupCard_calibrationText'}
>
{calibrationStatus.complete
? t('calibration_ready')
: t('calibration_needed')}
Expand Down
4 changes: 3 additions & 1 deletion components/src/icons/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IconProps extends SvgProps {
style?: Record<string, string | number>
/** optional children */
children?: React.ReactNode
id?: string
}

const spinAnimation = keyframes`
Expand All @@ -52,7 +53,7 @@ const spinStyle = css`
* ```
*/
export function Icon(props: IconProps): JSX.Element | null {
const { name, children, className, spin, ...svgProps } = props
const { name, children, className, spin, id, ...svgProps } = props

if (!(name in ICON_DATA_BY_NAME)) {
console.error(`"${name}" is not a valid Icon name`)
Expand All @@ -69,6 +70,7 @@ export function Icon(props: IconProps): JSX.Element | null {
className={cx(className, { spin })}
css={spinStyle}
{...svgProps}
id={id}
>
<path fillRule="evenodd" d={path} />
{props.children}
Expand Down

0 comments on commit 37e2a44

Please sign in to comment.