-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app): Fix spinner sizing on ODD and desktop (#15862)
There's a lot of places in the ODD that return either an InProgressModal or a SimpleWizardBody. This used to be fine because the InProgressMOdal had sizing, but now it doesn't so that it can be used inside other components, so those places all have an in-progress modal collapsed on top of the spinner icon. To fix this, let's make a component that is explicitly "InProgressModal designed to work alongside SimpleWizardBody", defined in SimpleWizardBody. We can make sure it's the same by splittin SWB into a container component and a contents component, and reusing the container. The container is also where styleprops go. Finally, take all the component that return (cond ? <InProgressModal /> : <SimpleWizardBody>...</SimpleWizardBody) and make them use a SimpleWizardInProgressBody instead of an InProgressModal. Since the SimpleWizardInProgressBody uses the same sizing as the SWB, the result will always be the correct size. ## Testing - [x] On the ODD, change pipette and pipette calibration have the right size spinners - [x] On the ODD, change gripper and gripper calibration have the right size spinners
- Loading branch information
Showing
23 changed files
with
393 additions
and
242 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/src/molecules/InProgressModal/InProgressModal.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as React from 'react' | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { InProgressModal as InProgressModalComponent } from './' | ||
import { SimpleWizardInProgressBody } from '../SimpleWizardBody' | ||
|
||
const meta: Meta<typeof InProgressModalComponent> = { | ||
title: 'App/Molecules/InProgressModal', | ||
component: InProgressModalComponent, | ||
argTypes: { | ||
description: { | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
body: { | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export default meta | ||
|
||
export type Story = StoryObj<typeof InProgressModalComponent> | ||
|
||
export const InProgressModal: Story = { | ||
args: { | ||
description: 'here is a description', | ||
body: 'Here is the body of the whole thing', | ||
}, | ||
} | ||
|
||
export const InProgressModalSimpleWizard: Story = { | ||
args: { | ||
description: 'here is a description', | ||
body: 'Here is the body of the whole thing', | ||
}, | ||
render: args => <SimpleWizardInProgressBody {...args} />, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { InProgressModal } from './InProgressModal' |
35 changes: 35 additions & 0 deletions
35
app/src/molecules/SimpleWizardBody/SimpleWizardBodyContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react' | ||
import { css } from 'styled-components' | ||
|
||
import { | ||
Flex, | ||
DIRECTION_COLUMN, | ||
JUSTIFY_SPACE_BETWEEN, | ||
RESPONSIVENESS, | ||
} from '@opentrons/components' | ||
import type { StyleProps } from '@opentrons/components' | ||
|
||
const WIZARD_CONTAINER_STYLE = css` | ||
min-height: 394px; | ||
flex-direction: ${DIRECTION_COLUMN}; | ||
justify-content: ${JUSTIFY_SPACE_BETWEEN}; | ||
height: 'auto'; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
height: 472px; | ||
} | ||
` | ||
|
||
export interface SimpleWizardBodyContainerProps extends StyleProps { | ||
children?: JSX.Element | JSX.Element[] | null | ||
} | ||
|
||
export function SimpleWizardBodyContainer({ | ||
children, | ||
...styleProps | ||
}: SimpleWizardBodyContainerProps): JSX.Element { | ||
return ( | ||
<Flex css={WIZARD_CONTAINER_STYLE} {...styleProps}> | ||
{children} | ||
</Flex> | ||
) | ||
} |
178 changes: 178 additions & 0 deletions
178
app/src/molecules/SimpleWizardBody/SimpleWizardBodyContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
import * as React from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { css } from 'styled-components' | ||
import { | ||
ALIGN_CENTER, | ||
DIRECTION_COLUMN, | ||
Flex, | ||
Icon, | ||
JUSTIFY_CENTER, | ||
JUSTIFY_FLEX_END, | ||
JUSTIFY_FLEX_START, | ||
JUSTIFY_SPACE_BETWEEN, | ||
POSITION_ABSOLUTE, | ||
RESPONSIVENESS, | ||
SPACING, | ||
LegacyStyledText, | ||
TYPOGRAPHY, | ||
} from '@opentrons/components' | ||
import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data' | ||
import SuccessIcon from '../../assets/images/icon_success.png' | ||
import { getIsOnDevice } from '../../redux/config' | ||
|
||
import { Skeleton } from '../../atoms/Skeleton' | ||
import type { RobotType } from '@opentrons/shared-data' | ||
|
||
interface Props { | ||
iconColor: string | ||
header: string | ||
isSuccess: boolean | ||
children?: React.ReactNode | ||
subHeader?: string | JSX.Element | ||
isPending?: boolean | ||
robotType?: RobotType | ||
/** | ||
* this prop is to change justifyContent of OnDeviceDisplay buttons | ||
* TODO(jr, 8/9/23): this SHOULD be refactored so the | ||
* buttons' justifyContent is specified at the parent level | ||
*/ | ||
justifyContentForOddButton?: string | ||
} | ||
|
||
const BACKGROUND_SIZE = '47rem' | ||
|
||
const HEADER_STYLE = css` | ||
${TYPOGRAPHY.h1Default}; | ||
margin-top: ${SPACING.spacing24}; | ||
margin-bottom: ${SPACING.spacing8}; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
font-size: 2rem; | ||
font-weight: 700; | ||
line-height: ${SPACING.spacing40}; | ||
} | ||
` | ||
const SUBHEADER_STYLE = css` | ||
${TYPOGRAPHY.pRegular}; | ||
margin-left: 6.25rem; | ||
margin-right: 6.25rem; | ||
margin-bottom: ${SPACING.spacing32}; | ||
text-align: ${TYPOGRAPHY.textAlignCenter}; | ||
height: 1.75rem; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
font-size: ${TYPOGRAPHY.fontSize28}; | ||
line-height: ${TYPOGRAPHY.lineHeight36}; | ||
margin-left: 4.5rem; | ||
margin-right: 4.5rem; | ||
} | ||
` | ||
|
||
const FLEX_SPACING_STYLE = css` | ||
height: 1.75rem; | ||
margin-bottom: ${SPACING.spacing32}; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
height: 0rem; | ||
} | ||
` | ||
|
||
export function SimpleWizardBodyContent(props: Props): JSX.Element { | ||
const { | ||
iconColor, | ||
children, | ||
header, | ||
subHeader, | ||
isSuccess, | ||
isPending, | ||
robotType = FLEX_ROBOT_TYPE, | ||
} = props | ||
const isOnDevice = useSelector(getIsOnDevice) | ||
|
||
const BUTTON_STYLE = css` | ||
width: 100%; | ||
justify-content: ${JUSTIFY_FLEX_END}; | ||
padding-right: ${SPACING.spacing32}; | ||
padding-bottom: ${SPACING.spacing32}; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
justify-content: ${props.justifyContentForOddButton ?? | ||
JUSTIFY_SPACE_BETWEEN}; | ||
padding-bottom: ${SPACING.spacing32}; | ||
padding-left: ${SPACING.spacing32}; | ||
} | ||
` | ||
|
||
const ICON_POSITION_STYLE = css` | ||
justify-content: ${JUSTIFY_CENTER}; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
justify-content: ${JUSTIFY_FLEX_START}; | ||
margin-top: ${isSuccess ? SPACING.spacing32 : '8.1875rem'}; | ||
} | ||
` | ||
|
||
return ( | ||
<> | ||
<Flex | ||
width="100%" | ||
alignItems={ALIGN_CENTER} | ||
css={ICON_POSITION_STYLE} | ||
flexDirection={DIRECTION_COLUMN} | ||
flex="1 0 auto" | ||
> | ||
{isPending ? ( | ||
<Flex | ||
gridGap={SPACING.spacing24} | ||
flexDirection={DIRECTION_COLUMN} | ||
justifyContent={JUSTIFY_CENTER} | ||
> | ||
<Skeleton | ||
width="6.25rem" | ||
height="6.25rem" | ||
backgroundSize={BACKGROUND_SIZE} | ||
/> | ||
<Skeleton | ||
width="18rem" | ||
height="1.125rem" | ||
backgroundSize={BACKGROUND_SIZE} | ||
/> | ||
</Flex> | ||
) : ( | ||
<> | ||
{isSuccess ? ( | ||
<img | ||
width={robotType === FLEX_ROBOT_TYPE ? '170px' : '160px'} | ||
height={robotType === FLEX_ROBOT_TYPE ? '141px' : '120px'} | ||
src={SuccessIcon} | ||
alt="Success Icon" | ||
/> | ||
) : ( | ||
<Icon | ||
name="ot-alert" | ||
size={isOnDevice ? '3.75rem' : '2.5rem'} | ||
color={iconColor} | ||
aria-label="ot-alert" | ||
/> | ||
)} | ||
<LegacyStyledText css={HEADER_STYLE}>{header}</LegacyStyledText> | ||
{subHeader != null ? ( | ||
<LegacyStyledText css={SUBHEADER_STYLE}> | ||
{subHeader} | ||
</LegacyStyledText> | ||
) : ( | ||
<Flex aria-label="flex_spacing" css={FLEX_SPACING_STYLE} /> | ||
)} | ||
</> | ||
)} | ||
</Flex> | ||
<Flex | ||
position={POSITION_ABSOLUTE} | ||
bottom={0} | ||
right={0} | ||
css={BUTTON_STYLE} | ||
> | ||
{children} | ||
</Flex> | ||
</> | ||
) | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/molecules/SimpleWizardBody/SimpleWizardInProgressBody.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react' | ||
import type { StyleProps } from '@opentrons/components' | ||
import { InProgressModal } from '../InProgressModal/InProgressModal' | ||
import { SimpleWizardBodyContainer } from './SimpleWizardBodyContainer' | ||
|
||
export type SimpleWizardInProgressBodyProps = React.ComponentProps< | ||
typeof InProgressModal | ||
> & | ||
StyleProps | ||
|
||
export function SimpleWizardInProgressBody({ | ||
alternativeSpinner, | ||
description, | ||
body, | ||
children, | ||
...styleProps | ||
}: SimpleWizardInProgressBodyProps): JSX.Element { | ||
return ( | ||
<SimpleWizardBodyContainer {...styleProps}> | ||
<InProgressModal | ||
alternativeSpinner={alternativeSpinner} | ||
description={description} | ||
body={body} | ||
> | ||
{children} | ||
</InProgressModal> | ||
</SimpleWizardBodyContainer> | ||
) | ||
} |
Oops, something went wrong.