You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/core/README.md
+49-34Lines changed: 49 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -121,20 +121,22 @@ type AccountCenterPosition =
121
121
**`notify`**
122
122
Notify provides by default transaction notifications for all connected wallets on the current blockchain. When switching chains the previous chain listeners remain active for 60 seconds to allow capture and report of an remaining transactions that may be in flight.
123
123
By default transaction notifications are captured if a DAppID is provided in the Onboard config along with the Account Center being enabled.
124
-
An object that defines whether transaction notifications will display (defaults to true if an API key is provided). This object contains an `enabled` flag prop and an optional `transactionHandler` which is a callback that can disable or allow customizations of notifications.
124
+
An object that defines whether transaction notifications will display (defaults to true if an API key is provided). This object contains an `enabled` flag prop and an optional `transactionHandler` which is a callback that can disable or allow customizations of notifications.
125
125
Currently notifications are positioned in the same location as the account center (either below, if the Account Center is positioned along the top, or above if positioned on the bottom of the view).
126
126
The `transactionHandler` can react off any property of the Ethereum TransactionData returned to the callback from the event (see console.log in example init). In turn, it can return a Custom `Notification` object to define the verbiage, styling, or add functionality:
127
-
- `Notification.message` - to completely customize the message shown
128
-
- `Notification.eventCode` - handle codes in your own way - see codes here under the notify prop [default en file here](src/i18n/en.json)
129
-
- `Notification.type` - icon type displayed (see `NotificationType` below for options)
130
-
- `Notification.autoDismiss` - time (in ms) after which the notification will be dismissed. If set to `0` the notification will remain on screen until the user dismisses the notification, refreshes the page or navigates away from the site with the notifications
131
-
- `Notification.link` - add link to the transaction hash. For instance, a link to the transaction on etherscan
132
-
- `Notification.onClick()` - onClick handler for when user clicks the notification element
133
127
134
-
Notify can also be styled by using the CSS variables found below. These are setup to allow maximum customization with base styling variables setting the global theme (i.e. `--onboard-grey-600`) along with more precise component level styling variables available (`--notify-onboard-grey-600`) with the latter taking precedent if defined
128
+
- `Notification.message` - to completely customize the message shown
129
+
- `Notification.eventCode` - handle codes in your own way - see codes here under the notify prop [default en file here](src/i18n/en.json)
130
+
- `Notification.type` - icon type displayed (see `NotificationType` below for options)
131
+
- `Notification.autoDismiss` - time (in ms) after which the notification will be dismissed. If set to `0` the notification will remain on screen until the user dismisses the notification, refreshes the page or navigates away from the site with the notifications
132
+
- `Notification.link` - add link to the transaction hash. For instance, a link to the transaction on etherscan
133
+
- `Notification.onClick()` - onClick handler for when user clicks the notification element
135
134
136
-
If notifications are enabled the notifications can be handled through onboard app state as seen below.
137
-
```javascript
135
+
Notify can also be styled by using the CSS variables found below. These are setup to allow maximum customization with base styling variables setting the global theme (i.e. `--onboard-grey-600`) along with more precise component level styling variables available (`--notify-onboard-grey-600`) with the latter taking precedent if defined
136
+
137
+
If notifications are enabled the notifications can be handled through onboard app state as seen below.
Notify can be used to deliver custom DApp notifications by passing a `CustomNotification` object to the `customNotification` action. This will return an `UpdateNotification` type.
191
-
This `UpdateNotification` will return an `update` function that can be passed a new `CustomNotification` to update the existing notification.
192
-
The `customNotification` method also returns a `dismiss` method that is called without any parameters to dismiss the notification.
193
-
204
+
Notify can be used to deliver custom DApp notifications by passing a `CustomNotification` object to the `customNotification` action. This will return an `UpdateNotification` type.
205
+
This `UpdateNotification` will return an `update` function that can be passed a new `CustomNotification` to update the existing notification.
206
+
The `customNotification` method also returns a `dismiss` method that is called without any parameters to dismiss the notification.
207
+
194
208
```typescript
195
-
const { update, dismiss } =
196
-
onboard.state.actions.customNotification({
197
-
type: 'pending',
198
-
message:
199
-
'This is a custom DApp pending notification to use however you want',
200
-
autoDismiss: 0
201
-
})
202
-
setTimeout(
203
-
() =>
204
-
update({
205
-
eventCode: 'dbUpdateSuccess',
206
-
message: 'Updated status for custom notification',
0 commit comments