Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/borealis/global/nav.import.less
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ nav {
min-width: 100%;
display: none;
}
.w-dropdown:hover > .dropdown-list,
.w-dropdown-list:hover,
.w-dropdown-list.w--open {
display: flex;
flex-direction: column;
display: flex !important;
flex-direction: column !important;
}
.dropdown-list {
border-radius: 8px;
Expand Down Expand Up @@ -295,11 +297,13 @@ nav {
1px 1px 3px 0 rgba(27, 36, 72, 0.16);
}

.w-dropdown:hover > .dropdown-list,
.dropdown-list:hover,
.dropdown-list.w--open {
left: 50%;
padding-top: 8px;
padding-bottom: 8px;
transform: translateX(-50%);
left: 50% !important;
padding-top: 8px !important;
padding-bottom: 8px !important;
transform: translateX(-50%) !important;

&:before {
content:"";
Expand Down Expand Up @@ -349,6 +353,9 @@ nav {
flex-basis: 100%;
height: 0;
}
.arrow-icon--active {
transform: rotate(-90deg);
}
.third-level-items {
ul {
display: none;
Expand Down
62 changes: 16 additions & 46 deletions packages/borealis/react-components/NavigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class NavigationBarComponent extends React.Component {
};
this.urlIntervalId = Meteor.setInterval(this.eventListener, 1000);
this.pollingIntervalId = Meteor.setInterval(() => this.fetchItems(), 5000);
this.dropdownSecondary = React.createRef();
this.dropdownSecondary.current = [];
}
// eslint-disable-next-line no-undef
state = {
Expand Down Expand Up @@ -138,6 +140,10 @@ class NavigationBarComponent extends React.Component {
this.setState({ mainLabel: null });
};

toggleDropdownSecondary = (i) => {
this.dropdownSecondary.current[i].classList.toggle('ul--open');
};

// eslint-disable-next-line no-undef
timeout = {};

Expand All @@ -162,14 +168,6 @@ class NavigationBarComponent extends React.Component {
const currentApplicationInfo =
currentApplication && applicationsMap[currentApplication];

const onMouseEnter = _id => {
if (this.timeout[_id]) Meteor.clearTimeout(this.timeout[_id]);
this.setState({
active: {
[_id]: true,
},
});
};
const toggleState = (_id, subitem) => {
this.setState({
active: {
Expand All @@ -178,16 +176,7 @@ class NavigationBarComponent extends React.Component {
},
});
};
const onMouseLeave = _id => {
this.timeout[_id] = Meteor.setTimeout(() => {
this.setState({
active: {
...this.state.active,
[_id]: false,
},
});
}, 100);
};

const renderSubItems = ({
subItems,
_id,
Expand All @@ -196,17 +185,13 @@ class NavigationBarComponent extends React.Component {
mobileOnClick,
}) => (
<nav
onMouseEnter={mobile ? () => {} : () => onMouseEnter(_id)}
onMouseLeave={mobile ? () => {} : () => onMouseLeave(_id)}
className={
mobile
? 'mobile-menu-subitem'
: `dropdown-list w-dropdown-list ${
this.state.active[_id] ? 'w--open' : ''
} `
: `dropdown-list w-dropdown-list`
}
>
{subItems.map(subitem => {
{subItems.map((subitem, i) => {
const subSubItemOpenId = `${subitem.label}-thirdlevel`;
const logoutFunction = () => {
Meteor.logout();
Expand Down Expand Up @@ -237,7 +222,6 @@ class NavigationBarComponent extends React.Component {
onClick={e => {
if (subitem.items && subitem.items.length) {
e.stopPropagation();
toggleState(subSubItemOpenId, _id);
}
if (mobile) {
mobileOnClick({ close: true })();
Expand Down Expand Up @@ -266,10 +250,11 @@ class NavigationBarComponent extends React.Component {
</Link>
{subitem.items && subitem.items.length && (
<ArrowIcon
direction={
this.state.active[subSubItemOpenId] ? 'right' : 'down'
}
onClick={() => toggleState(subSubItemOpenId, _id)}
direction='down'
onClick={(e) => {
this.toggleDropdownSecondary(i);
e.currentTarget.classList.toggle('arrow-icon--active');
}}
/>
)}
{subitem.alternativeLink ? (
Expand All @@ -287,15 +272,7 @@ class NavigationBarComponent extends React.Component {
{subitem.items && subitem.items.length && (
<div className={mobile ? '' : 'third-level-items'}>
<ul
className={
mobile
? ''
: `${
this.state.active[subSubItemOpenId]
? 'ul--open'
: ''
} `
}
ref={el => this.dropdownSecondary.current[i] = el}
>
{(subitem.items || []).map(subSubItem => (
<li key={`${subitem.label}-${subSubItem.label}`}>
Expand Down Expand Up @@ -365,10 +342,7 @@ class NavigationBarComponent extends React.Component {
onClick={mobileOnClick()}
>
{(!mobile || this.state.mainLabel !== label) && (
<div className="avatar-wrapper"
onMouseEnter={mobile ? () => {} : () => onMouseEnter(_id)}
onMouseLeave={mobile ? () => {} : () => onMouseLeave(_id)}
>
<div className="avatar-wrapper">
<LetterAvatar
size={40}
bgColor={mobile ? '#eee' : 'white'}
Expand Down Expand Up @@ -414,8 +388,6 @@ class NavigationBarComponent extends React.Component {
RouterComponent={RouterComponent}
className={variant}
{...(onClick ? { onClick } : { href: actionLink })}
onMouseEnter={mobile ? () => {} : () => onMouseEnter(_id)}
onMouseLeave={mobile ? () => {} : () => onMouseLeave(_id)}
>
{currentRegion.label}
<img
Expand Down Expand Up @@ -448,8 +420,6 @@ class NavigationBarComponent extends React.Component {
RouterComponent={RouterComponent}
className={variant}
{...(onClick ? { onClick } : { href: actionLink })}
onMouseEnter={mobile ? () => {} : () => onMouseEnter(_id)}
onMouseLeave={mobile ? () => {} : () => onMouseLeave(_id)}
>
{label}
</Link>
Expand Down