Skip to content

Conversation

@caffeinum
Copy link
Member

@caffeinum caffeinum commented Jun 20, 2022

Added connect wallet component that keeps track of the modal state open/closed. Use like this:

import { ProfileView, AddressView } from "@buildship/web3-login";

...
  
  <ProfileView {...} />

  <AddressView isShort={true} />

@vercel
Copy link

vercel bot commented Jun 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
web3-login ✅ Ready (Inspect) Visit Preview Jun 20, 2022 at 2:08PM (UTC)

@caffeinum caffeinum changed the title Feature/components components: add ConnectWalletButton, AddressView Jun 20, 2022
{!address && (
renderButton
? renderButton({ text: "Connect Wallet", onClick: () => setOpen(true) })
: <button onClick={() => setOpen(true)}>Connect Wallet</button>
Copy link
Member

@theshadowagent theshadowagent Jun 20, 2022

Choose a reason for hiding this comment

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

Should use <Button variant="contained" /> from @mui by default since it's already dependent on this UI library

* @param isShort - If true, the address is displayed in short format: 0xff...abcd
* @returns {JSX.Element}
*/
export const AddressView = ({ isShort = true }: Props): JSX.Element => {
Copy link
Member

Choose a reason for hiding this comment

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

How to style <AddressView />? Consider wrapping in @mui <Box /> and passing styling props: sx, style, className

: <button onClick={() => setOpen(true)}>Connect Wallet</button>
)}

{showDisconnect && address && (
Copy link
Member

Choose a reason for hiding this comment

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

Consider moving disconnect logic to a <ProfileView /> component
image
image

navigator.clipboard.writeText(address)

// TODO: show a snackbar
window.alert("Address copied to clipboard")
Copy link
Member

Choose a reason for hiding this comment

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

@theshadowagent
Copy link
Member

I'd still prefer having a simple <ConnectWallet /> component that is just a button that connects wallet

<AddressView />
</Typography>}

{showDisconnect && address && (renderButton({
Copy link
Member

@theshadowagent theshadowagent Jun 20, 2022

Choose a reason for hiding this comment

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

Popup might also be better from a UX perspective because users can accidentally log out if this button is so visible. I heard stories of 10x difference in log out rates because of unaware users who just click on things. Can be added in the future release

@caffeinum caffeinum mentioned this pull request Jun 21, 2022
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.

3 participants