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

refactor(app): Desktop implementation for SelectRecoveryOption #15691

Merged
merged 14 commits into from
Jul 18, 2024

Conversation

sfoster1
Copy link
Member

@sfoster1 sfoster1 commented Jul 17, 2024

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

  • Visual tests, at all (this is why it's a draft)

@sfoster1 sfoster1 requested a review from a team as a code owner July 17, 2024 17:22
@sfoster1 sfoster1 requested review from mjhuff and removed request for a team July 17, 2024 17:22
@sfoster1 sfoster1 marked this pull request as draft July 17, 2024 17:23
@sfoster1 sfoster1 requested a review from TamarZanzouri July 17, 2024 17:23
Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

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

Will give this a more thorough review soon, but the overall structure makes sense to me!

Comment on lines +5 to +9
// note: this typescript stuff is so that e.currentTarget.value in the ChangeEventHandler
// is deduced to a union of the values of the options passed to the radiogroup rather than
// just string
Copy link
Contributor

Choose a reason for hiding this comment

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

Sweet.

@sfoster1 sfoster1 marked this pull request as ready for review July 17, 2024 19:26
sfoster1 added 9 commits July 17, 2024 16:11
StandIn can have children, VisibleContainer gets some customization so
it works properly in flow cases.

StandIn can now be used in TwoColumn.

TwoColumn has its fixed width popped out into constants and now takes
advantage of VisibleContainer to work slightly better.
We have a radio button group in the desktop app, but it is still using
CSS modules and kind of awful to use. Make a quick wrapper that allows
customization via the ways that we currently like to customize things.
This was a single component that had both the step lister thing and a
forced two-column layout, which isn't really useful. Make
FailedStepNextStep its own component and use it in the TwoCol.
This is a structural component that will render as two columns on
desktop and as one column (not displaying the right-column component) on
ODD. This is a pattern that is used in semantically-equivalent cross
platform layouts throughout error recovery, so let's implement it as an
intervention modal component here.
The container was just the ContentWrapper and was implicitly only single
column; make versions for two columns and optional numbers of columns as
well, since those are layouts that are used throughout ER. Also handle
footer buttons, since those can be a little tricky (they should be
inside the content, or can be anyway, if SingleColumn but definitely
outside and spanning if TwoColumn).

This requires renaming the component instantiations in a whole bunch of
places, which is annoying, but such is life.
This implements the desktop styling for SelectRecoveryOption.
Specifically,

- On desktop this should be a twocolumn with failedstepnextstep, and on
ODD this should be a onecolumn with just the buttons; that means use the
fancy one or two columns wrapper
- The radio buttons need desktop styles, so use the fancy
RecoveryRadioGroup component

Unfortunately, since we're rendering FailedStepNextStep we need access
to the full analysis in tests which means we need to change the fixtures
which means some other components needed to handle having the fixtures changed.
@sfoster1 sfoster1 force-pushed the fix-desktop-select-recovery branch from 3566602 to e63d05a Compare July 17, 2024 20:13
Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for tackling this.

@@ -0,0 +1 @@
export const TWO_COLUMN_ELEMENT_MIN_WIDTH = '17.1875rem' as const
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious - aree we getting this number from the ER Figma or is there some InterventionModal master design file that more formally specify this?

Copy link
Member Author

Choose a reason for hiding this comment

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

>
{t('choose_a_recovery_action')}
</StyledText>
{isOnDevice ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

we cant lose isOnDevice here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I suppose we could!

Copy link
Contributor

@TamarZanzouri TamarZanzouri left a comment

Choose a reason for hiding this comment

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

Very nice! one question about the isOnDevice var but besides that looks great!

@sfoster1 sfoster1 merged commit 8eb14ae into edge Jul 18, 2024
34 checks passed
@sfoster1 sfoster1 deleted the fix-desktop-select-recovery branch July 18, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants