Skip to content

Commit c3a931a

Browse files
committed
Update README.md to include quick information about the new Button component
1 parent 3b6e87c commit c3a931a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const kit: StellarWalletsKit = new StellarWalletsKit({
5858
});
5959
```
6060

61-
## Integrated UI modal
61+
## Integrated UI Modal
6262

6363
![](./modal-ui.gif)
6464

@@ -86,6 +86,36 @@ function openModal(params: {
8686
}) {}
8787
```
8888

89+
## Integrated UI Button
90+
91+
![](./button-ui.gif)
92+
93+
Just like with the built-in modal component, the kit also includes a `Button` component that helps you to show an easy-to-use interface to your users so they can connect/disconnect their wallet while your site gets updates for when that happens. Here is how you can use it:
94+
95+
```typescript
96+
await kit.createButton({
97+
container: document.querySelector('#containerDiv'),
98+
onConnect: ({ address}) => {
99+
// Do something when the user "connects" the wallet, like fetching the account data
100+
},
101+
onDisconnect: () => {
102+
// Do something when the user "disconnects" the wallet, like clearing all site data and reload
103+
}
104+
})
105+
```
106+
107+
With just that you will include an interactive button on your website that will show the built-in modal to the user, fetch the public key, fetch the current XLM balance (if you provide a horizon URL), and give the user a UI to use!.
108+
109+
You can see all the parameters you can include:
110+
```typescript
111+
function createButton(params: {
112+
container: HTMLElement;
113+
onConnect: (response: { address: string }) => void;
114+
onDisconnect: () => void;
115+
horizonUrl?: string;
116+
buttonText?: string;
117+
}): Promise<void> {}
118+
```
89119

90120
## Request the public key and sign transactions
91121

button-ui.gif

635 KB
Loading

0 commit comments

Comments
 (0)