-
Notifications
You must be signed in to change notification settings - Fork 212
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
Conversation
There was a problem hiding this 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.
apps/voting/app/src/components/LocalIdentityBadge/LocalIdentityBadge.js
Outdated
Show resolved
Hide resolved
* 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
There was a problem hiding this 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!
apps/voting/app/src/App.js
Outdated
/> | ||
)} | ||
</SidePanel> | ||
<IdentityProvider |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 overstyle
- Can we add
min-width: 320px
to the Main element?
There was a problem hiding this comment.
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 theMain
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; }
?
apps/voting/app/src/components/LocalIdentityBadge/LocalIdentityBadge.js
Outdated
Show resolved
Hide resolved
apps/voting/app/src/components/LocalIdentityBadge/LocalIdentityBadge.js
Outdated
Show resolved
Hide resolved
} | ||
|
||
const Wrap = styled.div` | ||
display: grid; |
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :).
There was a problem hiding this comment.
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.
9dc88e1
to
de294e0
Compare
* 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
* 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
What
Dependencies in other repos
@aragon/wrapper
and@aragon/api
Implement IdentityProvider aragon.js#253Nomenclature
IdentityBadge
component expects acustomLabel
prop)Todo before merging
@aragon/ui
once released with updated IdentityBadge@aragon/api
once released with identities functionality