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

feat(protocol-designer): onboarding animations for ot-2 #16958

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
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
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> = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: post-release we will revisit optimizing the animations for ot-2 and flex. Right now its a bit weird that the flex animations are in webm format but ot-2 animations are in gif format. but it seems to work okay for the release so i think its fine that they have different formats.

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={true}
jerader marked this conversation as resolved.
Show resolved Hide resolved
loop={false}
controls={false}
aria-label={`onboarding animation for page ${stepNumber}`}
>
<source src={asset ?? ''} type="video/mp4" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why mp4? I thought the type was webm.
converted from webm to mp4?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops they're definitely webm, i'll fix

</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
Loading