Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
feat(nextjs): example app UI updates
Browse files Browse the repository at this point in the history
  • Loading branch information
drichar committed Feb 23, 2024
1 parent c50e8aa commit d536649
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
24 changes: 21 additions & 3 deletions examples/nextjs/src/app/Connect.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.walletName {
margin-bottom: 0.25em;
line-height: 1.5;
margin: 1.33em 0;
text-align: center;
}

.walletName[data-active='true']:after {
content: ' [active]';
}

.walletButtons {
Expand All @@ -8,7 +14,7 @@
justify-content: center;
flex-wrap: wrap;
gap: 0.5em;
margin-bottom: 2em;
margin-bottom: 0.9em;
}

.walletButtons button {
Expand All @@ -34,8 +40,20 @@
cursor: default;
}

.walletMenu {
margin-top: 1.5em;
}

.fallbackMsg {
font-size: 1.125rem;
line-height: 1.5rem;
text-align: center;
opacity: 0.5;
margin: 2em 0;
}

@media (prefers-color-scheme: light) {
.walletButtons button {
background-color: #f9f9f9;
background-color: #ffffff;
}
}
16 changes: 14 additions & 2 deletions examples/nextjs/src/app/Connect.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { useWallet } from '@txnlab/use-wallet-react'
import * as React from 'react'
import styles from './Connect.module.css'

export function Connect() {
const [isReady, setIsReady] = React.useState(false)

React.useEffect(() => {
setIsReady(true)
}, [])

const { wallets } = useWallet()

if (!isReady) {
return <p className={styles.fallbackMsg}>Loading wallets&hellip;</p>
}

return (
<div>
{wallets.map((wallet) => (
<div key={wallet.id}>
<h4 className={styles.walletName}>
{wallet.metadata.name} {wallet.isActive ? '[active]' : ''}
<h4 className={styles.walletName} data-active={wallet.isActive}>
{wallet.metadata.name}
</h4>
<div className={styles.walletButtons}>
<button type="button" onClick={() => wallet.connect()} disabled={wallet.isConnected}>
Expand All @@ -33,6 +44,7 @@ export function Connect() {
{wallet.isActive && wallet.accounts.length > 0 && (
<div>
<select
className={styles.walletMenu}
onChange={(event: React.ChangeEvent<HTMLSelectElement>) => {
const target = event.target
wallet.setActiveAccount(target.value)
Expand Down
13 changes: 11 additions & 2 deletions examples/nextjs/src/app/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
align-items: center;
position: relative;
padding: 4rem 0;
row-gap: 3rem;
}

.center::before {
Expand All @@ -92,13 +91,14 @@
height: 360px;
margin-left: -400px;
pointer-events: none;
z-index: -1;
}

.center::after {
background: var(--primary-glow);
width: 240px;
height: 180px;
z-index: -1;
z-index: -2;
pointer-events: none;
}

Expand All @@ -113,7 +113,16 @@

.logo {
position: relative;
margin: 1.5em;
}

.heading {
text-align: center;
font-size: 3.2em;
line-height: 1.1;
margin: 0.67em 0 0.25em;
}

/* Enable hover only on non-touch devices */
@media (hover: hover) and (pointer: fine) {
.card:hover {
Expand Down
1 change: 1 addition & 0 deletions examples/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function Home() {
height={37}
priority
/>
<h1 className={styles.heading}>@txnlab/use-wallet-react</h1>
<Connect />
</div>
</main>
Expand Down

0 comments on commit d536649

Please sign in to comment.