Skip to content

Commit

Permalink
Fix scrollable area and sync modals height
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Sep 8, 2023
1 parent 7918030 commit db21303
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 45 deletions.
9 changes: 5 additions & 4 deletions src/app/components/Toolbar/Features/Contacts/AddContact.tsx
Expand Up @@ -9,6 +9,7 @@ import { contactsActions } from 'app/state/contacts'
import { Contact } from 'app/state/contacts/types'
import { ResponsiveLayer } from '../../../ResponsiveLayer'
import { ContactAccountForm } from './ContactAccountForm'
import { layerOverlayMinHeight } from './layer'

interface AddContactProps {
setLayerVisibility: (isVisible: boolean) => void
Expand All @@ -34,10 +35,10 @@ export const AddContact = ({ setLayerVisibility }: AddContactProps) => {
<Tabs alignControls="start">
<Tab title={t('toolbar.contacts.addContact', 'Add Contact')}>
<Box
gap="small"
pad={{ vertical: 'medium', right: 'small' }}
overflow={{ vertical: 'auto' }}
height="400px"
flex="grow"
justify="center"
height={{ min: layerOverlayMinHeight }}
pad={{ vertical: 'medium' }}
>
<ContactAccountForm setLayerVisibility={setLayerVisibility} submitHandler={submitHandler} />
</Box>
Expand Down
Expand Up @@ -10,6 +10,7 @@ import { Contact } from 'app/state/contacts/types'
import { Account } from '../Account/Account'
import { ResponsiveLayer } from '../../../ResponsiveLayer'
import { ContactAccountForm } from './ContactAccountForm'
import { layerOverlayMinHeight } from './layer'

interface ContactAccountProps {
contact: Contact
Expand Down Expand Up @@ -51,10 +52,10 @@ export const ContactAccount = ({ contact }: ContactAccountProps) => {
<Tabs alignControls="start">
<Tab title={t('toolbar.contacts.manage', 'Manage Contact')}>
<Box
gap="small"
pad={{ vertical: 'medium', right: 'small' }}
overflow={{ vertical: 'auto' }}
height="400px"
flex="grow"
justify="center"
height={{ min: layerOverlayMinHeight }}
pad={{ vertical: 'medium' }}
>
<ContactAccountForm
contact={contact}
Expand Down
45 changes: 17 additions & 28 deletions src/app/components/Toolbar/Features/Contacts/DeleteContact.tsx
Expand Up @@ -22,36 +22,25 @@ export const DeleteContact = ({ deleteHandler, setLayerVisibility }: DeleteConta
animation="none"
background="background-front"
modal
position="top"
margin={isMobile ? 'none' : 'xlarge'}

Check warning on line 25 in src/app/components/Toolbar/Features/Contacts/DeleteContact.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/components/Toolbar/Features/Contacts/DeleteContact.tsx#L25

Added line #L25 was not covered by tests
>
<Box margin="medium" width={isMobile ? 'auto' : '700px'}>
<Box
gap="small"
pad={{ vertical: 'medium', right: 'small' }}
overflow={{ vertical: 'auto' }}
height="440px"
>
<Box flex="grow" justify="center">
<Text weight="bold" size="medium" alignSelf="center" margin={{ bottom: 'large' }}>
{t('toolbar.contacts.deleteTitle', 'Delete Contact')}
</Text>
<Text size="medium" alignSelf="center">
{t('toolbar.contacts.deleteDescription', 'Are you sure you want to delete this contact?')}
</Text>
</Box>
<Box direction="row" align="center" justify="between" pad={{ top: 'medium' }}>
<Button
label={t('toolbar.contacts.cancel', 'Cancel')}
onClick={() => setLayerVisibility(false)}
/>
<Button
onClick={deleteHandler}
label={t('toolbar.contacts.deleteConfirmation', 'Yes, delete')}
color="status-error"
primary
/>
</Box>
<Box margin="medium">
<Box flex="grow" justify="center">
<Text weight="bold" size="medium" alignSelf="center" margin={{ bottom: 'large' }}>
{t('toolbar.contacts.deleteTitle', 'Delete Contact')}
</Text>
<Text size="medium" alignSelf="center">
{t('toolbar.contacts.deleteDescription', 'Are you sure you want to delete this contact?')}
</Text>
</Box>
<Box direction="row" align="center" justify="between" pad={{ top: 'medium' }}>
<Button label={t('toolbar.contacts.cancel', 'Cancel')} onClick={() => setLayerVisibility(false)} />

Check warning on line 37 in src/app/components/Toolbar/Features/Contacts/DeleteContact.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/components/Toolbar/Features/Contacts/DeleteContact.tsx#L37

Added line #L37 was not covered by tests
<Button
onClick={deleteHandler}
label={t('toolbar.contacts.deleteConfirmation', 'Yes, delete')}
color="status-error"
primary
/>
</Box>
</Box>
</ResponsiveLayer>
Expand Down
21 changes: 12 additions & 9 deletions src/app/components/Toolbar/Features/Contacts/index.tsx
@@ -1,12 +1,14 @@
import { useState } from 'react'
import { useState, useContext } from 'react'
import { useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'
import { Box } from 'grommet/es6/components/Box'
import { Button } from 'grommet/es6/components/Button'
import { ResponsiveContext } from 'grommet/es6/contexts/ResponsiveContext'
import { Inbox } from 'grommet-icons/es6/icons/Inbox'
import { selectContactsList } from 'app/state/contacts/selectors'
import { ContactAccount } from './ContactAccount'
import { AddContact } from './AddContact'
import { layerScrollableAreaHeight } from './layer'

const ContactsListEmptyState = () => {
const { t } = useTranslation()

Check warning on line 14 in src/app/components/Toolbar/Features/Contacts/index.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L14 was not covered by tests
Expand All @@ -23,21 +25,22 @@ export const Contacts = () => {
const { t } = useTranslation()
const [layerVisibility, setLayerVisibility] = useState(false)
const contacts = useSelector(selectContactsList)
const isMobile = useContext(ResponsiveContext) === 'small'

Check warning on line 28 in src/app/components/Toolbar/Features/Contacts/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/components/Toolbar/Features/Contacts/index.tsx#L25-L28

Added lines #L25 - L28 were not covered by tests

return (

Check warning on line 30 in src/app/components/Toolbar/Features/Contacts/index.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L30 was not covered by tests
<Box
gap="small"
pad={{ vertical: 'medium', right: 'small' }}
overflow={{ vertical: 'auto' }}
height="400px"
>
<>
{!contacts.length && (
<Box justify="center" flex="grow">

Check warning on line 33 in src/app/components/Toolbar/Features/Contacts/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/components/Toolbar/Features/Contacts/index.tsx#L32-L33

Added lines #L32 - L33 were not covered by tests
<ContactsListEmptyState />
</Box>
)}
{!!contacts.length && (
<Box flex="grow" gap="small">
<Box

Check warning on line 38 in src/app/components/Toolbar/Features/Contacts/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/components/Toolbar/Features/Contacts/index.tsx#L37-L38

Added lines #L37 - L38 were not covered by tests
gap="small"
pad={{ vertical: 'medium', right: 'small' }}
overflow={{ vertical: 'auto' }}
height={isMobile ? 'auto' : layerScrollableAreaHeight}

Check warning on line 42 in src/app/components/Toolbar/Features/Contacts/index.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L42 was not covered by tests
>
{contacts?.map(contact => <ContactAccount key={contact.address} contact={contact} />)}

Check warning on line 44 in src/app/components/Toolbar/Features/Contacts/index.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L44 was not covered by tests
</Box>
)}
Expand All @@ -49,6 +52,6 @@ export const Contacts = () => {
/>
</Box>
{layerVisibility && <AddContact setLayerVisibility={setLayerVisibility} />}

Check warning on line 54 in src/app/components/Toolbar/Features/Contacts/index.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L54 was not covered by tests
</Box>
</>
)
}
2 changes: 2 additions & 0 deletions src/app/components/Toolbar/Features/Contacts/layer.ts
@@ -0,0 +1,2 @@
export const layerScrollableAreaHeight = '400px'
export const layerOverlayMinHeight = '435px' // Keep child modals height in sync with parent modal

0 comments on commit db21303

Please sign in to comment.