Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core-v2.3.1-alpha.3]: Feature - Allow defining container element for account center #1096

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/core",
"version": "2.4.0-alpha.6",
"version": "2.4.0-alpha.7",
"repository": "blocknative/web3-onboard",
"scripts": {
"build": "rollup -c",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const APP_INITIAL_STATE: AppState = {
enabled: true,
position: 'topRight',
expanded: false,
containerElement: 'body',
minimal: configuration.device.type === 'mobile'
},
notify: {
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,13 @@ function mountApp() {
</style>
`

document.body.appendChild(onboard)
const containerElementQuery = state.get().accountCenter.containerElement || 'body'
const containerElement = document.querySelector(containerElementQuery)
if (!containerElement) {
throw new Error(`Element with query ${state.get().accountCenter} does not exist.`)
}

containerElement.appendChild(onboard)

const app = new App({
target
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export type NotificationPosition = CommonPositions
export type AccountCenter = {
enabled: boolean
position?: AccountCenterPosition
containerElement?: string
expanded?: boolean
minimal?: boolean
}
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,14 @@ const initOptions = Joi.object({
desktop: Joi.object({
enabled: Joi.boolean(),
minimal: Joi.boolean(),
position: commonPositions
position: commonPositions,
containerElement: Joi.string()
}),
mobile: Joi.object({
enabled: Joi.boolean(),
minimal: Joi.boolean(),
position: commonPositions
position: commonPositions,
containerElement: Joi.string()
})
}),
notify: [notifyOptions, notify]
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@web3-onboard/coinbase": "^2.0.7",
"@web3-onboard/core": "^2.4.0-alpha.6",
"@web3-onboard/core": "^2.4.0-alpha.7",
"@web3-onboard/dcent": "^2.0.4",
"@web3-onboard/fortmatic": "^2.0.6",
"@web3-onboard/gnosis": "^2.0.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/react",
"version": "2.2.3-alpha.4",
"version": "2.2.3-alpha.5",
"description": "Collection of React Hooks for web3-onboard",
"repository": "blocknative/web3-onboard",
"module": "dist/index.js",
Expand All @@ -24,7 +24,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/core": "^2.4.0-alpha.6",
"@web3-onboard/core": "^2.4.0-alpha.7",
"@web3-onboard/common": "^2.1.4",
"use-sync-external-store": "1.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/vue",
"version": "2.1.3-alpha.4",
"version": "2.1.3-alpha.5",
"description": "Vue Composable for web3-onboard",
"repository": "blocknative/web3-onboard",
"module": "dist/index.js",
Expand All @@ -25,7 +25,7 @@
"@vueuse/core": "^8.4.2",
"@vueuse/rxjs": "^8.2.0",
"@web3-onboard/common": "^2.1.4",
"@web3-onboard/core": "^2.4.0-alpha.6",
"@web3-onboard/core": "^2.4.0-alpha.7",
"vue-demi": "^0.12.4"
},
"peerDependencies": {
Expand Down