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: balance skeleton loader #5126

Merged
merged 1 commit into from
Apr 4, 2024
Merged

feat: balance skeleton loader #5126

merged 1 commit into from
Apr 4, 2024

Conversation

alter-eggo
Copy link
Contributor

@alter-eggo alter-eggo commented Mar 26, 2024

Try out Leather build d0fd13aExtension build, Test report, Storybook, Chromatic

This pr adds skeleton loader for balances on home page and switch account modal
https://github.com/leather-wallet/extension/assets/46521087/492e7c7f-49b4-446d-b99e-f25c1d080bda

@alter-eggo alter-eggo changed the title feat: balance shimmer loading feat: balance skeleton loading Mar 26, 2024
@alter-eggo alter-eggo changed the title feat: balance skeleton loading feat: balance skeleton loader Mar 26, 2024
@alter-eggo alter-eggo force-pushed the feat/balance-loader branch 3 times, most recently from e438479 to 0860254 Compare March 28, 2024 14:41
@alter-eggo alter-eggo marked this pull request as ready for review March 28, 2024 15:02
@alter-eggo alter-eggo force-pushed the feat/balance-loader branch 2 times, most recently from 53a8b08 to 09f6c8d Compare March 28, 2024 17:56
Copy link
Contributor

@pete-watters pete-watters left a comment

Choose a reason for hiding this comment

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

I added some suggestions but overall good work and I like the shimmer 👍

import { css } from 'leather-styles/css';
import { Box } from 'leather-styles/jsx';

export function BalanceShimmer({ ...rest }) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs types

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, this is the skeleton loader? Can we call it skeleton instead? Shimmer makes me think it's just the text effect

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also why does this need to be specific to balances? What if we need a skeleton loader for other non-balance text?

Suggest we make a skeleton design system component, with stories, rather than having a specific balance one. This component could wrap that?

Copy link
Contributor Author

@alter-eggo alter-eggo Mar 29, 2024

Choose a reason for hiding this comment

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

yes, will rename to Skeleton loader. I actually added already some stories.
how you see this skeleton design system component? what should it take as props except width/height?

Copy link
Collaborator

Choose a reason for hiding this comment

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

what should it take as props except width/height?

Yeah exactly. Either width/height, or maybe some pre-defined values? Not sure. cc/ @fabric-8 @mica000 to add to design system with variants needed

Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

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

Think it's important to not make this component specific to balance. Thoughts?

import { css } from 'leather-styles/css';
import { Box } from 'leather-styles/jsx';

export function BalanceShimmer({ ...rest }) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also why does this need to be specific to balances? What if we need a skeleton loader for other non-balance text?

Suggest we make a skeleton design system component, with stories, rather than having a specific balance one. This component could wrap that?

@markmhendrickson
Copy link
Collaborator

Please link to a relevant issue and place that issue on the board 🙏

@alter-eggo alter-eggo linked an issue Apr 2, 2024 that may be closed by this pull request
@alter-eggo alter-eggo force-pushed the feat/balance-loader branch from 09f6c8d to 1e6ce1a Compare April 4, 2024 08:08
@alter-eggo alter-eggo force-pushed the feat/balance-loader branch from e0830c2 to 0f620f0 Compare April 4, 2024 08:14
Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

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

SkeletonLoader component looks good, but think it's really important not to break the conceptual divide between a generic component, and an instance of its use.

src/app/components/balance/balance-shimmer.tsx Outdated Show resolved Hide resolved
Comment on lines 15 to 27
accountItemTotalBalance: {
height: '20px',
},
cryptoAssetItemTokenBalance: {
width: '126px',
},
cryptoAssetItemUsdBalance: {
width: '78px',
},
accountCardTotalBalance: {
width: '200px',
height: '38px',
},
Copy link
Collaborator

@kyranjamie kyranjamie Apr 4, 2024

Choose a reason for hiding this comment

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

This breaks separation of concerns. A generic component like this shouldn't know about all these specific use-cases within the wallet. Will list just grow every new use we have? IMO this is a really important rule not to break, and easy to avoid. Also, think how we want to refactor this to monorepo. Extension-specific UI concerns shouldn't be there either.

Why not make it configurable by passing width/height. Or, perhaps better, given that the skeleton loader is there to replace areas of text, why not pass the textStyle that it's masking and infer the height from that? And also pass a length for how many chars long it should be?

<SkeletonLoader textStyle="header.01" textLength={20} />

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 made this to avoid duplication of width/height passing in components and stories.
maybe just put it to separate file? and yeah, just pass these styles in components to loader

I believe this textStyle approach is not extendable here as skeleton loader might be used not only for text

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep you're right, let's skip the textstyle approach, as we don't want to assume it's only used for text.

To avoid the duplication, we should make wrapper components

AccountCardSkeletonLoader contains SkeletonLoader with some predefined widths and heights. That's a more flexible approach than baking in these concerns to the loader itself.

Copy link
Contributor Author

@alter-eggo alter-eggo Apr 4, 2024

Choose a reason for hiding this comment

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

don't think we need any additional wrapper either. just pass width/height and that's it.
do we really need add to stories all skeleton usage variants?

src/shared/shimmer-styles.ts Outdated Show resolved Hide resolved
@alter-eggo alter-eggo force-pushed the feat/balance-loader branch from 0f620f0 to d0fd13a Compare April 4, 2024 12:00
@alter-eggo alter-eggo requested a review from kyranjamie April 4, 2024 12:03
Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

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

LGTM

@alter-eggo alter-eggo added this pull request to the merge queue Apr 4, 2024
Merged via the queue into dev with commit 5c1c284 Apr 4, 2024
28 checks passed
@alter-eggo alter-eggo deleted the feat/balance-loader branch April 4, 2024 12:19
@314159265359879
Copy link
Contributor

Was this already fixed? @alter-eggo you mentioned creating a new PR, I only see this one.
image

I see the loader for balances in this build but not for BNS names/account names on the switch select account screen.

image

Loading all the names on an account with hundreds of names looks good here!

@alter-eggo
Copy link
Contributor Author

@314159265359879 seems there was problem with shimmer styles which fixed here #5205
that's why you haven't seen "loading" animation

@markmhendrickson
Copy link
Collaborator

The loading indicators themselves seem much too wide?

Screenshot 2024-04-10 at 18 41 59

@markmhendrickson
Copy link
Collaborator

Also, is this branch not based on client-side throttling? I'm seeing lots of 429s

image

@alter-eggo
Copy link
Contributor Author

@markmhendrickson it's quite an old pr, pls check #5206

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.

Add skeleton loaders for user balances
6 participants