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

Tokens: Fix hidden you pill on sidebar #1124

Merged
merged 8 commits into from
Jun 9, 2020
Merged

Conversation

delfipolito
Copy link
Contributor

@delfipolito delfipolito commented Apr 10, 2020

This PR closes #1008
image

With long custom labels it looks like this:
image

@@ -110,13 +111,17 @@ function InfoBoxes({
items={stakes}
renderLegendItem={({ item: account }) => {
const isCurrentUser = addressesEqual(account, connectedAccount)
const [label, showLocalIdentityModal] = useIdentity(account)
Copy link
Contributor

Choose a reason for hiding this comment

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

We generally leave the "trailing" arguments if they're not used:

Suggested change
const [label, showLocalIdentityModal] = useIdentity(account)
const [label] = useIdentity(account)

/>
{isCurrentUser && <You />}
{isCurrentUser && Boolean(label) && <You />}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I wonder if we still need to show this? I understood the change as always showing just the identity badge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, when we have a custom label (like in the first case of the picture) I have to show the custom label or 'YOU'? I think the two things are relevant
I am only replacing for 'YOU' in the badge when it doesnt have a custom label

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha. I think keeping the "you" makes sense then. Let's double check what happens if you use a long label; ideally we will keep the "you" full width and shrink the label's size.

return (
<div>
<LocalIdentityBadge
entity={account}
connectedAccount={isCurrentUser}
customLabel={!Boolean(label) && isCurrentUser && 'YOU'}
labelStyle={(!Boolean(label) && isCurrentUser ? `color: ${theme.tagIndicatorContent};` : '')}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering—maybe we should move this logic into the LocalIdentityBadge.

We already provide a prop via connectedAccount to control whether or not it's "you", and we can detect and build off of this in that component. We can leave a prop to enable this "special" connected mode, to default the label and style.

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 didnt wanted to do it in LocalIdentityBadge cause I thought this change was only going to be used here because we dont have much space.

Copy link
Contributor

@sohkai sohkai Apr 10, 2020

Choose a reason for hiding this comment

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

Yes... I was thinking it could be a special mode of the LocalIdentityBadge but this falls apart with needing the label to detect whether we should display the "you".

Could we move to building these props as an object outside? I think it'll be a bit clearer to reason about.

E.g.

const identityBadgeProps = !isCurrentUser || !Boolean(label)
  ? {}
  : {
      customLabel: 'YOU'
      labelStyle: `color: ${theme.tagIndicatorContent};`
    }

(Or however prettier prefers 😄)

@delfipolito delfipolito requested a review from sohkai April 10, 2020 14:43
@delfipolito delfipolito requested a review from sohkai April 13, 2020 15:27
Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

@delfipolito I've just added a few commits to polish this up a bit:

  • 9e7cd31: simplified the logic for displaying the 'YOU' (since it's always the "default"), and how the widths are adjusted (using flexbox and flex-shrink: 0)
  • 1b0bc12: updated the Holders data view entries to dynamically calculate max widths (this may cause some small conflicts with Tokens: Vesting UI #1137)
  • 1fb2106, 11d8f98: align LocalIdentityBadge implementations in all the other apps, so they all support the defaultLabel prop.

@delfipolito delfipolito merged commit 9965ae8 into master Jun 9, 2020
@delfipolito delfipolito deleted the token-holders-you-tag branch June 9, 2020 17:49
bingen pushed a commit that referenced this pull request Jun 16, 2020
ramilexe pushed a commit to ConsiderItDone/aragon-apps that referenced this pull request Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Token Manager: "you" pill is partially hidden in sidebar
2 participants