-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from farrah-deriv/FEQ-2190/app-layout
farrah/FEQ-2190/Header and footer integration
- Loading branch information
Showing
31 changed files
with
333 additions
and
102 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.app-footer { | ||
padding: 2.4rem; | ||
|
||
&__language-btn { | ||
&:hover { | ||
background-color: transparent !important; | ||
|
||
span { | ||
color: #000 !important; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { LanguagesModal } from '@/components/Modals'; | ||
import { LANGUAGES } from '@/constants'; | ||
import { useModalManager } from '@/hooks/custom-hooks'; | ||
import { IconTypes } from '@deriv/quill-icons'; | ||
import { useTranslations } from '@deriv-com/translations'; | ||
import { Button, Footer } from '@deriv-com/ui'; | ||
import './AppFooter.scss'; | ||
|
||
// TODO: handle local storage values not updating after changing local storage values | ||
const AppFooter = () => { | ||
const { currentLang } = useTranslations(); | ||
const { hideModal, isModalOpenFor, showModal } = useModalManager(); | ||
const CountryIcon = LANGUAGES.find(lang => lang.code === currentLang)?.icon as IconTypes; | ||
|
||
return ( | ||
<Footer className='app-footer'> | ||
<Button | ||
className='app-footer__language-btn' | ||
color='black' | ||
icon={<CountryIcon iconSize='sm' />} | ||
onClick={() => showModal('LanguagesModal')} | ||
size='sm' | ||
variant='ghost' | ||
> | ||
{currentLang} | ||
</Button> | ||
{isModalOpenFor('LanguagesModal') && <LanguagesModal isModalOpen onClose={hideModal} />} | ||
</Footer> | ||
); | ||
}; | ||
|
||
export default AppFooter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import AppFooter from '../AppFooter'; | ||
|
||
jest.mock('use-query-params', () => ({ | ||
...jest.requireActual('use-query-params'), | ||
useQueryParams: jest.fn().mockReturnValue([{}, jest.fn()]), | ||
})); | ||
|
||
jest.mock('@deriv-com/translations', () => ({ | ||
useTranslations: jest.fn(() => ({ currentLang: 'EN' })), | ||
})); | ||
|
||
jest.mock('@deriv-com/ui', () => ({ | ||
...jest.requireActual('@deriv-com/ui'), | ||
useDevice: jest.fn(() => ({ isMobile: false })), | ||
})); | ||
|
||
describe('<AppFooter/>', () => { | ||
it('should render the footer', () => { | ||
render(<AppFooter />); | ||
expect(screen.getByRole('button', { name: 'EN' })).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as AppFooter } from './AppFooter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.app-header { | ||
padding: 2.4rem; | ||
|
||
@include mobile { | ||
padding-left: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { useState } from 'react'; | ||
import { | ||
LabelPairedHouseBlankMdRegularIcon, | ||
LegacyChevronRight2pxIcon, | ||
LegacyMenuHamburger1pxIcon, | ||
} from '@deriv/quill-icons'; | ||
import { useAuthData } from '@deriv-com/api-hooks'; | ||
import { Button, DerivLogo, Drawer, Header, MenuItem, Text, useDevice, Wrapper } from '@deriv-com/ui'; | ||
import { LocalStorageConstants, LocalStorageUtils, URLUtils } from '@deriv-com/utils'; | ||
import './AppHeader.scss'; | ||
|
||
// TODO: handle local storage values not updating after changing local storage values | ||
const AppHeader = () => { | ||
const [isDrawerOpen, setIsDrawerOpen] = useState(false); | ||
const { isDesktop } = useDevice(); | ||
const { activeLoginid, logout } = useAuthData(); | ||
const appId = LocalStorageUtils.getValue(LocalStorageConstants.configAppId); | ||
const serverUrl = localStorage.getItem(LocalStorageConstants.configServerURL.toString()); | ||
const oauthUrl = | ||
appId && serverUrl | ||
? `https://${serverUrl}/oauth2/authorize?app_id=${appId}&l=EN&&brand=deriv` | ||
: URLUtils.getOauthURL(); | ||
|
||
return ( | ||
<Header className='app-header'> | ||
{isDesktop ? ( | ||
<Wrapper variant='left'> | ||
<DerivLogo | ||
href='https://deriv.com' | ||
logoHeight={30} | ||
logoWidth={30} | ||
target='_blank' | ||
variant='wallets' | ||
/> | ||
<MenuItem | ||
as='button' | ||
className='flex gap-2 p-5' | ||
leftComponent={<LabelPairedHouseBlankMdRegularIcon />} | ||
> | ||
<Text>Trader's Hub</Text> | ||
</MenuItem> | ||
</Wrapper> | ||
) : ( | ||
<Wrapper variant='left'> | ||
<Drawer | ||
isOpen={isDrawerOpen} | ||
onCloseDrawer={() => { | ||
setIsDrawerOpen(false); | ||
}} | ||
width='300px' | ||
> | ||
<Drawer.Header | ||
onCloseDrawer={() => { | ||
setIsDrawerOpen(false); | ||
}} | ||
> | ||
<Text>Menu</Text> | ||
</Drawer.Header> | ||
<Drawer.Content> | ||
<div className='flex'> | ||
<MenuItem | ||
as='button' | ||
className='flex gap-5 p-5' | ||
leftComponent={<LabelPairedHouseBlankMdRegularIcon />} | ||
rightComponent={<LegacyChevronRight2pxIcon iconSize='xs' />} | ||
> | ||
<Text>Trader's Hub</Text> | ||
</MenuItem> | ||
</div> | ||
</Drawer.Content> | ||
</Drawer> | ||
<Button | ||
icon={<LegacyMenuHamburger1pxIcon iconSize='sm' />} | ||
onClick={() => setIsDrawerOpen(true)} | ||
variant='ghost' | ||
/> | ||
</Wrapper> | ||
)} | ||
{activeLoginid ? ( | ||
<Button onClick={logout}>Logout</Button> | ||
) : ( | ||
<a | ||
className='bg-solid-coral-800 text-body-sm text-opacity-white-800 rounded-200 px-800 py-300 font-bold' | ||
href={oauthUrl} | ||
> | ||
<Text>Log in</Text> | ||
</a> | ||
)} | ||
</Header> | ||
); | ||
}; | ||
|
||
export default AppHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as AppHeader } from './AppHeader'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.languages-modal { | ||
&__body { | ||
display: grid; | ||
grid-template-columns: repeat(4, 1fr); | ||
grid-gap: 1rem; | ||
padding: 2rem; | ||
|
||
&-button { | ||
height: auto; | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
|
||
&:hover { | ||
background-color: transparent !important; | ||
|
||
span { | ||
color: #000 !important; | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.