diff --git a/.changelog/1961.trivial.md b/.changelog/1961.trivial.md new file mode 100644 index 0000000000..0e37229a6e --- /dev/null +++ b/.changelog/1961.trivial.md @@ -0,0 +1 @@ +Move mobile footer to profile dropdown diff --git a/src/app/__tests__/__snapshots__/index.test.tsx.snap b/src/app/__tests__/__snapshots__/index.test.tsx.snap index 58d0c26986..bbca81b5aa 100644 --- a/src/app/__tests__/__snapshots__/index.test.tsx.snap +++ b/src/app/__tests__/__snapshots__/index.test.tsx.snap @@ -46,7 +46,7 @@ exports[` should render and match the snapshot 1`] = ` - + diff --git a/src/app/components/Footer/PageFooter.tsx b/src/app/components/Footer/PageFooter.tsx new file mode 100644 index 0000000000..122116e34e --- /dev/null +++ b/src/app/components/Footer/PageFooter.tsx @@ -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 && ( + + + + )} + {/* Footer for opened wallet is rendered in Settings tab in Profile dropdown */} + {((walletHasAccounts && isDesktop) || !walletHasAccounts) && } + > + ) +} diff --git a/src/app/components/Footer/__tests__/PageFooter.test.tsx b/src/app/components/Footer/__tests__/PageFooter.test.tsx new file mode 100644 index 0000000000..a014652dc0 --- /dev/null +++ b/src/app/components/Footer/__tests__/PageFooter.test.tsx @@ -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( + + + + + + + + + , + ) + +describe('', () => { + let store: ReturnType + + 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() + }) +}) diff --git a/src/app/components/Footer/__tests__/__snapshots__/index.test.tsx.snap b/src/app/components/Footer/__tests__/__snapshots__/index.test.tsx.snap index a284c1abd0..b043ba6049 100644 --- a/src/app/components/Footer/__tests__/__snapshots__/index.test.tsx.snap +++ b/src/app/components/Footer/__tests__/__snapshots__/index.test.tsx.snap @@ -1,40 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` should render mobile version of footer 1`] = ` -.c9 { - display: inline-block; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - width: 24px; - height: 24px; - fill: currentColor; - stroke: currentColor; -} - -.c9 g { - fill: inherit; - stroke: inherit; -} - -.c9 *:not([stroke])[fill='none'] { - stroke-width: 0; -} - -.c9 *[stroke*='#'], -.c9 *[STROKE*='#'] { - stroke: inherit; - fill: none; -} - -.c9 *[fill-rule], -.c9 *[FILL-RULE], -.c9 *[fill*='#'], -.c9 *[FILL*='#'] { - fill: inherit; - stroke: none; -} - .c0 { display: -webkit-box; display: -webkit-flex; @@ -42,7 +8,8 @@ exports[` should render mobile version of footer 1`] = ` display: flex; box-sizing: border-box; max-width: 100%; - margin-bottom: 48px; + margin-top: auto; + margin-bottom: 0px; -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -59,19 +26,16 @@ exports[` should render mobile version of footer 1`] = ` padding-left: 24px; padding-right: 24px; padding-top: 1rem; - padding-bottom: 4rem; border-radius: 5px; } -.c3 { +.c1 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; box-sizing: border-box; max-width: 100%; - margin-left: 6px; - margin-right: 6px; min-width: 0; min-height: 0; -webkit-flex-direction: column; @@ -79,40 +43,33 @@ exports[` should render mobile version of footer 1`] = ` flex-direction: column; } -.c8 { +.c6 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; box-sizing: border-box; max-width: 100%; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; + margin-left: 6px; + margin-right: 6px; min-width: 0; min-height: 0; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; - height: 100%; - -webkit-box-pack: center; - -webkit-justify-content: center; - -ms-flex-pack: center; - justify-content: center; } -.c10 { +.c4 { -webkit-flex: 0 0 auto; -ms-flex: 0 0 auto; flex: 0 0 auto; -webkit-align-self: stretch; -ms-flex-item-align: stretch; align-self: stretch; - height: 12px; + height: 0; } -.c2 { +.c3 { box-sizing: border-box; display: -webkit-inline-box; display: -webkit-inline-flex; @@ -127,251 +84,170 @@ exports[` should render mobile version of footer 1`] = ` cursor: pointer; } -.c2:hover { +.c3:hover { -webkit-text-decoration: underline; text-decoration: underline; } -.c1 { +.c2 { margin-bottom: 12px; font-size: 14px; line-height: 20px; text-align: center; } -.c4 { +.c5 { margin-top: 12px; font-size: 14px; line-height: 20px; text-align: center; } -.c11 { - font-size: 14px; - line-height: 20px; - text-align: center; -} - -.c6 { - background-color: #FFFFFF; - position: fixed; - bottom: 0; - left: 0; - right: 0; - height: 4rem; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-align-items: stretch; - -webkit-box-align: stretch; - -ms-flex-align: stretch; - align-items: stretch; - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; - box-shadow: 0px 0px 1px #EDEDED; - border-top: solid 1px #11111108; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; -} - -.c7 { - -webkit-box-flex: 1; - -webkit-flex-grow: 1; - -ms-flex-positive: 1; - flex-grow: 1; - -webkit-flex-basis: 0; - -ms-flex-preferred-size: 0; - flex-basis: 0; -} - -.c7:hover { - background-color: #11111108; -} - -.c5 { - display: inline-block; - box-sizing: border-box; - cursor: pointer; - font: inherit; - -webkit-text-decoration: none; - text-decoration: none; - margin: 0; - background: transparent; - overflow: visible; - text-transform: none; - color: #0500e2; - outline: none; - border: none; - padding: 0; - text-align: inherit; -} - -.c5:focus { - outline: none; - box-shadow: 0 0 2px 2px #00A9FF; -} - -.c5:focus > circle, -.c5:focus > ellipse, -.c5:focus > line, -.c5:focus > path, -.c5:focus > polygon, -.c5:focus > polyline, -.c5:focus > rect { - outline: none; - box-shadow: 0 0 2px 2px #00A9FF; -} - -.c5:focus::-moz-focus-inner { - border: 0; -} - -.c5:focus:not(:focus-visible) { - outline: none; - box-shadow: none; -} - -.c5:focus:not(:focus-visible) > circle, -.c5:focus:not(:focus-visible) > ellipse, -.c5:focus:not(:focus-visible) > line, -.c5:focus:not(:focus-visible) > path, -.c5:focus:not(:focus-visible) > polygon, -.c5:focus:not(:focus-visible) > polyline, -.c5:focus:not(:focus-visible) > rect { - outline: none; - box-shadow: none; -} - -.c5:focus:not(:focus-visible)::-moz-focus-inner { - border: 0; -} - @media only screen and (max-width:768px) { .c0 { - margin-bottom: 24px; + margin-top: auto; } } @media only screen and (max-width:768px) { .c0 { - padding-left: 12px; - padding-right: 12px; + margin-bottom: 0px; } } @media only screen and (max-width:768px) { .c0 { - padding-top: 1rem; + padding-left: 12px; + padding-right: 12px; } } @media only screen and (max-width:768px) { .c0 { - padding-bottom: 4rem; + padding-top: 1rem; } } @media only screen and (max-width:768px) { - .c3 { + .c6 { margin-left: 3px; } } @media only screen and (max-width:768px) { - .c3 { + .c6 { margin-right: 3px; } } -@media only screen and (max-width:768px) { - .c10 { - height: 6px; - } -} -