Skip to content

Commit

Permalink
feat(protocol-designer): onboarding animations for ot-2 (#16958)
Browse files Browse the repository at this point in the history
closes RQA-3677
  • Loading branch information
jerader authored Nov 22, 2024
1 parent 6c2948e commit 7bbb1c2
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 16 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function AddMetadata(props: AddMetadataProps): JSX.Element | null {
return (
<HandleEnter onEnter={handleProceed}>
<WizardBody
robotType={robotType}
stepNumber={
robotType === FLEX_ROBOT_TYPE
? FLEX_METADATA_WIZARD_STEP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useTranslation } from 'react-i18next'
import without from 'lodash/without'
import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data'
import {
ALIGN_CENTER,
BORDERS,
Expand Down Expand Up @@ -63,6 +64,7 @@ export function SelectFixtures(props: WizardTileProps): JSX.Element | null {
return (
<HandleEnter onEnter={handleProceed}>
<WizardBody
robotType={FLEX_ROBOT_TYPE}
stepNumber={5}
header={t('add_fixtures')}
subHeader={t('fixtures_replace')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import without from 'lodash/without'
import { useLocation } from 'react-router-dom'

import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data'
import {
Flex,
SPACING,
Expand Down Expand Up @@ -43,6 +43,7 @@ export function SelectGripper(props: WizardTileProps): JSX.Element | null {
return (
<HandleEnter onEnter={handleProceed}>
<WizardBody
robotType={FLEX_ROBOT_TYPE}
stepNumber={3}
header={t('add_gripper')}
disabled={gripperStatus == null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export function SelectModules(props: WizardTileProps): JSX.Element | null {
return (
<HandleEnter onEnter={proceed}>
<WizardBody
robotType={robotType}
stepNumber={robotType === FLEX_ROBOT_TYPE ? 4 : 3}
header={t('add_modules')}
goBack={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export function SelectPipettes(props: WizardTileProps): JSX.Element | null {
) : null}
<HandleEnter onEnter={handleProceed}>
<WizardBody
robotType={robotType}
stepNumber={2}
header={page === 'add' ? t('add_pipette') : t('robot_pipettes')}
subHeader={page === 'add' ? t('which_pipette') : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function SelectRobot(props: WizardTileProps): JSX.Element {
return (
<HandleEnter onEnter={proceed}>
<WizardBody
robotType={robotType}
stepNumber={1}
header={t('basics')}
disabled={false}
Expand Down
61 changes: 46 additions & 15 deletions protocol-designer/src/pages/CreateNewProtocolWizard/WizardBody.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useTranslation } from 'react-i18next'
import { css } from 'styled-components'
import { useState, useLayoutEffect } from 'react'
import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data'
import {
ALIGN_CENTER,
ALIGN_END,
Expand All @@ -25,8 +26,10 @@ import four from '../../assets/images/onboarding_animation_4.webm'
import five from '../../assets/images/onboarding_animation_5.webm'
import six from '../../assets/images/onboarding_animation_6.webm'
import { BUTTON_LINK_STYLE } from '../../atoms'
import type { RobotType } from '@opentrons/shared-data'

interface WizardBodyProps {
robotType: RobotType
stepNumber: number
header: string
children: React.ReactNode
Expand All @@ -37,6 +40,21 @@ interface WizardBodyProps {
tooltipOnDisabled?: string
}

const OT2_GIFS: Record<number, string> = {
2: new URL(
'../../assets/images/onboarding_animation_ot2_2.gif',
import.meta.url
).href,
3: new URL(
'../../assets/images/onboarding_animation_ot2_3.gif',
import.meta.url
).href,
4: new URL(
'../../assets/images/onboarding_animation_ot2_4.gif',
import.meta.url
).href,
}

const ONBOARDING_ANIMATIONS: Record<number, string> = {
1: one,
2: two,
Expand All @@ -56,6 +74,7 @@ export function WizardBody(props: WizardBodyProps): JSX.Element {
proceed,
disabled = false,
tooltipOnDisabled,
robotType,
} = props
const { t } = useTranslation('shared')
const [targetProps, tooltipProps] = useHoverTooltip({
Expand Down Expand Up @@ -153,21 +172,33 @@ export function WizardBody(props: WizardBodyProps): JSX.Element {
transition: opacity 0.5s ease-in-out;
`}
>
<video
preload="auto"
css={css`
width: 100%;
height: 100%;
object-fit: cover;
border-radius: ${BORDERS.borderRadius16};
`}
autoPlay={true}
loop={false}
controls={false}
aria-label={`onboarding animation for page ${stepNumber}`}
>
<source src={asset ?? ''} type="video/mp4" />
</video>
{robotType === FLEX_ROBOT_TYPE || stepNumber === 1 ? (
<video
preload="auto"
css={css`
width: 100%;
height: 100%;
object-fit: cover;
border-radius: ${BORDERS.borderRadius16};
`}
autoPlay
loop={false}
controls={false}
aria-label={`onboarding animation for page ${stepNumber}`}
>
<source src={asset ?? ''} type="video/webm" />
</video>
) : (
<img
src={OT2_GIFS[stepNumber]}
width="100%"
height="100%"
css={css`
object-fit: cover;
border-radius: ${BORDERS.borderRadius16};
`}
/>
)}
</Flex>
</Flex>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type * as React from 'react'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import '@testing-library/jest-dom/vitest'
import { fireEvent, screen } from '@testing-library/react'
import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data'
import { i18n } from '../../../assets/localization'
import { renderWithProviders } from '../../../__testing-utils__'
import { WizardBody } from '../WizardBody'
Expand All @@ -24,6 +25,7 @@ describe('WizardBody', () => {
disabled: false,
goBack: vi.fn(),
subHeader: 'mockSubheader',
robotType: FLEX_ROBOT_TYPE,
}
})

Expand Down

0 comments on commit 7bbb1c2

Please sign in to comment.