Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
746ff83
Minimized the account center button removing balance, address and net…
mahmud-bn May 13, 2022
8ced9a7
Remove disconnect all wallets and connect another wallet option on mo…
mahmud-bn May 13, 2022
6f9caba
Remove disconnect all wallets and connect another wallet option on mo…
mahmud-bn May 15, 2022
033f094
Version bump
mahmud-bn May 16, 2022
acf188b
Formatting
mahmud-bn May 16, 2022
c97080f
Merge branch 'v2-web3-onboard-develop' into feature/minimal-account-c…
mahmud-bn May 16, 2022
056fedf
Version bump
mahmud-bn May 16, 2022
c1da776
Added yarn lock to gitignore
mahmud-bn May 16, 2022
8a98e3f
Version bump
mahmud-bn May 16, 2022
1a7d3b9
Yarn lock fix
mahmud-bn May 16, 2022
69a657f
Delete yarn.lock
mahmud-bn May 16, 2022
1a0236b
Spacing and documentation update
mahmud-bn May 16, 2022
28e52c3
Documentation update
mahmud-bn May 16, 2022
64bc5ed
Demo core version package update
mahmud-bn May 16, 2022
bfd5749
fixes
mahmud-bn May 17, 2022
df44144
Desktop and Mobile configurations
mahmud-bn May 19, 2022
c8a4371
Refine constant configurations
mahmud-bn May 19, 2022
57063c2
Refine constant configurations
mahmud-bn May 19, 2022
85982f4
Remove commented code
mahmud-bn May 20, 2022
f878b29
Remove empty lines
mahmud-bn May 20, 2022
513ca8a
Packages bump
mahmud-bn May 20, 2022
7264c0b
Documentation update
mahmud-bn May 20, 2022
9d89446
Cleanup
mahmud-bn May 23, 2022
3c14ecf
Conflicts fix
mahmud-bn May 23, 2022
ab64222
Conflicts fix
mahmud-bn May 23, 2022
0963513
styling fixes
mahmud-bn May 24, 2022
8627708
styling fixes
mahmud-bn May 24, 2022
83dc78d
fixes
mahmud-bn May 24, 2022
c36c035
Change width based on micro state
lnbc1QWFyb24 May 25, 2022
1babd9a
Remove yarn.lock from demo
lnbc1QWFyb24 May 25, 2022
5705efd
Revert yarn.lock changes
lnbc1QWFyb24 May 25, 2022
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
36 changes: 25 additions & 11 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,19 @@ To see a list of all of the text values that can be internationalized or replace
Onboard is using the [ICU syntax](https://formatjs.io/docs/core-concepts/icu-syntax/) for formatting under the hood.

**`accountCenter`**
An object that defines whether the account center UI is enabled and it's position on the screen. Currently the account center is disabled for mobile devices, so only desktop options are available.
An object that defines whether the account center UI (default and minimal) is enabled and it's position on the screen. Currently the account center is enabled for both desktop and mobile devices.

```typescript
type AccountCenterOptions = {
desktop: {
position?: AccountCenterPosition // default: 'topRight'
enabled?: AccountCenter['enabled'] // default: true
}
export type AccountCenter = {
enabled: boolean
position?: AccountCenterPosition // default: 'topRight'
expanded?: boolean // default: true
minimal?: boolean // enabled by default for mobile
}

type AccountCenter = {
enabled: boolean
position: AccountCenterPosition
expanded: boolean
export type AccountCenterOptions = {
desktop: Omit<AccountCenter, 'expanded'>
mobile: Omit<AccountCenter, 'expanded'>
}

type AccountCenterPosition =
Expand Down Expand Up @@ -175,6 +174,18 @@ const onboard = Onboard({
{ name: 'Coinbase', url: 'https://wallet.coinbase.com/' }
]
},
accountCenter: {
desktop: {
position: 'topRight',
enabled: true,
minimal: true
},
mobile: {
position: 'topRight',
enabled: true,
minimal: true
}
},
i18n: {
en: {
connect: {
Expand Down Expand Up @@ -316,6 +327,7 @@ type AccountCenter = {
enabled: boolean
position: AccountCenterPosition
expanded: boolean
minimal: boolean
}

type AccountCenterPosition =
Expand Down Expand Up @@ -516,8 +528,10 @@ The Onboard styles can customized via [CSS variables](https://developer.mozilla.
--onboard-spacing-4: 1rem;
--onboard-spacing-5: 0.5rem;

/* SHADOWS */
/* BORDER RADIUS */
--onboard-border-radius-1: 24px;
--onboard-border-radius-2: 20px;
--onboard-border-radius-3: 16px;

/* SHADOWS */
--onboard-shadow-0: none;
Expand Down
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.2.9-alpha.2",
"version": "2.2.9-alpha.3",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AppState } from './types'
import { getDevice } from './utils'

export const APP_INITIAL_STATE: AppState = {
wallets: [],
Expand All @@ -7,7 +8,8 @@ export const APP_INITIAL_STATE: AppState = {
accountCenter: {
enabled: true,
position: 'topRight',
expanded: false
expanded: false,
minimal: getDevice().type === 'mobile'
},
locale: ''
}
Expand Down
33 changes: 22 additions & 11 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import initI18N from './i18n'

import App from './views/Index.svelte'
import type { InitOptions, OnboardAPI } from './types'
import { APP_INITIAL_STATE } from './constants'
import { getDevice } from './utils'

const API = {
Expand Down Expand Up @@ -58,19 +59,26 @@ function init(options: InitOptions): OnboardAPI {
initI18N(i18n)
addChains(chains)

let accountCenterUpdate

const device = getDevice()

if (device.type === 'mobile') {
accountCenterUpdate = {
enabled: false

// update accountCenter
if (typeof accountCenter !== 'undefined') {
let accountCenterUpdate

if (device.type === 'mobile' && accountCenter.mobile) {
accountCenterUpdate = {
...APP_INITIAL_STATE.accountCenter,
...accountCenter.mobile
}
} else if (accountCenter.desktop) {
accountCenterUpdate = {
...APP_INITIAL_STATE.accountCenter,
...accountCenter.desktop
}
}
} else if (typeof accountCenter !== 'undefined' && accountCenter.desktop) {
accountCenterUpdate = accountCenter.desktop
}

accountCenterUpdate && updateAccountCenter(accountCenterUpdate)
updateAccountCenter(accountCenterUpdate)
}

const { svelteInstance } = internalState$.getValue()

Expand Down Expand Up @@ -187,7 +195,10 @@ function mountApp() {
--spacing-7: 0.125rem;

/* BORDER RADIUS */
--border-radius-1: 24px;
--border-radius-1: 24px;
--border-radius-2: 20px;
--border-radius-3: 16px;


/* SHADOWS */
--shadow-0: none;
Expand Down
17 changes: 8 additions & 9 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,16 @@ export type AccountCenterPosition =
| 'bottomLeft'
| 'topLeft'

export type AccountCenterOptions = {
desktop?: {
export type AccountCenter = {
enabled: boolean
position?: AccountCenterPosition
enabled?: AccountCenter['enabled']
}
expanded?: boolean
minimal?: boolean
}

export type AccountCenter = {
enabled: boolean
position: AccountCenterPosition
expanded: boolean

export type AccountCenterOptions = {
desktop: Omit<AccountCenter, 'expanded'>
mobile: Omit<AccountCenter, 'expanded'>
}

// ==== ACTIONS ==== //
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ const initOptions = Joi.object({
accountCenter: Joi.object({
desktop: Joi.object({
enabled: Joi.boolean(),
minimal: Joi.boolean(),
position: accountCenterPosition
}),
mobile: Joi.object({
enabled: Joi.boolean(),
position: accountCenterPosition
minimal: Joi.boolean(),
position: accountCenterPosition,
})
})
})
Expand Down Expand Up @@ -146,7 +148,8 @@ const setChainOptions = Joi.object({
const accountCenter = Joi.object({
enabled: Joi.boolean(),
position: accountCenterPosition,
expanded: Joi.boolean()
expanded: Joi.boolean(),
minimal: Joi.boolean()
})

type ValidateReturn = Joi.ValidationResult | null
Expand Down
19 changes: 15 additions & 4 deletions packages/core/src/views/account-center/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import type { AccountCenter } from '../../types'
import Maximized from './Maximized.svelte'
import Minimized from './Minimized.svelte'
import Micro from './Micro.svelte'

export let settings: AccountCenter

Expand All @@ -28,21 +29,31 @@
<style>
.container {
padding: 16px;
max-width: 364px;
min-width: 348px;
font-family: var(--onboard-font-family-normal, var(--font-family-normal));
width: 100%;
}

@media all and (min-width: 428px) {
.container {
max-width: 352px;
}
}
</style>

<svelte:window on:click={minimize} />

<div
class="container flex flex-column absolute"
style={accountCenterPositions[settings.position]}
style="{accountCenterPositions[
settings.position
]} width: {!settings.expanded && settings.minimal ? 'auto' : '100%'}"
>
{#if !settings.expanded}
{#if !settings.expanded && !settings.minimal}
<!-- minimized -->
<Minimized />
{:else if !settings.expanded && settings.minimal}
<!-- micro -->
<Micro />
{:else}
<!-- maximized -->
<Maximized />
Expand Down
61 changes: 32 additions & 29 deletions packages/core/src/views/account-center/Maximized.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { updateAccountCenter } from '../../store/actions'
import blocknative from '../../icons/blocknative'
import DisconnectAllConfirm from './DisconnectAllConfirm.svelte'
import { getDevice } from '../../utils'

function disconnectAllWallets() {
$wallets$.forEach(({ label }) => disconnect({ label }))
Expand All @@ -44,12 +45,13 @@
)

const { position } = state.get().accountCenter
const device = getDevice()
</script>

<style>
.outer-container {
background-color: var(--onboard-gray-600, var(--gray-600));
border-radius: 16px;
border-radius: var(--onboard-border-radius-3, var(--border-radius-3));
width: 100%;
filter: drop-shadow(0px 4px 16px rgba(178, 178, 178, 0.2));
}
Expand Down Expand Up @@ -228,38 +230,40 @@
/>
{/each}
</div>

<!-- actions -->
<div class="actions flex flex-column items-start">
<!-- connect another wallet -->
<div
on:click={() => connect()}
class="action-container flex items-center pointer"
>
<div class="plus-icon flex items-center justify-center">
{@html plusCircleIcon}
</div>
<span class="action-text"
>{$_('accountCenter.connectAnotherWallet', {
default: en.accountCenter.connectAnotherWallet
})}</span
<!-- Hide for Mobile -->
{#if device.type === 'desktop'}
<!-- connect another wallet -->
<div
on:click={() => connect()}
class="action-container flex items-center pointer"
>
</div>

<!-- disconnect all wallets -->
<div
on:click={() => (disconnectConfirmModal = true)}
class="action-container flex items-center mt pointer"
>
<div class="arrow-forward flex items-center justify-center">
{@html arrowForwardIcon}
<div class="plus-icon flex items-center justify-center">
{@html plusCircleIcon}
</div>
<span class="action-text"
>{$_('accountCenter.connectAnotherWallet', {
default: en.accountCenter.connectAnotherWallet
})}</span
>
</div>
<span class="action-text"
>{$_('accountCenter.disconnectAllWallets', {
default: en.accountCenter.disconnectAllWallets
})}</span

<!-- disconnect all wallets -->
<div
on:click={() => (disconnectConfirmModal = true)}
class="action-container flex items-center mt pointer"
>
</div>
<div class="arrow-forward flex items-center justify-center">
{@html arrowForwardIcon}
</div>
<span class="action-text"
>{$_('accountCenter.disconnectAllWallets', {
default: en.accountCenter.disconnectAllWallets
})}</span
>
</div>
{/if}
</div>
</div>

Expand Down Expand Up @@ -414,7 +418,6 @@
default: en.accountCenter.backToApp
})}</button
>

<a
href="https://blocknative.com"
target="_blank"
Expand Down
Loading