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

components: add ConnectWalletButton, AddressView #10

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

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
src/package/components/AddressView.tsx Show resolved Hide resolved
{!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.

2 participants