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

Voting: Custom Labels / Local Identities #728

Merged
merged 17 commits into from
Mar 29, 2019
Merged

Conversation

2color
Copy link
Contributor

@2color 2color commented Mar 21, 2019

What

  • Local Identities (aka Custom Labels) in the Voting App.

Dependencies in other repos

Nomenclature

  • For consistency I tried to use the term identity
  • Only in the badge do I name things with label to reflect its actual use in the UI toolkit (the IdentityBadge component expects a customLabel prop)

Todo before merging

  • Bump minor version of @aragon/ui once released with updated IdentityBadge
  • Bump version of @aragon/api once released with identities functionality

@2color 2color requested review from bpierre, AquiGorka and sohkai March 21, 2019 12:45
@AquiGorka AquiGorka mentioned this pull request Mar 21, 2019
2 tasks
Copy link
Contributor

@AquiGorka AquiGorka left a comment

Choose a reason for hiding this comment

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

❤️ I like your naming conventions (mine was arbitrary ideas in the moment) so I'll update the other PRs for consistency.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.734% when pulling ba68612 on feature/custom-labels-voting into a7413ff on master.

@coveralls
Copy link

coveralls commented Mar 21, 2019

Coverage Status

Coverage remained the same at 96.734% when pulling a801346 on feature/custom-labels-voting into 3c3db0d on master.

2color added 4 commits March 26, 2019 12:27
* Move observable logic into a hook

* Combine identity contexts and define a custom hook

* Add missing propType

* Encapsulate both generation and handling of updates in hook
@AquiGorka AquiGorka self-requested a review March 27, 2019 11:46
@2color 2color mentioned this pull request Mar 27, 2019
3 tasks
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.

❤️ 😲💫

A few notes on the implementation, but this looks really good!

/>
)}
</SidePanel>
<IdentityProvider
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering how you feel about this @bpierre; I think I'd generally recommend putting <Main /> as the very first component that's rendered.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes let’s do this 👍

The only one that really need to be outside is the <div css="min-width: 320px">, so it applies to the elements rendered at the root level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two questions:

  • Is css a valid prop? Why is it used over style
  • Can we add min-width: 320px to the Main element?

Copy link
Contributor

@bpierre bpierre Mar 28, 2019

Choose a reason for hiding this comment

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

Is css a valid prop? Why is it used over style

It is being transformed by the styled-components babel plugin.

It transforms this:

import React from 'react'

const App = () => <div css="min-width: 320px" />

Into this:

import React from 'react'
import styled from 'styled-components'

const App = () => <A />

const A = styled.div`
  min-width: 320px
`

And it also works if you do this:

import React from 'react'

const items = ['apple', 'orange', 'banana']

const App = () => (
  <ul>
    {items.map(item => (
      // Only one styled component will be extracted by the babel transform.
      <li css="color: tomato">{item}</li>
    ))}
  </ul>
)

It is basically style, but without the downsides :-)

Can we add min-width: 320px to the Main element?

That’s something I keep wondering… We used to have AragonApp, which was defining some default styles, and it was causing too many issues. Main replaced it, and it was decided that it would not set anything styles, and only providing context. We can imagine a website widget using aragonUI, and being smaller than 320px, so it would be a problem to have it by default.

But on the other hand, developing a fullscreen app with aragonUI is quite a common use case… maybe we could have it as a prop, like minWidth, that would be either 0 or 320 by default?

Copy link
Contributor Author

@2color 2color Mar 28, 2019

Choose a reason for hiding this comment

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

Thanks for the clarification.

Can we add min-width: 320px to the Main element?

On that note, I actually meant to have it inline: <Main assetsUrl="./aragon-ui" css="min-width: 320px"> rather than a separate element.

Update: I did try this but it didn't work.

But on the other hand, developing a fullscreen app with aragonUI is quite a common use case… maybe we could have it as a prop, like minWidth, that would be either 0 or 320 by default?

I don't have an opinion on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, no it wouldn’t directly work because Main doesn’t render any DOM element. We could redirect styling props (style and className) to Root, but I would like to not encourage doing this, and prefer the minWidth solution for now.

@sohkai @AquiGorka any thoughts on that?

Copy link
Contributor

@AquiGorka AquiGorka Mar 29, 2019

Choose a reason for hiding this comment

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

html, body { min-width: 320px; }?

}

const Wrap = styled.div`
display: grid;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems a little bit unnecessary to use grid here 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see using grid as overkill over flex and I tend to use the first one before the latter by default. Let me know if you strongly think we'd need to use flex here.

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 not as familiar with the grid "language" as I am with the older layout ones, so that's partly why I'm not as comfortable using it everywhere.

But in general, my impression is that grid is so powerful you could probably build a spaceship with it, but it doesn't mean it's the best or easiest to maintain method of doing it :).

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider the verbosity levels here: if I were to use flex, I'd have to set the display on the container and then set flex-grow in one of the children with grid I get the same result with two rules on the container.

@2color 2color force-pushed the feature/custom-labels-voting branch from 9dc88e1 to de294e0 Compare March 28, 2019 17:44
@2color 2color merged commit 711f755 into master Mar 29, 2019
@2color 2color deleted the feature/custom-labels-voting branch March 29, 2019 10:00
facuspagnuolo pushed a commit that referenced this pull request Apr 4, 2019
* Voting: upgrade packages for local identities

* Add Identity and modal provider

* Voting: use LocalIdentityBadge

* LocalIdentityBadge: add lower case to check

* Version bump aragon/ui

* Upgrade aragon/api

* Make useEffect hook dependency explicit

* Abstract identity logic with a custom useIdentity react hook (#743)

* Move observable logic into a hook

* Combine identity contexts and define a custom hook

* Add missing propType

* Encapsulate both generation and handling of updates in hook

* Fix code formatting

* Default to null for when an identity is removed

* Handle case where identity resolves to null

* Use ternary operator

* Change order of nesting to have Main first

* Rename address to label

* propagate promise rejection

* Rename address to entity for consistency

* LocalIdentityBadge: fix var name error
ramilexe pushed a commit to ConsiderItDone/aragon-apps that referenced this pull request Dec 9, 2021
* Voting: upgrade packages for local identities

* Add Identity and modal provider

* Voting: use LocalIdentityBadge

* LocalIdentityBadge: add lower case to check

* Version bump aragon/ui

* Upgrade aragon/api

* Make useEffect hook dependency explicit

* Abstract identity logic with a custom useIdentity react hook (aragon#743)

* Move observable logic into a hook

* Combine identity contexts and define a custom hook

* Add missing propType

* Encapsulate both generation and handling of updates in hook

* Fix code formatting

* Default to null for when an identity is removed

* Handle case where identity resolves to null

* Use ternary operator

* Change order of nesting to have Main first

* Rename address to label

* propagate promise rejection

* Rename address to entity for consistency

* LocalIdentityBadge: fix var name error
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.

5 participants