Skip to content

Update main-quote-summary designs/styles#9612

Merged
danjm merged 7 commits intodevelopfrom
update-main-quote-summary-component
Oct 25, 2020
Merged

Update main-quote-summary designs/styles#9612
danjm merged 7 commits intodevelopfrom
update-main-quote-summary-component

Conversation

@danjm
Copy link
Copy Markdown
Contributor

@danjm danjm commented Oct 15, 2020

This PR updates the UI/styles of the main-quote-summary component to match the latest designs:
https://www.figma.com/file/fDtda1cs3MmPXw1MgKswZc/Development---MetaSwaps?node-id=1247%3A0

A demo video of how the component now behaves with different amount and symbol lengths: https://streamable.com/9znvxd

@danjm danjm requested a review from a team as a code owner October 15, 2020 09:01
@danjm danjm requested a review from danfinlay October 15, 2020 09:01
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@danjm danjm force-pushed the update-main-quote-summary-component branch from 1ebe3a1 to d33a03c Compare October 15, 2020 10:30
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [d33a03c]
Page Load Metrics (406 ± 51 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint299442199
domContentLoaded30163840410651
load30363840610651
domInteractive30163740410651

name={destinationSymbol}
fallbackClassName="main-quote-summary__icon-fallback"
/>
<span>{ destinationSymbol }</span>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we add a className to these spans so that the scss can target them by a classname and not by an element type? Hopefully, that would lead to more easily understanding of the CSS when coming back to it/new dev onboarding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in e3841a2

destinationSymbol={destinationTokenSymbol}
isBestQuote={isBestQuote}
sourceIconUrl={selectedFromToken.iconUrl}
destinationIconUrl={destinationToken.iconUrl}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is iconUrl on tokens something added by swaps or did that exist prior?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's part of swaps tokens, but not other tokens in the app. You can see it on the objects returned by https://api.metaswap.codefi.network/tokens

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will expose the user's IP address to the server hosting the token icon URL. This is why we bundle the icon with the extension for the list we have now

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [e3841a2]
Page Load Metrics (513 ± 62 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint34110572211
domContentLoaded32176351113063
load32576451313062
domInteractive32176351013063

brad-decker
brad-decker previously approved these changes Oct 16, 2020
Copy link
Copy Markdown
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

LGTM

@Gudahtt
Copy link
Copy Markdown
Member

Gudahtt commented Oct 21, 2020

This needs to be rebased - there is a conflict.

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Presumably this wasn't supposed to look like this:

conversion

  • It looks like it tries to use the "fallback" for ETH, instead of using the Ethereum logo as we do elsewhere
  • The logo for USDC is being fetched successfully (confirmed via the network tab), but it's still not shown for some reason
  • We're using the URL returned by the swaps API for USDC and fetching the logo despite already having another copy of the icon bundled with the extension
  • The padding between the logo and the symbol looks wrong for the source token
  • The fallback letter is off-center
  • In the designs the destination token is bolded, but here it is not

@danjm
Copy link
Copy Markdown
Contributor Author

danjm commented Oct 22, 2020

Thanks @Gudahtt. Regard "We're using the URL returned by the swaps API for USDC and fetching the logo despite already having another copy of the icon bundled with the extension"

The preference is to use the url from the swaps API because those icons are up to date. Many of the icon's bundled with our extension are outdated.

@danjm danjm force-pushed the update-main-quote-summary-component branch from e3841a2 to e3d10b9 Compare October 22, 2020 14:05
@danjm
Copy link
Copy Markdown
Contributor Author

danjm commented Oct 22, 2020

The latest two commits, and PR #9678, address the issues @Gudahtt found. It looks correct now:

Screenshot from 2020-10-22 10-26-22

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [e3d10b9]
Page Load Metrics (484 ± 65 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint2898522411
domContentLoaded31069748213565
load31269948413565
domInteractive31069748213565

@jakehaugen
Copy link
Copy Markdown

This is looking amazing! Just a couple minor visual spacing tweaks.

  • 16px space between convert to text and amount
  • 24px space between convert to amount and rate

Screen Shot 2020-10-22 at 9 47 12 AM

We've also updated the styling of the "New quotes in" counter. It's now in a container with a gray background to help separate it from the quote text. Not sure if that will be part of a different PR but wanted to call it out. The designs showing that are here: https://www.figma.com/file/fDtda1cs3MmPXw1MgKswZc/Development-MetaSwaps?node-id=1315%3A843

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

This is what the latest version looks like locally for me:

new-main-summary

I'm guessing the ETH icon will be fixed after this branch is rebased?

The space between the conversion rate and the "_ quotes available" button is way too small as well.

if (fontSizeScore > 20) {
ellipsedAmountToDisplay = `${amountToDisplay.slice(0, amountToDisplay.length - (fontSizeScore - 20))}...`
if (amountDigitLength > 20) {
ellipsedAmountToDisplay = `${amountToDisplay.slice(0, 20)}...`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this is a pre-existing, but... it looks like the amount here is being manually ellipsed, and then we're using JavaScript to create a tooltip for the full value.

The browser is already much better at this than we are. We could instead use text-overflow: ellipsis; for the ellipses, and use the HTML title attribute for the tooltip. This would be faster, simpler, and more accessible. Was this option considered and ruled out for some reason?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So this is partly a left over of the previous designs, that had a symbol on the same line as the amount. Doing this with javascript was done for two reasons. First, toproperly control spacing between the amount and the symbol, and the width of each, adding the ellipsis with javascript with necessary. (This is related to trailing space that comes with an ellipsis, but moreover that width has to be constrained with px for ellipsis to work)

Now that the designs have changed, those issues are no longer present. But the second problem is that the designs want the same amount of vertical space between the destination symbol (eth in your screenshots) and the amount. The designs also call for different font sizes depending on the length of the string. When font size changes, the line-height changes, and line height adds extra space above the font. The amount of extra space it adds increase with line height. We address that issue by setting the line height for each font size with javascript. And if line height is set small enough relative to font-size, then the overflow: hidden property required for text-overflow: ellipsis to work will vertically cut off some of the text

(fyi, here is an article that discusses the issues with line-height: https://css-tricks.com/how-to-tame-line-height-in-css/, here is the approach they recommend, which also requires javascript manipulation of the line-height and related properties https://github.com/michaeltaranto/basekick/blob/master/index.js... I am not sure if we can do any better in that regard)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The height adjustment seems independent of the length though. I understand that we'll have to use JavaScript to adjust the height as content changes, but I think we could still use CSS/HTML for the ellipsis and tooltip. Or am I misunderstanding something still?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You might be missing something, or maybe I am...

And if line height is set small enough relative to font-size, then the overflow: hidden property required for text-overflow: ellipsis to work will vertically cut off some of the text

So for ellipsis to work, we have to set overflow: hidden, and if we do that, we hide part of the font that is outside the boundaries of the small line height we set

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

unless maybe if we manipulate the height of the container as well...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, that explains it. I had mistakenly thought you were saying that the height of the container was already being manipulated, but it is not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do thing we'd be better off making this improvement but it can wait for a future PR

@danjm
Copy link
Copy Markdown
Contributor Author

danjm commented Oct 23, 2020

I'm guessing the ETH icon will be fixed after this branch is rebased?

yes

The space between the conversion rate and the "_ quotes available" button is way too small as well.

that's a pre-existing issue on develop (that shows up when that top warning is there). It will go away when both this PR and #9629 are merged into develop

@danjm danjm force-pushed the update-main-quote-summary-component branch from e3d10b9 to f9e258b Compare October 23, 2020 15:09
@danjm
Copy link
Copy Markdown
Contributor Author

danjm commented Oct 23, 2020

@jakehaugen @Gudahtt I have improved some of the vertical spacing issues that were mentioned above. I have also rebased so that the ETH logo is appearing correctly

Screenshots of latest

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [92babbf]
Page Load Metrics (448 ± 62 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint32130472311
domContentLoaded32175544612962
load32375644812962
domInteractive32175544512962

@danjm
Copy link
Copy Markdown
Contributor Author

danjm commented Oct 23, 2020

@jakehaugen The tweak to spacing has been added to this PR

Screenshot from 2020-10-23 16-25-00

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [b8d2d56]
Page Load Metrics (530 ± 131 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaintNaNNaNNaNNaNNaN
domContentLoaded2991348528271130
load3011353530272131
domInteractive2991347528271130

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@danjm danjm merged commit 5456d55 into develop Oct 25, 2020
@danjm danjm deleted the update-main-quote-summary-component branch October 25, 2020 13:23
@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants