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(odd): Protocol dashboard hifi designs #12453

Merged
merged 16 commits into from
Apr 12, 2023

Conversation

ewagoner
Copy link
Contributor

@ewagoner ewagoner commented Apr 10, 2023

Overview

This PR implements the HiFi designs for the protocol dashboard, as specified here: https://www.figma.com/file/AoTLAYuWawlaWItB1umOjr/Opentrons-Flex-Touchscreen-Designs?node-id=5155-84968&t=WIbrmZjlwG5NxXMe-0

TODO: The protocol card component needs to display analysis info, and I don't believe that's available yet. It's also not quite a ListItem, but when analysis is ready to display it's possible this could use the generic ListItem.

Closes RCORE-673

Test Plan

This PR is almost purely UI changes. Core logic was already in place with the LoFi implementation and contains unit tests. I will go through the coverage reports and if there are uncovered bits I will add additional unit tests to this PR.

Changelog

  • Created PinnedProtocolCarousel component
  • Implement carousel swipe on touchscreen
  • Used snacker to notify user of pins and unpins
  • Applied HiFi designs to All Protocols page and Pinned Protocol cards

Review requests

Please give it a spin on the DevKit and report anything amiss.

Risk assessment

This only implements UI changes over the LoFi implementation, so user risk is minimal.

@ewagoner ewagoner requested review from koji, shlokamin, jerader and a team April 10, 2023 14:09
@ewagoner ewagoner requested a review from a team as a code owner April 10, 2023 14:09
@ewagoner
Copy link
Contributor Author

Screen.Recording.2023-04-10.at.9.51.07.AM.mov

@ewagoner
Copy link
Contributor Author

Upload.from.GitHub.for.iOS.MOV

@codecov
Copy link

codecov bot commented Apr 10, 2023

Codecov Report

Merging #12453 (ef4cecc) into edge (f9e3024) will decrease coverage by 0.04%.
The diff coverage is 26.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #12453      +/-   ##
==========================================
- Coverage   73.81%   73.78%   -0.04%     
==========================================
  Files        2246     2246              
  Lines       61740    61772      +32     
  Branches     6430     6439       +9     
==========================================
+ Hits        45574    45577       +3     
- Misses      14653    14679      +26     
- Partials     1513     1516       +3     
Flag Coverage Δ
app 72.47% <25.00%> (-0.15%) ⬇️
components 67.23% <100.00%> (+0.04%) ⬆️
labware-library 49.74% <ø> (ø)
protocol-designer 46.34% <ø> (ø)
step-generation 88.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
app/src/organisms/ToasterOven/ToasterOven.tsx 25.00% <0.00%> (-2.78%) ⬇️
...splay/ProtocolDashboard/PinnedProtocolCarousel.tsx 0.00% <0.00%> (ø)
components/src/icons/icon-data.ts 100.00% <ø> (ø)
...DeviceDisplay/ProtocolDashboard/LongPressModal.tsx 47.36% <33.33%> (-1.21%) ⬇️
...rc/pages/OnDeviceDisplay/ProtocolDetails/index.tsx 63.88% <33.33%> (-1.33%) ⬇️
.../pages/OnDeviceDisplay/ProtocolDashboard/index.tsx 14.06% <39.13%> (+9.71%) ⬆️
...DeviceDisplay/ProtocolDashboard/PinnedProtocol.tsx 70.58% <72.72%> (-9.42%) ⬇️
components/src/ui-style-constants/typography.ts 100.00% <100.00%> (ø)

@ewagoner ewagoner changed the title RCORE-673-odd-protocol-dashboard feat(odd): Protocol dashboard hifi designs Apr 10, 2023
Comment on lines +52 to +69
full: {
fontSize: TYPOGRAPHY.fontSize32,
height: '100%',
lineHeight: TYPOGRAPHY.lineHeight42,
width: '100%',
},
half: {
fontSize: TYPOGRAPHY.fontSize28,
height: '10.75rem',
lineHeight: TYPOGRAPHY.lineHeight36,
width: '29.25rem',
},
regular: {
fontSize: TYPOGRAPHY.fontSize28,
height: '10.75rem',
lineHeight: TYPOGRAPHY.lineHeight36,
width: '28.375rem',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can define this as a const like cardSizeOptions and put it right after import statements?

Comment on lines 58 to 63
const cardSize =
pinnedProtocols.length === 1
? 'full'
: pinnedProtocols.length === 2
? 'half'
: 'regular'
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is totally fine since I like this personally.
But, maybe switch could be a better option?

what do you think @shlokamin @jerader?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I turned it into a boring function without the nesting.

Copy link
Member

@shlokamin shlokamin left a comment

Choose a reason for hiding this comment

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

im having issues pushing to my dev kit aat the moment but this looks good overall! @koji would you mind testing on your kit when you have some time?

const runs = useAllRunsQuery()
const swipe = useSwipe()

const slider = (swipe.ref.current as unknown) as HTMLDivElement
Copy link
Member

Choose a reason for hiding this comment

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

@koji can we avoid this double as casting if we change the type of interactiveRef in useSwipe to MutableRefObject< HTMLDivElement | null> ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I will take a look.

Comment on lines +23 to +26
let isDown = false
let startX = 0
let scrollLeft = 0
Copy link
Member

Choose a reason for hiding this comment

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

hmm is there a reason we're using global variables rather than refs here? makes my spidey senses tingle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only that I was torn between making this fully generic and reusable carousel component and one that is only used by the pinned protocols. I wrote two different sets of functions, since the ODD swiping and mousing works differently. With a mouse, I initialize the dragging positions at 0 and move left or right based on mouse movement. With the ODD swipe, I use the ref and just move it 800px each swipe (the most "natural" feeling amount of movement based on my tests but still totally arbitrary.

There wasn't any harm in just initializing mouse movement with zeros for now, but if this carousel ends up getting used elsewhere and for things other than pinned protocols, that might have to be parameterized.

Comment on lines 58 to 63
const cardSize =
pinnedProtocols.length === 1
? 'full'
: pinnedProtocols.length === 2
? 'half'
: 'regular'
Copy link
Member

Choose a reason for hiding this comment

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

nit: nested ternaries make me sad. can we extract this into a function and make this switch/if statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've simplified this brain teaser :)

@shlokamin
Copy link
Member

also looks like you need to rebase on top of edge to resolve these merge conflicts

@ewagoner
Copy link
Contributor Author

resolve these merge conflicts

Oh, those are brand new! I'll fix 'em.

@ewagoner ewagoner force-pushed the RCORE-673-odd-protocol-dashboard branch from ee72500 to c498082 Compare April 10, 2023 21:29
@koji
Copy link
Contributor

koji commented Apr 11, 2023

IMG_0648

0309_OpentronsRisingStarsPromotionParty.py

looks we need to wrap pinned protocol name's name.
From the design, the max would 2 lines.
If the name exceeds that, we will need to truncate the name.
Actually I asked about the truncation rule to Mel, but I've not received any answers from her.

my suggestion for now is below.
https://codepen.io/sleepy_coder/pen/yLxqNPX

@ewagoner
Copy link
Contributor Author

ewagoner commented Apr 11, 2023

If the name exceeds that, we will need to truncate the name.

I am truncating the name. For a single pinned protocol it will max out at two lines. For two or more pinned protocols, it can max out at three lines. The truncation rules were in Figma but they didn't quite align with the max lines rule so I adjusted them in my code.

You can see them in action in my videos attached to this PR. I've got one example with a crazy long name that demonstrates the truncation.

Your example is a word break issue, which would apply to any fixed width div.

@ewagoner
Copy link
Contributor Author

looks we need to wrap pinned protocol name's name

I've pushed a fix for the wrap issue

@ewagoner ewagoner requested review from koji, shlokamin and a team April 11, 2023 15:18
Copy link
Contributor

@koji koji left a comment

Choose a reason for hiding this comment

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

Overall looks good to me.
I left a couple of comments and questions.

Tested your branch on my dev kit.
The name display thing in ProtocolCard is fixed. Thank you!

@koji
Copy link
Contributor

koji commented Apr 11, 2023

Probably need to solve conflicts since Jethary merged her PR which is related to TooManyPinsModal into edge recently.

@koji koji self-requested a review April 11, 2023 22:36
Copy link
Contributor

@koji koji left a comment

Choose a reason for hiding this comment

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

I think once you update the icon data + snapshot and solve conflicts, your branch should be good to go.

sorry for the unclear guide of icon things... I will add this to Confluence

@ewagoner ewagoner force-pushed the RCORE-673-odd-protocol-dashboard branch from a253e06 to ef4cecc Compare April 12, 2023 00:25
@ewagoner ewagoner merged commit 4e8524b into edge Apr 12, 2023
@ewagoner ewagoner deleted the RCORE-673-odd-protocol-dashboard branch April 12, 2023 13:48
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.

None yet

3 participants