Skip to content

Commit f8ae9e6

Browse files
authored
Merge pull request #2230 from oasisprotocol/mz/mobileAccList
Adjust My accounts and Contacts scrollable area heights on mobile
2 parents 20e3d2c + 5b2ef8b commit f8ae9e6

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
lines changed

.changelog/2230.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adjust My accounts and Contacts scrollable area heights on mobile

src/app/components/Toolbar/Features/AccountSelector/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,18 @@ exports[`<AccountSelector /> should match snapshot 1`] = `
233233
display: flex;
234234
box-sizing: border-box;
235235
max-width: 100%;
236+
-webkit-align-items: flex-end;
237+
-webkit-box-align: flex-end;
238+
-ms-flex-align: flex-end;
239+
align-items: flex-end;
236240
min-width: 0;
237241
min-height: 0;
238242
-webkit-flex-direction: row;
239243
-ms-flex-direction: row;
240244
flex-direction: row;
245+
-webkit-flex: 1 0 auto;
246+
-ms-flex: 1 0 auto;
247+
flex: 1 0 auto;
241248
-webkit-box-pack: justify;
242249
-webkit-justify-content: space-between;
243250
-ms-flex-pack: justify;
@@ -667,10 +674,11 @@ exports[`<AccountSelector /> should match snapshot 1`] = `
667674
>
668675
<div
669676
class="c1"
677+
style="height: 0px;"
670678
>
671679
<div
672680
class="c2"
673-
style="max-height: 400px;"
681+
style=""
674682
>
675683
<div
676684
aria-checked="false"

src/app/components/Toolbar/Features/AccountSelector/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import { selectAddress, selectWallets, selectHasOneAccount } from 'app/state/wal
88
import { selectUnlockedStatus } from 'app/state/selectUnlockedStatus'
99
import { Box } from 'grommet/es6/components/Box'
1010
import { Button } from 'grommet/es6/components/Button'
11-
import { memo } from 'react'
11+
import { memo, useContext } from 'react'
1212
import { useTranslation } from 'react-i18next'
1313
import { useDispatch, useSelector } from 'react-redux'
1414
import { ManageableAccount } from '../Account/ManageableAccount'
1515
import { ScrollableContainer } from '../ScrollableContainer'
1616
import { ButtonLink } from '../../../ButtonLink'
1717
import { Add } from 'grommet-icons/es6/icons/Add'
18+
import { ResponsiveContext } from 'grommet/es6/contexts/ResponsiveContext'
1819

1920
interface Props {
2021
closeHandler: () => any
@@ -32,7 +33,7 @@ export const AccountSelector = memo((props: Props) => {
3233
dispatch(walletActions.selectWallet(address))
3334
props.closeHandler()
3435
}
35-
36+
const isMobile = useContext(ResponsiveContext) === 'small'
3637
const accounts = Object.values(wallets).map(wallet => (
3738
<ManageableAccount
3839
closeHandler={props.closeHandler}
@@ -59,9 +60,9 @@ export const AccountSelector = memo((props: Props) => {
5960
))
6061

6162
return (
62-
<Box flex="grow" justify="between" gap="medium">
63+
<Box flex="grow" justify="between" gap="medium" style={{ height: isMobile ? '0' : 'auto' }}>
6364
<ScrollableContainer>{accounts}</ScrollableContainer>
64-
<Box direction="row" justify="between" gap="medium">
65+
<Box direction="row" justify="between" gap="medium" flex="grow" align="end">
6566
<ButtonLink
6667
icon={<Add a11yTitle={undefined} />}
6768
label={t('menu.addAccounts', 'Add accounts')}

src/app/components/Toolbar/Features/Contacts/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,16 @@ exports[`<Contacts /> should match snapshot 1`] = `
134134
align-items: flex-end;
135135
min-width: 0;
136136
min-height: 0;
137-
-webkit-flex-direction: column;
138-
-ms-flex-direction: column;
139-
flex-direction: column;
137+
-webkit-flex-direction: row;
138+
-ms-flex-direction: row;
139+
flex-direction: row;
140+
-webkit-flex: 1 0 auto;
141+
-ms-flex: 1 0 auto;
142+
flex: 1 0 auto;
143+
-webkit-box-pack: end;
144+
-webkit-justify-content: flex-end;
145+
-ms-flex-pack: end;
146+
justify-content: flex-end;
140147
}
141148
142149
.c2 {
@@ -394,10 +401,11 @@ exports[`<Contacts /> should match snapshot 1`] = `
394401
>
395402
<div
396403
class="c1"
404+
style="height: 0px;"
397405
>
398406
<div
399407
class="c2"
400-
style="max-height: 400px;"
408+
style=""
401409
>
402410
<div
403411
aria-checked="false"

src/app/components/Toolbar/Features/Contacts/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, ReactNode } from 'react'
1+
import { useState, useContext, ReactNode } from 'react'
22
import { useSelector } from 'react-redux'
33
import { Trans, useTranslation } from 'react-i18next'
44
import { useNavigate } from 'react-router-dom'
@@ -10,6 +10,7 @@ import { selectUnlockedStatus } from 'app/state/selectUnlockedStatus'
1010
import { ContactAccount } from './ContactAccount'
1111
import { AddContact } from './AddContact'
1212
import { ScrollableContainer } from '../ScrollableContainer'
13+
import { ResponsiveContext } from 'grommet/es6/contexts/ResponsiveContext'
1314

1415
type ContactsListEmptyStateProps = {
1516
children: ReactNode
@@ -34,6 +35,7 @@ export const Contacts = ({ closeHandler }: ContactsProps) => {
3435
const contacts = useSelector(selectContactsList)
3536
const unlockedStatus = useSelector(selectUnlockedStatus)
3637
const isAvailable = unlockedStatus === 'unlockedProfile'
38+
const isMobile = useContext(ResponsiveContext) === 'small'
3739
const navigate = useNavigate()
3840

3941
if (!isAvailable) {
@@ -63,7 +65,7 @@ export const Contacts = ({ closeHandler }: ContactsProps) => {
6365

6466
return (
6567
<>
66-
<Box flex="grow" justify="between" gap="medium">
68+
<Box flex="grow" justify="between" gap="medium" style={{ height: isMobile ? '0' : 'auto' }}>
6769
{!contacts.length && (
6870
<ContactsListEmptyState>
6971
{t('toolbar.contacts.emptyList', 'You have no contacts yet.')}
@@ -76,7 +78,7 @@ export const Contacts = ({ closeHandler }: ContactsProps) => {
7678
))}
7779
</ScrollableContainer>
7880
)}
79-
<Box align="end">
81+
<Box direction="row" justify="end" gap="medium" flex="grow" align="end">
8082
<Button
8183
primary
8284
label={t('toolbar.contacts.add', 'Add contact')}

src/app/components/Toolbar/Features/ScrollableContainer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const ScrollableContainer = ({ children }: ScrollableContainerProps) => {
1717
gap="small"
1818
pad={{ right: 'small', left: spaceForFocusIndicator }}
1919
overflow={{ vertical: 'auto' }}
20-
style={{ maxHeight: layerScrollableAreaHeight }}
20+
style={{ maxHeight: isMobile ? undefined : layerScrollableAreaHeight }}
2121
margin={{ bottom: isMobile ? 'large' : 'none', left: `-${spaceForFocusIndicator}` }}
2222
>
2323
{children}

0 commit comments

Comments
 (0)