Skip to content

Commit bb543ad

Browse files
authored
[core-2.3.1-alpha.2 , react-2.2.1-alpha.2]: enhancement - account-center-z-index (#1091)
* account-center-z-index * account-center-z-index * account-center-z-index * merge develop * merge develop
1 parent f514215 commit bb543ad

File tree

4 files changed

+57
-38
lines changed

4 files changed

+57
-38
lines changed

packages/core/README.md

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,22 @@ type AccountCenterPosition =
121121
**`notify`**
122122
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.
123123
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.
125125
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).
126126
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
133127
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
135134
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.
138+
139+
```javascript
138140
const wallets = onboard.state.select('notifications')
139141
const { unsubscribe } = wallets.subscribe(update =>
140142
console.log('transaction notifications: ', update)
@@ -146,7 +148,7 @@ unsubscribe()
146148

147149
```typescript
148150
export type NotifyOptions = {
149-
enabled: boolean // default: true
151+
enabled: boolean // default: true
150152
/**
151153
* Callback that receives all transaction events
152154
* Return a custom notification based on the event
@@ -177,7 +179,19 @@ export type Notification = {
177179

178180
export type NotificationType = 'pending' | 'success' | 'error' | 'hint'
179181

180-
export declare type Network = 'main' | 'testnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan' | 'xdai' | 'bsc-main' | 'matic-main' | 'fantom-main' | 'matic-mumbai' | 'local';
182+
export declare type Network =
183+
| 'main'
184+
| 'testnet'
185+
| 'ropsten'
186+
| 'rinkeby'
187+
| 'goerli'
188+
| 'kovan'
189+
| 'xdai'
190+
| 'bsc-main'
191+
| 'matic-main'
192+
| 'fantom-main'
193+
| 'matic-mumbai'
194+
| 'local'
181195

182196
export interface UpdateNotification {
183197
(notificationObject: CustomNotification): {
@@ -187,28 +201,26 @@ export interface UpdateNotification {
187201
}
188202
```
189203

190-
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+
194208
```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',
207-
type: 'success',
208-
autoDismiss: 8000
209-
}),
210-
4000
211-
)
209+
const { update, dismiss } = onboard.state.actions.customNotification({
210+
type: 'pending',
211+
message: 'This is a custom DApp pending notification to use however you want',
212+
autoDismiss: 0
213+
})
214+
setTimeout(
215+
() =>
216+
update({
217+
eventCode: 'dbUpdateSuccess',
218+
message: 'Updated status for custom notification',
219+
type: 'success',
220+
autoDismiss: 8000
221+
}),
222+
4000
223+
)
212224
```
213225

214226
### Initialization Example
@@ -309,7 +321,7 @@ const onboard = Onboard({
309321
},
310322
watched: {
311323
// Any words in brackets can be re-ordered or removed to fit your dapps desired verbiage
312-
"txPool": "Your account is {verb} {formattedValue} {asset} {preposition} {counterpartyShortened}"
324+
"txPool": "Your account is {verb} {formattedValue} {asset} {preposition} {counterpartyShortened}"
313325
}
314326
}
315327
},
@@ -618,6 +630,9 @@ The Onboard styles can customized via [CSS variables](https://developer.mozilla.
618630
--onboard-warning-600: #cc8c00;
619631
--onboard-warning-700: #664600;
620632

633+
/* CUSTOMIZE ACCOUNT CENTER STACK POSITIONING*/
634+
--account-center-z-index
635+
621636
/* CUSTOMIZE SECTIONS OF THE CONNECT MODAL */
622637
--onboard-connect-content-width
623638
--onboard-connect-content-height

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/core",
3-
"version": "2.3.1-alpha.1",
3+
"version": "2.3.1-alpha.2",
44
"scripts": {
55
"build": "rollup -c",
66
"dev": "rollup -c -w",

packages/core/src/views/Index.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@
258258
touch-action: none;
259259
}
260260
261+
.z-indexed {
262+
z-index: var(--account-center-z-index);
263+
}
264+
261265
@media all and (min-width: 428px) {
262266
.container {
263267
max-width: 348px;
@@ -279,7 +283,7 @@
279283

280284
{#if ($notify$.enabled || $accountCenter$.enabled) && $wallets$.length}
281285
<div
282-
class="container flex flex-column fixed"
286+
class="container flex flex-column fixed z-indexed"
283287
style="{accountCenterPositions[$accountCenter$.position]}; {device.type ===
284288
'mobile' && $accountCenter$.position.includes('top')
285289
? 'padding-bottom: 0;'

packages/react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/react",
3-
"version": "2.2.1-alpha.1",
3+
"version": "2.2.1-alpha.2",
44
"description": "Collection of React Hooks for web3-onboard",
55
"module": "dist/index.js",
66
"browser": "dist/index.js",
@@ -23,7 +23,7 @@
2323
"typescript": "^4.5.5"
2424
},
2525
"dependencies": {
26-
"@web3-onboard/core": "^2.3.1-alpha.1",
26+
"@web3-onboard/core": "^2.3.1-alpha.2",
2727
"@web3-onboard/common": "^2.1.3-alpha.1",
2828
"use-sync-external-store": "1.0.0"
2929
},

0 commit comments

Comments
 (0)