-
Notifications
You must be signed in to change notification settings - Fork 45
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 #1961 from oasisprotocol/mz/footer
Move mobile footer to profile dropdown
- Loading branch information
Showing
13 changed files
with
415 additions
and
511 deletions.
There are no files selected for viewing
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 @@ | ||
Move mobile footer to profile dropdown |
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,25 @@ | ||
import { useContext } from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { Box } from 'grommet/es6/components/Box' | ||
import { ResponsiveContext } from 'grommet/es6/contexts/ResponsiveContext' | ||
import { selectHasAccounts } from 'app/state/wallet/selectors' | ||
import { MobileFooterNavigation } from '../MobileFooterNavigation' | ||
import { Footer } from '.' | ||
|
||
export const PageFooter = () => { | ||
const isMobile = useContext(ResponsiveContext) === 'small' | ||
const isDesktop = useContext(ResponsiveContext) === 'large' | ||
const walletHasAccounts = useSelector(selectHasAccounts) | ||
|
||
return ( | ||
<> | ||
{walletHasAccounts && isMobile && ( | ||
<Box pad="xlarge"> | ||
<MobileFooterNavigation /> | ||
</Box> | ||
)} | ||
{/* Footer for opened wallet is rendered in Settings tab in Profile dropdown */} | ||
{((walletHasAccounts && isDesktop) || !walletHasAccounts) && <Footer />} | ||
</> | ||
) | ||
} |
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,70 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { ResponsiveContext } from 'grommet/es6/contexts/ResponsiveContext' | ||
import { MemoryRouter } from 'react-router-dom' | ||
import { Provider } from 'react-redux' | ||
import { ThemeProvider } from 'styles/theme/ThemeProvider' | ||
import { configureAppStore } from 'store/configureStore' | ||
import { Wallet } from 'app/state/wallet/types' | ||
import { PageFooter } from '../PageFooter' | ||
|
||
const renderComponent = (store: any, responsiveContext: string) => | ||
render( | ||
<Provider store={store}> | ||
<MemoryRouter> | ||
<ThemeProvider> | ||
<ResponsiveContext.Provider value={responsiveContext}> | ||
<PageFooter /> | ||
</ResponsiveContext.Provider> | ||
</ThemeProvider> | ||
</MemoryRouter> | ||
</Provider>, | ||
) | ||
|
||
describe('<PageFooter />', () => { | ||
let store: ReturnType<typeof configureAppStore> | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
|
||
store = configureAppStore({ | ||
wallet: { | ||
selectedWallet: 'dummy', | ||
wallets: { | ||
dummy: { | ||
address: 'dummy', | ||
} as Wallet, | ||
}, | ||
}, | ||
}) | ||
}) | ||
|
||
it('should render mobile navigation without footer on mobile when account is open', () => { | ||
renderComponent(store, 'small') | ||
|
||
expect(screen.queryByTestId('footer')).not.toBeInTheDocument() | ||
expect(screen.getByTestId('mobile-footer-navigation')).toBeInTheDocument() | ||
}) | ||
|
||
it('should render footer without mobile navigation on desktop when account is open', () => { | ||
renderComponent(store, 'large') | ||
|
||
expect(screen.getByTestId('footer')).toBeInTheDocument() | ||
expect(screen.queryByTestId('mobile-footer-navigation')).not.toBeInTheDocument() | ||
}) | ||
|
||
it('should render footer without mobile navigation on mobile when account is not open', () => { | ||
const storeWithoutAccount = configureAppStore({}) | ||
renderComponent(storeWithoutAccount, 'small') | ||
|
||
expect(screen.getByTestId('footer')).toBeInTheDocument() | ||
expect(screen.queryByTestId('mobile-footer-navigation')).not.toBeInTheDocument() | ||
}) | ||
|
||
it('should render footer without mobile navigation on desktop when account is not open', () => { | ||
const storeWithoutAccount = configureAppStore({}) | ||
renderComponent(storeWithoutAccount, 'large') | ||
|
||
expect(screen.getByTestId('footer')).toBeInTheDocument() | ||
expect(screen.queryByTestId('mobile-footer-navigation')).not.toBeInTheDocument() | ||
}) | ||
}) |
Oops, something went wrong.