From 4244e30a61bf259cfad1a66ff3459d958de8571f Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Fri, 25 Aug 2017 14:58:02 +0300 Subject: [PATCH] Secondary navigation: UserNav. It will be used in desktop mode on current user related pages --- src/components/UserNav/UserNav.css | 32 +++++++++++ src/components/UserNav/UserNav.js | 57 +++++++++++++++++++ src/components/index.js | 2 + .../ManageListingsPage/ManageListingsPage.js | 32 +---------- .../ManageListingsPage.test.js.snap | 42 +------------- 5 files changed, 95 insertions(+), 70 deletions(-) create mode 100644 src/components/UserNav/UserNav.css create mode 100644 src/components/UserNav/UserNav.js diff --git a/src/components/UserNav/UserNav.css b/src/components/UserNav/UserNav.css new file mode 100644 index 00000000..9c70df53 --- /dev/null +++ b/src/components/UserNav/UserNav.css @@ -0,0 +1,32 @@ +@import '../../marketplace.css'; + +.root { + display: none; + + @media (--viewportMedium) { + display: flex; + justify-content: flex-end; + height: 55px; + align-items: flex-end; + padding: 13px 24px 0 24px; + } + + @media (--viewportLarge) { + padding: 0 36px; + } +} + +.tab { + display: flex; + align-items: flex-end; + height: 100%; + margin-left: 16px; + + &:first-child { + margin-left: 0; + } + + @media (--viewportLarge) { + margin-left: 24px; + } +} diff --git a/src/components/UserNav/UserNav.js b/src/components/UserNav/UserNav.js new file mode 100644 index 00000000..9a85be15 --- /dev/null +++ b/src/components/UserNav/UserNav.js @@ -0,0 +1,57 @@ +import React, { PropTypes } from 'react'; +import { FormattedMessage } from 'react-intl'; +import classNames from 'classnames'; +import { TabNavHorizontal } from '../../components'; + +import css from './UserNav.css'; + +const UserNav = props => { + const { className, rootClassName, selectedPageName } = props; + const classes = classNames(rootClassName || css.root, className); + + const tabs = [ + { + text: , + selected: selectedPageName === 'EditProfilePage', + disabled: true, + linkProps: { + name: 'EditProfilePage', + params: { displayName: 'testinglink' }, + }, + }, + { + text: , + selected: selectedPageName === 'AccountPage', + disabled: true, + linkProps: { + name: 'AccountPage', + }, + }, + { + text: , + selected: selectedPageName === 'ManageListingsPage', + linkProps: { + name: 'ManageListingsPage', + }, + }, + ]; + + return ( + + ); +}; + +UserNav.defaultProps = { + className: null, + rootClassName: null, +}; + +const { string } = PropTypes; + +UserNav.propTypes = { + className: string, + rootClassName: string, + selectedPageName: string.isRequired, +}; + +export default UserNav; diff --git a/src/components/index.js b/src/components/index.js index 284d342b..e1bd8c99 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -56,6 +56,7 @@ import TextInputField from './TextInputField/TextInputField'; import Topbar from './Topbar/Topbar'; import TopbarDesktop from './TopbarDesktop/TopbarDesktop'; import TopbarMobileMenu from './TopbarMobileMenu/TopbarMobileMenu'; +import UserNav from './UserNav/UserNav'; import ValidationError from './ValidationError/ValidationError'; export { @@ -120,5 +121,6 @@ export { Topbar, TopbarDesktop, TopbarMobileMenu, + UserNav, ValidationError, }; diff --git a/src/containers/ManageListingsPage/ManageListingsPage.js b/src/containers/ManageListingsPage/ManageListingsPage.js index 415d10d5..cfeecb95 100644 --- a/src/containers/ManageListingsPage/ManageListingsPage.js +++ b/src/containers/ManageListingsPage/ManageListingsPage.js @@ -6,7 +6,7 @@ import { withRouter } from 'react-router-dom'; import * as propTypes from '../../util/propTypes'; import { logout, authenticationInProgress } from '../../ducks/Auth.duck'; import { manageDisableScrolling, isScrollingDisabled } from '../../ducks/UI.duck'; -import { PageLayout, Topbar, TabNavHorizontal } from '../../components'; +import { PageLayout, Topbar, UserNav } from '../../components'; import css from './ManageListingsPage.css'; @@ -25,33 +25,6 @@ export const ManageListingsPageComponent = props => { onManageDisableScrolling, } = props; - const tabs = [ - { - text: , - selected: false, - disabled: true, - linkProps: { - name: 'EditProfilePage', - params: { displayName: 'testinglink' }, - }, - }, - { - text: , - selected: false, - disabled: true, - linkProps: { - name: 'AccountPage', - }, - }, - { - text: , - selected: true, - linkProps: { - name: 'ManageListingsPage', - }, - }, - ]; - return ( { onLogout={onLogout} onManageDisableScrolling={onManageDisableScrolling} /> - - + ); }; diff --git a/src/containers/ManageListingsPage/__snapshots__/ManageListingsPage.test.js.snap b/src/containers/ManageListingsPage/__snapshots__/ManageListingsPage.test.js.snap index 9a90dbce..2101be6e 100644 --- a/src/containers/ManageListingsPage/__snapshots__/ManageListingsPage.test.js.snap +++ b/src/containers/ManageListingsPage/__snapshots__/ManageListingsPage.test.js.snap @@ -22,47 +22,9 @@ exports[`ContactDetailsPage matches snapshot 1`] = ` notificationCount={0} onLogout={[Function]} onManageDisableScrolling={[Function]} /> - , - }, - Object { - "disabled": true, - "linkProps": Object { - "name": "AccountPage", - }, - "selected": false, - "text": , - }, - Object { - "linkProps": Object { - "name": "ManageListingsPage", - }, - "selected": true, - "text": , - }, - ] - } /> + selectedPageName="ManageListingsPage" /> `;