Skip to content

Commit b2e2ec3

Browse files
moeintropee-moeintaylorjdawson
authored
* [Feature]: Allow defining container element for account center (#1096)
* [Feature]: Allow defining container element for account center * Version bumps + validation Co-authored-by: Moein Akbarof <moein@tropee.com> Co-authored-by: Taylor Dawson <taylorjdawson@gmail.com>
1 parent dc4d250 commit b2e2ec3

File tree

8 files changed

+19
-9
lines changed

8 files changed

+19
-9
lines changed

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.4.0-alpha.6",
3+
"version": "2.4.0-alpha.7",
44
"repository": "blocknative/web3-onboard",
55
"scripts": {
66
"build": "rollup -c",

packages/core/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const APP_INITIAL_STATE: AppState = {
99
enabled: true,
1010
position: 'topRight',
1111
expanded: false,
12+
containerElement: 'body',
1213
minimal: configuration.device.type === 'mobile'
1314
},
1415
notify: {

packages/core/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,13 @@ function mountApp() {
314314
</style>
315315
`
316316

317-
document.body.appendChild(onboard)
317+
const containerElementQuery = state.get().accountCenter.containerElement || 'body'
318+
const containerElement = document.querySelector(containerElementQuery)
319+
if (!containerElement) {
320+
throw new Error(`Element with query ${state.get().accountCenter} does not exist.`)
321+
}
322+
323+
containerElement.appendChild(onboard)
318324

319325
const app = new App({
320326
target

packages/core/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export type NotificationPosition = CommonPositions
138138
export type AccountCenter = {
139139
enabled: boolean
140140
position?: AccountCenterPosition
141+
containerElement?: string
141142
expanded?: boolean
142143
minimal?: boolean
143144
}

packages/core/src/validation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@ const initOptions = Joi.object({
159159
desktop: Joi.object({
160160
enabled: Joi.boolean(),
161161
minimal: Joi.boolean(),
162-
position: commonPositions
162+
position: commonPositions,
163+
containerElement: Joi.string()
163164
}),
164165
mobile: Joi.object({
165166
enabled: Joi.boolean(),
166167
minimal: Joi.boolean(),
167-
position: commonPositions
168+
position: commonPositions,
169+
containerElement: Joi.string()
168170
})
169171
}),
170172
notify: [notifyOptions, notify]

packages/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"dependencies": {
2525
"@web3-onboard/coinbase": "^2.0.7",
26-
"@web3-onboard/core": "^2.4.0-alpha.6",
26+
"@web3-onboard/core": "^2.4.0-alpha.7",
2727
"@web3-onboard/dcent": "^2.0.4",
2828
"@web3-onboard/fortmatic": "^2.0.6",
2929
"@web3-onboard/gnosis": "^2.0.5",

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.3-alpha.4",
3+
"version": "2.2.3-alpha.5",
44
"description": "Collection of React Hooks for web3-onboard",
55
"repository": "blocknative/web3-onboard",
66
"module": "dist/index.js",
@@ -24,7 +24,7 @@
2424
"typescript": "^4.5.5"
2525
},
2626
"dependencies": {
27-
"@web3-onboard/core": "^2.4.0-alpha.6",
27+
"@web3-onboard/core": "^2.4.0-alpha.7",
2828
"@web3-onboard/common": "^2.1.4",
2929
"use-sync-external-store": "1.0.0"
3030
},

packages/vue/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/vue",
3-
"version": "2.1.3-alpha.4",
3+
"version": "2.1.3-alpha.5",
44
"description": "Vue Composable for web3-onboard",
55
"repository": "blocknative/web3-onboard",
66
"module": "dist/index.js",
@@ -25,7 +25,7 @@
2525
"@vueuse/core": "^8.4.2",
2626
"@vueuse/rxjs": "^8.2.0",
2727
"@web3-onboard/common": "^2.1.4",
28-
"@web3-onboard/core": "^2.4.0-alpha.6",
28+
"@web3-onboard/core": "^2.4.0-alpha.7",
2929
"vue-demi": "^0.12.4"
3030
},
3131
"peerDependencies": {

0 commit comments

Comments
 (0)