Skip to content

Commit 6e44fd8

Browse files
frano-mNoopDog
authored andcommitted
Add 2nd level nav to 'March 2020 Release' in top nav so we can show both 'Datasets' and 'Documentation' options. Resolves #1131. (#1142)
1 parent 9f14a53 commit 6e44fd8

14 files changed

+356
-22
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="toolbar-nav-drop-down" (click)="onClickDropDown($event)">
2+
<ng-content></ng-content>
3+
</div>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
5+
* Toolbar nav drop down styles.
6+
*/
7+
8+
@import "../../site/theme/cgl.vars";
9+
10+
/* Nav drop down - hide */
11+
:host {
12+
display: none;
13+
}
14+
15+
.toolbar-nav-drop-down {
16+
background-color: $hca-white;
17+
border: 1px solid $hca-gray-lightest;
18+
border-radius: 4px;
19+
left: 0;
20+
padding: 8px 0;
21+
position: absolute;
22+
top: 46px;
23+
width: 100%;
24+
}
25+
26+
/**
27+
* Large Tablet +
28+
* https://material.io/design/layout/responsive-layout-grid.html#breakpoints
29+
*/
30+
@media screen and (min-width: 840px) {
31+
32+
/* Nav drop down - show */
33+
:host {
34+
display: block;
35+
}
36+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Dependencies
2+
import { Component, EventEmitter, HostListener, OnInit, Output } from "@angular/core";
3+
4+
/**
5+
* Component for displaying nav drop down, used in conjunction with cc-toolbar-nav.
6+
*/
7+
8+
@Component({
9+
selector: "cc-toolbar-nav-drop-down",
10+
templateUrl: "cc-toolbar-nav-drop-down.component.html",
11+
styleUrls: ["cc-toolbar-nav-drop-down.component.scss"],
12+
})
13+
14+
export class CCToolbarNavDropDownComponent implements OnInit {
15+
16+
// Output
17+
@Output() dropDownMenuOpened = new EventEmitter<boolean>();
18+
19+
/**
20+
* Add click handler to close the drop down menu.
21+
*
22+
*/
23+
@HostListener("document:click")
24+
public onClickDocument() {
25+
26+
// Any click event will close the drop down menu.
27+
this.onDropDownOpened(false);
28+
}
29+
30+
/**
31+
* Prevents event propagation when click event is inside the drop down menu.
32+
* Method will allow drop down menu to remain open when a click event is inside the menu, by
33+
* stopping the propagation of click event to @HostListener (where any document click event closes menu).
34+
*
35+
* @param {MouseEvent} event
36+
*/
37+
public onClickDropDown(event: MouseEvent) {
38+
39+
event.stopPropagation();
40+
}
41+
42+
/**
43+
* Let parents know the toolbar nav drop down component has either been opened or closed.
44+
*
45+
* @param {boolean} opened
46+
*/
47+
public onDropDownOpened(opened: boolean) {
48+
49+
this.dropDownMenuOpened.emit(opened);
50+
}
51+
52+
/**
53+
* Let parents know the drop down is now open.
54+
*/
55+
ngOnInit() {
56+
57+
this.onDropDownOpened(true);
58+
}
59+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<a class="sub-nav-item" href="{{link}}">
2+
<span class="fontsize-xs">
3+
<ng-content></ng-content>
4+
</span>
5+
</a>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
5+
* Toolbar nav sub menu item styles.
6+
*/
7+
8+
@import "../../site/theme/cgl.vars";
9+
10+
/* Nav sub item */
11+
.sub-nav-item {
12+
align-items: flex-start;
13+
color: $hca-black;
14+
display: flex;
15+
flex-direction: column;
16+
height: 24px;
17+
justify-content: center;
18+
padding: 0 24px;
19+
text-decoration: none;
20+
text-transform: capitalize;
21+
22+
/* Text */
23+
span {
24+
font-weight: 400;
25+
margin: 0;
26+
}
27+
}
28+
29+
/**
30+
* Large Tablet +
31+
* https://material.io/design/layout/responsive-layout-grid.html#breakpoints
32+
*/
33+
@media screen and (min-width: 840px) {
34+
35+
.sub-nav-item {
36+
height: 32px;
37+
padding: 0 12px;
38+
39+
/* Hover */
40+
&:hover {
41+
background-color: $hca-blue-light;
42+
}
43+
}
44+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Dependencies
2+
import { Component, Input } from "@angular/core";
3+
4+
/**
5+
* Component for displaying nav sub menu item, used in conjunction with cc-toolbar-nav.
6+
*/
7+
8+
@Component({
9+
selector: "cc-toolbar-nav-sub-menu-item",
10+
templateUrl: "cc-toolbar-nav-sub-menu-item.component.html",
11+
styleUrls: ["cc-toolbar-nav-sub-menu-item.component.scss"],
12+
})
13+
14+
export class CCToolbarNavSubMenuItemComponent {
15+
16+
// Inputs
17+
@Input() link: string;
18+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="toolbar-nav-sub-menu">
2+
<ng-content></ng-content>
3+
</div>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
5+
* Toolbar nav sub menu styles.
6+
* ViewEncapsulation is disabled - required in order to style <ng-content>.
7+
*/
8+
9+
/* Nav sub menu */
10+
.toolbar-nav-sub-menu {
11+
display: flex;
12+
flex-direction: column;
13+
margin: 12px 0;
14+
}
15+
16+
/**
17+
* Large Tablet +
18+
* https://material.io/design/layout/responsive-layout-grid.html#breakpoints
19+
*/
20+
@media screen and (min-width: 840px) {
21+
22+
/* Nav sub menu - hide */
23+
:host {
24+
display: none;
25+
}
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Dependencies
2+
import { Component } from "@angular/core";
3+
4+
/**
5+
* Component for displaying nav sub menu, used in conjunction with cc-toolbar-nav.
6+
*/
7+
8+
@Component({
9+
selector: "cc-toolbar-nav-sub-menu",
10+
templateUrl: "cc-toolbar-nav-sub-menu.component.html",
11+
styleUrls: ["cc-toolbar-nav-sub-menu.component.scss"],
12+
})
13+
14+
export class CCToolbarNavSubMenuComponent {
15+
}

spa/src/app/shared/cc-toolbar-nav/cc-toolbar-nav.component.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
:host, cc-toolbar-nav {
4343
display: flex;
4444
flex-direction: column;
45-
overflow: hidden;
45+
height: calc(100vh - 60px);
46+
overflow: auto;
4647
}
4748
}
4849
}

0 commit comments

Comments
 (0)