Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit 5923edd

Browse files
committed
feat: connect button character list
1 parent 0640982 commit 5923edd

4 files changed

Lines changed: 65 additions & 36 deletions

File tree

src/components/ConnectButton.tsx

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const ConnectButton: React.FC<{
8484
}) => {
8585
return (
8686
<div
87-
className="absolute right-10 top-10"
87+
className="absolute right-10 top-8 z-10"
8888
{...(!mounted && {
8989
"aria-hidden": true,
9090
style: {
@@ -98,20 +98,16 @@ export const ConnectButton: React.FC<{
9898
if (!mounted || !account || !chain) {
9999
return (
100100
<Button
101-
className="text-accent"
101+
className="text-accent h-10 rounded-full px-8 text-lg"
102102
onClick={openConnectModal}
103-
style={{ height: "30px" }}
104103
variant={variant || "primary"}
105104
>
106105
Connect
107106
</Button>
108107
)
109108
}
110109
return (
111-
<div
112-
className="relative group"
113-
style={{ gap: 12, height: "30px" }}
114-
>
110+
<div className="relative group h-10" style={{ gap: 12 }}>
115111
{characters.isSuccess ? (
116112
<>
117113
<button
@@ -128,23 +124,22 @@ export const ConnectButton: React.FC<{
128124
name={
129125
characters.data?.list?.[0]?.metadata?.content?.name
130126
}
131-
size={30}
127+
size={40}
132128
/>
133129
<div className="flex-1 flex flex-col min-w-0">
134130
<span
135-
className={`text-left leading-none font-medium truncate ${
131+
className={`text-left leading-tight font-medium truncate text-lg ${
136132
InsufficientBalance
137133
? "text-red-600"
138134
: "text-gray-600"
139135
}`}
140-
style={{ marginBottom: "0.15rem" }}
141136
>
142137
{characters.data?.list?.[0]?.metadata?.content
143138
?.name || account.displayName}
144139
</span>
145140
{characters.data?.list?.[0]?.handle && (
146141
<span
147-
className={`text-left leading-none text-xs truncate ${
142+
className={`text-left leading-tight truncate text-sm ${
148143
InsufficientBalance
149144
? "text-red-400"
150145
: "text-gray-400"
@@ -162,6 +157,44 @@ export const ConnectButton: React.FC<{
162157
}-0 pt-2 group-hover:block top-full z-10 text-gray-600`}
163158
>
164159
<div className="bg-white rounded-lg ring-1 ring-zinc-100 min-w-[140px] shadow-md py-2 text-sm">
160+
<div className="px-4 py-2 h-auto flex items-center w-full whitespace-nowrap font-medium">
161+
Your characters
162+
</div>
163+
{characters.data?.list?.length ? (
164+
characters.data?.list?.map((character) => (
165+
<UniLink
166+
key={character.handle}
167+
href={`/${character.handle}`}
168+
className="px-4 py-2 h-auto flex items-center w-full whitespace-nowrap hover:bg-zinc-100"
169+
>
170+
<Avatar
171+
className="align-middle mr-2"
172+
images={
173+
character.metadata?.content?.avatars || []
174+
}
175+
name={character.metadata?.content?.name}
176+
size={30}
177+
/>
178+
<span className="flex-1 flex flex-col min-w-0">
179+
<span className="text-left leading-none font-medium truncate">
180+
{character.metadata?.content?.name}
181+
</span>
182+
<span className="text-left leading-none text-xs truncate">
183+
{"@" + character.handle}
184+
</span>
185+
</span>
186+
{character.primary && (
187+
<span className="font-medium text-xs text-yellow-300 ml-2">
188+
🌟 Primary
189+
</span>
190+
)}
191+
</UniLink>
192+
))
193+
) : (
194+
<span className="px-4 py-2 h-auto flex items-center w-full whitespace-nowrap text-zinc-400">
195+
Empty
196+
</span>
197+
)}
165198
{InsufficientBalance && (
166199
<UniLink
167200
href="https://faucet.crossbell.io/"

src/pages/[handle].tsx

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,21 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
4242
ctx.params!.handle as string,
4343
queryClient,
4444
)
45-
await Promise.all([
46-
prefetchGetFollowers(character.characterId, queryClient),
47-
prefetchGetFollowings(character.characterId, queryClient),
48-
prefetchGetNotes(
49-
{
50-
characterId: character.characterId,
51-
limit: 10,
52-
},
53-
queryClient,
54-
),
55-
prefetchGetAchievements(character.characterId, queryClient),
56-
prefetchGetCalendar(character.characterId, queryClient),
57-
])
45+
if (character?.characterId) {
46+
await Promise.all([
47+
prefetchGetFollowers(character.characterId, queryClient),
48+
prefetchGetFollowings(character.characterId, queryClient),
49+
prefetchGetNotes(
50+
{
51+
characterId: character.characterId,
52+
limit: 10,
53+
},
54+
queryClient,
55+
),
56+
prefetchGetAchievements(character.characterId, queryClient),
57+
prefetchGetCalendar(character.characterId, queryClient),
58+
])
59+
}
5860

5961
return {
6062
props: {
@@ -89,8 +91,6 @@ export default function HandlePage() {
8991
}
9092
})
9193

92-
let currentLength = 0
93-
9494
return (
9595
<div className="relative flex flex-col items-center min-h-screen py-20">
9696
<Head>
@@ -237,7 +237,7 @@ export default function HandlePage() {
237237
(connected_account) => {
238238
const match = (
239239
(connected_account as any).uri || connected_account
240-
).match(/csb:\/\/account:(.*)@(.*)/)
240+
)?.match?.(/csb:\/\/account:(.*)@(.*)/)
241241
if (!match) {
242242
return null
243243
}
@@ -280,18 +280,15 @@ export default function HandlePage() {
280280
{!!notes.data?.pages?.[0]?.count &&
281281
notes.data?.pages?.map((page) =>
282282
page?.list.map((note) => {
283-
currentLength++
284283
return (
285284
<div
286285
key={note.noteId}
287286
className="mx-auto relative py-6 space-y-2 overflow-hidden border-b border-dashed last:border-b-0"
288287
>
289288
<UniLink
290289
href={
291-
note.metadata?.content?.sources?.includes("xlog") &&
292-
note.metadata?.content?.external_urls?.[0]
293-
? note.metadata?.content?.external_urls?.[0]
294-
: `https://crossbell.io/notes/${note.characterId}-${note.noteId}`
290+
note.metadata?.content?.external_urls?.[0] ||
291+
`https://crossbell.io/notes/${note.characterId}-${note.noteId}`
295292
}
296293
>
297294
<span className="w-full">

src/pages/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export default function Home() {
6363
<Image
6464
alt="xChar"
6565
src="/logos/crossbell.svg"
66-
width={250}
67-
height={68}
66+
width={375}
67+
height={102}
6868
priority
6969
/>
7070
</h1>

src/styles/globals.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010

1111
html,
1212
body {
13-
height: 100%;
14-
width: 100%;
13+
@apply h-full w-full cursor-default;
1514
}

0 commit comments

Comments
 (0)