Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Commit

Permalink
feat: Add settings link on mobile (#657)
Browse files Browse the repository at this point in the history
* feat: Add settings link on mobile

* feat: Remove unnecessary <Hidden /> components
  • Loading branch information
chardos authored Feb 6, 2020
1 parent 92408f1 commit f051676
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 32 deletions.
50 changes: 33 additions & 17 deletions react/Header/UserAccountMenu/UserAccountMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import styles from './UserAccountMenu.less';

import React from 'react';
import React, { Fragment } from 'react';
import classnames from 'classnames';

import ArticleIcon from '../../ArticleIcon/ArticleIcon';
Expand Down Expand Up @@ -253,22 +253,38 @@ export default ({
</span>
);
case AUTHENTICATED:
return linkRenderer({
'data-analytics': 'header:sign-out',
className: styles.item,
onClick: clearLocalStorage,
href: returnUrl
? appendReturnUrl('/login/LogoutWithReturnUrl', returnUrl)
: '/Login/Logout',
children: [
'Sign Out',
<Hidden
desktop
key="iconSpacer"
className={styles.iconSpacer}
/>
]
});
return (
<Fragment>
<li
className={classnames(
activeTab === SETTINGS && styles.activeTab
)}
>
{linkRenderer({
'data-analytics': 'header:settings',
className: styles.item,
href: '/settings/',
children: [
SETTINGS,
<div key="iconSpacer" className={styles.iconSpacer} />
]
})}
</li>
{linkRenderer({
'data-analytics': 'header:sign-out',
className: styles.item,
onClick: clearLocalStorage,
href: returnUrl
? appendReturnUrl('/login/LogoutWithReturnUrl', returnUrl)
: '/Login/Logout',
children: [
'Sign Out',
<div key="iconSpacer" className={styles.iconSpacer} />
]
})}
</Fragment>
);

default:
return (
<span className={classnames(styles.item, styles.pendingAuth)}>
Expand Down
69 changes: 54 additions & 15 deletions react/Header/__snapshots__/Header.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -850,18 +850,31 @@ exports[`Header: should render first part of email address when username isn't p
</li>
<li
class="UserAccountMenu__firstItemInGroup Hidden__desktop"
/>
<li
class=""
>
<a
class="UserAccountMenu__item"
data-analytics="header:sign-out"
href="/Login/Logout"
data-analytics="header:settings"
href="/settings/"
>
Sign Out
<span
class="UserAccountMenu__iconSpacer Hidden__desktop"
Settings
<div
class="UserAccountMenu__iconSpacer"
/>
</a>
</li>
<a
class="UserAccountMenu__item"
data-analytics="header:sign-out"
href="/Login/Logout"
>
Sign Out
<div
class="UserAccountMenu__iconSpacer"
/>
</a>
<li
class="UserAccountMenu__firstItemInGroup Hidden__desktop"
>
Expand Down Expand Up @@ -1983,18 +1996,31 @@ exports[`Header: should render when authenticated 1`] = `
</li>
<li
class="UserAccountMenu__firstItemInGroup Hidden__desktop"
/>
<li
class=""
>
<a
class="UserAccountMenu__item"
data-analytics="header:sign-out"
href="/login/LogoutWithReturnUrl?returnUrl=%2Fjobs"
data-analytics="header:settings"
href="/settings/"
>
Sign Out
<span
class="UserAccountMenu__iconSpacer Hidden__desktop"
Settings
<div
class="UserAccountMenu__iconSpacer"
/>
</a>
</li>
<a
class="UserAccountMenu__item"
data-analytics="header:sign-out"
href="/login/LogoutWithReturnUrl?returnUrl=%2Fjobs"
>
Sign Out
<div
class="UserAccountMenu__iconSpacer"
/>
</a>
<li
class="UserAccountMenu__firstItemInGroup Hidden__desktop"
>
Expand Down Expand Up @@ -2548,18 +2574,31 @@ exports[`Header: should render when authenticated but username and email is not
</li>
<li
class="UserAccountMenu__firstItemInGroup Hidden__desktop"
/>
<li
class=""
>
<a
class="UserAccountMenu__item"
data-analytics="header:sign-out"
href="/Login/Logout"
data-analytics="header:settings"
href="/settings/"
>
Sign Out
<span
class="UserAccountMenu__iconSpacer Hidden__desktop"
Settings
<div
class="UserAccountMenu__iconSpacer"
/>
</a>
</li>
<a
class="UserAccountMenu__item"
data-analytics="header:sign-out"
href="/Login/Logout"
>
Sign Out
<div
class="UserAccountMenu__iconSpacer"
/>
</a>
<li
class="UserAccountMenu__firstItemInGroup Hidden__desktop"
>
Expand Down

0 comments on commit f051676

Please sign in to comment.