Skip to content

Commit 446befa

Browse files
Merge branch 'nav-bugbash-2' into issue47
2 parents 09dad37 + 6bc9b6f commit 446befa

File tree

15 files changed

+169
-39
lines changed

15 files changed

+169
-39
lines changed

dist/dev/index.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/prod/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/sass/_global/_themes.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $themes: (
3232
iconDarkDisplay: none,
3333
iconLightDisplay: block,
3434
arrowBackground: $gray-neutral-light,
35+
beforeBackground: $turquoise
3536
),
3637
dark: (
3738
secondaryBackgroundColor: $gray-60,
@@ -42,5 +43,6 @@ $themes: (
4243
iconDarkDisplay: block,
4344
iconLightDisplay: none,
4445
arrowBackground: $gray-60,
46+
beforeBackground: $white
4547
),
4648
);

src/components/AccountMenu/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ const MANAGE_ROLES = [
1818
'manager',
1919
'global manager',
2020
'client manager',
21-
'connect manager'
21+
'connect manager',
22+
'connect account manager',
23+
'connect copilot manager'
2224
]
2325

2426
const hasAccess = roles => {
@@ -41,11 +43,11 @@ class AccountMenu extends React.Component {
4143

4244
render () {
4345
const {
44-
onClose, open, menu, switchText, onSwitch, profile
46+
onClose, open, menu, switchText, onSwitch, profile, domRef
4547
} = this.props
4648

4749
return (
48-
<div className={cn(styles['user-info-popup'], open && styles.open)}>
50+
<div ref={domRef} className={cn(styles['user-info-popup'], open && styles.open)}>
4951
<div className={styles.backdrop} onClick={onClose} />
5052

5153
<Link to={_.isEmpty(profile) ? '/' : `/members/${profile.handle}`}>
@@ -113,7 +115,8 @@ AccountMenu.propTypes = {
113115
menu: PropTypes.array,
114116
switchText: PropTypes.shape(),
115117
onSwitch: PropTypes.func,
116-
profile: PropTypes.shape()
118+
profile: PropTypes.shape(),
119+
domRef: PropTypes.shape()
117120
}
118121

119122
export default AccountMenu

src/components/ChosenArrow/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import styles from './styles.module.scss'
55
const ChosenArrow = ({ show, x }) => (
66
<div
77
className={styles.chosenArrow}
8-
style={{ transform: `translateX(calc(${x}px - 50%))` }}
8+
style={{ transform: `translateX(${x}px)` }}
99
hidden={!show}
1010
>
1111
<svg width='40px' height='10px' viewBox='0 0 40 10'>

src/components/ChosenArrow/styles.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.chosenArrow {
44
position: absolute;
55
bottom: -1px;
6-
left: 0;
6+
left: -20px;
77
z-index: 1;
88
-webkit-transition: -webkit-transform 0.5s;
99
transition: transform 0.5s;

src/components/IconSelect/index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import styles from './styles.module.scss'
44

5-
const IconSelect = ({ show, x }) => (
6-
<span
5+
const IconSelect = ({ show, x, isResize }) => {
6+
let styleObj = {
7+
transform: `translateX(${x}px)`
8+
9+
}
10+
// is window is on resize, stop animation
11+
if (isResize) {
12+
styleObj['transition'] = 'auto'
13+
styleObj['-webkit-transition'] = 'auto'
14+
}
15+
return <span
716
className={styles.iconSelect}
8-
style={{ transform: `translateX(calc(${x}px - 50%))` }}
17+
style={styleObj}
918
hidden={!show}
1019
/>
11-
)
20+
}
1221

1322
IconSelect.propTypes = {
23+
// screen is changing size
24+
isResize: PropTypes.bool,
1425
/** Show or hide the icon */
1526
show: PropTypes.bool,
1627
/** The x position of the arrow. Generally this will be the center of the target */

src/components/IconSelect/styles.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.iconSelect {
44
position: absolute;
55
bottom: -1px;
6-
left: 0;
6+
left: -7px;
77
width: 15px;
88
height: 3px;
99
border-radius: 1.5px;

src/components/LoginNav/index.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react'
1+
import React, { useState, useEffect, useRef } from 'react'
22
import PropTypes from 'prop-types'
33
import styles from './styles.module.scss'
44

@@ -21,6 +21,8 @@ const LoginNav = ({
2121
}) => {
2222
const [openNotifications, setOpenNotifications] = useState()
2323
const [openAccountMenu, setOpenAccountMenu] = useState()
24+
const accountMenuRef = useRef(null)
25+
const userInfoRef = useRef(null)
2426

2527
useEffect(() => {
2628
// trigger when orientationChange in ipad
@@ -32,6 +34,25 @@ const LoginNav = ({
3234
window.addEventListener('orientationchange', onOrientationChange)
3335
return () => window.removeEventListener('orientationchange', onOrientationChange)
3436
}, [])
37+
38+
useEffect(() => {
39+
// Internet Explorer 6-11
40+
const isIE = /*@cc_on!@*/false || !!document.documentMode // eslint-disable-line spaced-comment
41+
// Edge 20+
42+
const isEdge = !isIE && !!window.StyleMedia
43+
if (!(isIE || isEdge)) return
44+
45+
// trigger when click outside
46+
const onClickOutside = (event) => {
47+
if (!(userInfoRef.current.contains(event.target) || accountMenuRef.current.contains(event.target))) {
48+
setOpenAccountMenu(false)
49+
document.body.style.position = ''
50+
}
51+
}
52+
document.addEventListener('mousedown', onClickOutside, true)
53+
return () => document.removeEventListener('mousedown', onClickOutside, true)
54+
}, [])
55+
3556
const handleClickNotifications = () => setOpenNotifications(x => !x)
3657

3758
const handleClickUserInfo = () => {
@@ -61,6 +82,7 @@ const LoginNav = ({
6182
onClick={handleClickUserInfo}
6283
open={openAccountMenu}
6384
key='user-info'
85+
domRef={userInfoRef}
6486
/>
6587
])
6688
}
@@ -72,6 +94,7 @@ const LoginNav = ({
7294
onClick={handleClickUserInfo}
7395
open={openAccountMenu}
7496
key='user-info'
97+
domRef={userInfoRef}
7598
/>
7699
)
77100
}
@@ -108,6 +131,7 @@ const LoginNav = ({
108131
setOpenAccountMenu(false)
109132
document.body.style.position = ''
110133
}}
134+
domRef={accountMenuRef}
111135
/>
112136
</div>
113137
)

src/components/LoginNav/styles.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
position: relative;
66
display: flex;
77
align-items: center;
8+
cursor: default;
89

910
.notificationButton {
1011
@include hide-mobile;

0 commit comments

Comments
 (0)