-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(app): Desktop implementation for SelectRecoveryOption (#15691)
This PR got away from me a little bit (and I still have to test it - the sum of these two is why it's in draft). It's probably best to view it commit by commit. Overall, the point is to implement the desktop styling for the SelectRecoveryOption component of error recovery, here: https://www.figma.com/design/8dMeu8MuPfXoORtOV6cACO/Feature%3A-Error-Recovery-August-Release?node-id=4829-78111&t=bTwOek0mZSA61ugm-4 . This is a little weird because it is exactly semantically equivalent to the ODD panel, but has a very different styling - two columns instead of one. It also uses the radio buttons that we use only in OT-2 tip length calibration method selection, which are old and use cssmodules and need a cleanup. The approach here was to add some fundamental structure components to InterventionModal that will render two columns on desktop (as the TwoColumn structure, including min-size and wrap) and one column on the ODD at full width. Then, we can build on top of that in ErrorRecovery, with the big difference being that the ErrorRecovery component also folds in the standard ER footer (or will - already had to find/replace a bunch of stuff, going to move other components over to specifying their footers through the wrapper as we update their styles). There were also some incidental refactors. By commit, - 981e828 : we have these utility components for visualizing structure components; make them handle sometimes being size limited and sometimes not being - a7917e7 : Add a wrapper around the RadioGroup component. We're going to need to update these styles further (that's a todo) but we don't want to, or I don't want to, have to mess with cssmodules. Also I think @TamarZanzouri is touching this stuff at the same time, so keep it isolated and droppable. Did I let the worms in my brain drive and make a typescript wrapper for getting the change events to take an inferred union of button values? Yes. Also note the one change to the underlying component to specify IDs so that we can use aria label linking in the passed components, which is both good practice and allows tests to work later. - e835f86 The error recovery component for viewing failed and next commands was bundled with presenting text in the left column, which is not what we want this panel to have, so split it out. - 699cb79 The first fun one: Add a component that can responsively present one or two columns, and by "responsively" i mean abuse css mediaquery to only do it on touchscreen and maintain the two-column responsive presentation through desktop resizes. Best appreciated in storybook. - 52150cb Simultaneous refactor and feature - we had a RecoveryContentWrapper but it was really just a single column, this isn't helpful, add a single and twocolumn version (lots of find and replace since I changed the name) and then add a OneOrTwoColumn on top of that. These wrappers also encompass rendering footers because the footer needs to be in different places in one or two column - 00f38e8 Use all that stuff to render SelectRecoveryOption! Note that the tests now run on both presentations and it all works because of that aria label stuff. ## Todo - [x] Visual tests, at all (this is why it's a draft)
- Loading branch information
Showing
30 changed files
with
664 additions
and
295 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,11 +1,28 @@ | ||
import * as React from 'react' | ||
|
||
import { Box } from '@opentrons/components' | ||
import { | ||
Flex, | ||
DIRECTION_COLUMN, | ||
JUSTIFY_SPACE_BETWEEN, | ||
} from '@opentrons/components' | ||
import type { StyleProps } from '@opentrons/components' | ||
|
||
export interface OneColumnProps { | ||
export interface OneColumnProps extends StyleProps { | ||
children: React.ReactNode | ||
} | ||
|
||
export function OneColumn({ children }: OneColumnProps): JSX.Element { | ||
return <Box width="100%">{children}</Box> | ||
export function OneColumn({ | ||
children, | ||
...styleProps | ||
}: OneColumnProps): JSX.Element { | ||
return ( | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
width="100%" | ||
{...styleProps} | ||
> | ||
{children} | ||
</Flex> | ||
) | ||
} |
68 changes: 68 additions & 0 deletions
68
app/src/molecules/InterventionModal/OneColumnOrTwoColumn.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,68 @@ | ||
import * as React from 'react' | ||
|
||
import { OneColumnOrTwoColumn } from './' | ||
|
||
import { StandInContent } from './story-utils/StandIn' | ||
import { VisibleContainer } from './story-utils/VisibleContainer' | ||
import { css } from 'styled-components' | ||
import { | ||
RESPONSIVENESS, | ||
Flex, | ||
ALIGN_CENTER, | ||
JUSTIFY_SPACE_AROUND, | ||
DIRECTION_COLUMN, | ||
} from '@opentrons/components' | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
function Wrapper(props: {}): JSX.Element { | ||
return ( | ||
<OneColumnOrTwoColumn> | ||
<StandInContent> | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
alignItems={ALIGN_CENTER} | ||
justifyContent={JUSTIFY_SPACE_AROUND} | ||
height="100%" | ||
> | ||
This component is the only one shown on the ODD. | ||
</Flex> | ||
</StandInContent> | ||
<StandInContent> | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
alignItems={ALIGN_CENTER} | ||
justifyContent={JUSTIFY_SPACE_AROUND} | ||
height="100%" | ||
> | ||
This component is shown in the right column on desktop. | ||
</Flex> | ||
</StandInContent> | ||
</OneColumnOrTwoColumn> | ||
) | ||
} | ||
|
||
const meta: Meta<React.ComponentProps<typeof Wrapper>> = { | ||
title: 'App/Molecules/InterventionModal/OneColumnOrTwoColumn', | ||
component: Wrapper, | ||
decorators: [ | ||
Story => ( | ||
<VisibleContainer | ||
css={css` | ||
min-width: min(max-content, 100vw); | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
width: 500px; | ||
} | ||
`} | ||
> | ||
<Story /> | ||
</VisibleContainer> | ||
), | ||
], | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof Wrapper> | ||
|
||
export const OneOrTwoColumn: Story = {} |
55 changes: 55 additions & 0 deletions
55
app/src/molecules/InterventionModal/OneColumnOrTwoColumn.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,55 @@ | ||
import * as React from 'react' | ||
|
||
import { css } from 'styled-components' | ||
import { | ||
Flex, | ||
Box, | ||
DIRECTION_ROW, | ||
SPACING, | ||
WRAP, | ||
RESPONSIVENESS, | ||
} from '@opentrons/components' | ||
import type { StyleProps } from '@opentrons/components' | ||
import { TWO_COLUMN_ELEMENT_MIN_WIDTH } from './constants' | ||
|
||
export interface OneColumnOrTwoColumnProps extends StyleProps { | ||
children: [React.ReactNode, React.ReactNode] | ||
} | ||
|
||
export function OneColumnOrTwoColumn({ | ||
children: [leftOrSingleElement, optionallyDisplayedRightElement], | ||
...styleProps | ||
}: OneColumnOrTwoColumnProps): JSX.Element { | ||
return ( | ||
<Flex | ||
flexDirection={DIRECTION_ROW} | ||
gap={SPACING.spacing40} | ||
flexWrap={WRAP} | ||
{...styleProps} | ||
> | ||
<Box | ||
flex="1" | ||
css={css` | ||
min-width: ${TWO_COLUMN_ELEMENT_MIN_WIDTH}; | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
min-width: none; | ||
width: 100%; | ||
} | ||
`} | ||
> | ||
{leftOrSingleElement} | ||
</Box> | ||
<Box | ||
flex="1" | ||
minWidth={TWO_COLUMN_ELEMENT_MIN_WIDTH} | ||
css={css` | ||
@media ${RESPONSIVENESS.touchscreenMediaQuerySpecs} { | ||
display: none; | ||
} | ||
`} | ||
> | ||
{optionallyDisplayedRightElement} | ||
</Box> | ||
</Flex> | ||
) | ||
} |
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 const TWO_COLUMN_ELEMENT_MIN_WIDTH = '17.1875rem' as const |
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
10 changes: 8 additions & 2 deletions
10
app/src/molecules/InterventionModal/story-utils/StandIn.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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import * as React from 'react' | ||
import { Box, BORDERS } from '@opentrons/components' | ||
|
||
export function StandInContent(): JSX.Element { | ||
export function StandInContent({ | ||
children, | ||
}: { | ||
children?: React.ReactNode | ||
}): JSX.Element { | ||
return ( | ||
<Box | ||
border={'4px dashed #A864FFFF'} | ||
borderRadius={BORDERS.borderRadius8} | ||
height="104px" | ||
backgroundColor="#A864FF19" | ||
/> | ||
> | ||
{children} | ||
</Box> | ||
) | ||
} |
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
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
Oops, something went wrong.