Skip to content

Commit f47dd3b

Browse files
mfbzchasefleming
andauthored
Added Profile component with Connect refactoring (#2685)
* Added Profile component with Connect refactoring * Update packages/demo/src/components/component-cards/profile-card.tsx Co-authored-by: Chase Fleming <chasefleming@users.noreply.github.com> * Updated profile component to use tabs --------- Co-authored-by: mfbz <mfbz@users.noreply.github.com> Co-authored-by: Chase Fleming <chasefleming@users.noreply.github.com>
1 parent bf3bdb1 commit f47dd3b

File tree

8 files changed

+1027
-323
lines changed

8 files changed

+1027
-323
lines changed

.changeset/nine-beers-behave.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@onflow/react-sdk": minor
3+
"@onflow/demo": minor
4+
---
5+
6+
Added standalone Profile component for displaying wallet information. The Profile component has been extracted from the Connect component modal to provide a reusable profile display that can be used independently. The component automatically detects connection state, showing a compact "No connected wallet" message when disconnected and full profile information when connected (including address, balance with cross-VM support, multi-token selector, copy/disconnect actions, and optional scheduled transactions).

packages/demo/src/components/component-cards/connect-card.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,22 @@ const PROPS: PropDefinition[] = [
7070
description:
7171
"Configuration for the profile modal (like show scheduled transactions, filter handler types)",
7272
},
73+
{
74+
name: "modalEnabled",
75+
type: "boolean",
76+
required: false,
77+
description:
78+
"Controls whether the profile modal opens on click when connected. Set to false to manage the profile display externally.",
79+
defaultValue: "true",
80+
},
7381
]
7482

7583
export function ConnectCard() {
7684
const {darkMode} = useDarkMode()
7785
const {data: chainId, isLoading} = useFlowChainId()
7886
const isEmulator = chainId === "emulator" || chainId === "local"
7987
const [showMultiToken, setShowMultiToken] = useState(false)
88+
const [modalEnabled, setModalEnabled] = useState(true)
8089
const [balanceType, setBalanceType] = useState<
8190
"cadence" | "evm" | "combined"
8291
>("cadence")
@@ -218,9 +227,13 @@ export function ConnectCard() {
218227
<Connect
219228
balanceType={balanceType}
220229
balanceTokens={multiTokens}
230+
modalEnabled={modalEnabled}
221231
/>
222232
) : (
223-
<Connect balanceType={balanceType} />
233+
<Connect
234+
balanceType={balanceType}
235+
modalEnabled={modalEnabled}
236+
/>
224237
)}
225238
</div>
226239
)}
@@ -282,6 +295,28 @@ export function ConnectCard() {
282295
))}
283296
</div>
284297
</div>
298+
299+
<div>
300+
<label
301+
className={`text-xs font-medium mb-2 block ${darkMode ? "text-gray-500" : "text-gray-500"}`}
302+
>
303+
Profile Modal
304+
</label>
305+
<button
306+
onClick={() => setModalEnabled(!modalEnabled)}
307+
className={`w-full text-sm px-3 py-2 rounded-lg transition-colors ${
308+
modalEnabled
309+
? darkMode
310+
? "bg-blue-600 hover:bg-blue-700 text-white"
311+
: "bg-blue-500 hover:bg-blue-600 text-white"
312+
: darkMode
313+
? "bg-gray-800 hover:bg-gray-700 text-white"
314+
: "bg-white hover:bg-gray-100 text-black border border-black/10"
315+
}`}
316+
>
317+
{modalEnabled ? "Enabled" : "Disabled"}
318+
</button>
319+
</div>
285320
</div>
286321
)}
287322
</div>

0 commit comments

Comments
 (0)