Skip to content

Commit 7c0fdcb

Browse files
authored
Merge pull request DSpace#2527 from alexandrevryghem/add-display-none-to-hidden-navbar-buttons_contribute-7.6
Minor header button improvements
2 parents a9d7ee3 + fa56d5d commit 7c0fdcb

35 files changed

Lines changed: 178 additions & 62 deletions

src/app/admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import { Router } from '@angular/router';
1212
* Represents a non-expandable section in the admin sidebar
1313
*/
1414
@Component({
15-
/* eslint-disable @angular-eslint/component-selector */
16-
selector: 'li[ds-admin-sidebar-section]',
15+
selector: 'ds-admin-sidebar-section',
1716
templateUrl: './admin-sidebar-section.component.html',
1817
styleUrls: ['./admin-sidebar-section.component.scss'],
1918

src/app/admin/admin-sidebar/admin-sidebar.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ <h4 class="section-header-text mb-0">{{ 'menu.header.admin' | translate }}</h4>
2626
</div>
2727
</li>
2828

29-
<ng-container *ngFor="let section of (sections | async)">
29+
<li *ngFor="let section of (sections | async)">
3030
<ng-container
3131
*ngComponentOutlet="(sectionMap$ | async).get(section.id).component; injector: (sectionMap$ | async).get(section.id).injector;"></ng-container>
32-
</ng-container>
32+
</li>
3333
</ul>
3434
</div>
3535
<div class="navbar-nav">

src/app/admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import { Router } from '@angular/router';
1515
* Represents a expandable section in the sidebar
1616
*/
1717
@Component({
18-
/* eslint-disable @angular-eslint/component-selector */
19-
selector: 'li[ds-expandable-admin-sidebar-section]',
18+
selector: 'ds-expandable-admin-sidebar-section',
2019
templateUrl: './expandable-admin-sidebar-section.component.html',
2120
styleUrls: ['./expandable-admin-sidebar-section.component.scss'],
2221
animations: [rotate, slide, bgColor]

src/app/header/context-help-toggle/context-help-toggle.component.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, ElementRef } from '@angular/core';
22
import { ContextHelpService } from '../../shared/context-help.service';
3-
import { Observable } from 'rxjs';
3+
import { Observable, Subscription } from 'rxjs';
44
import { map } from 'rxjs/operators';
55

66
/**
@@ -15,12 +15,23 @@ import { map } from 'rxjs/operators';
1515
export class ContextHelpToggleComponent implements OnInit {
1616
buttonVisible$: Observable<boolean>;
1717

18+
subscriptions: Subscription[] = [];
19+
1820
constructor(
19-
private contextHelpService: ContextHelpService,
20-
) { }
21+
protected elRef: ElementRef,
22+
protected contextHelpService: ContextHelpService,
23+
) {
24+
}
2125

2226
ngOnInit(): void {
2327
this.buttonVisible$ = this.contextHelpService.tooltipCount$().pipe(map(x => x > 0));
28+
this.subscriptions.push(this.buttonVisible$.subscribe((showContextHelpToggle: boolean) => {
29+
if (showContextHelpToggle) {
30+
this.elRef.nativeElement.classList.remove('d-none');
31+
} else {
32+
this.elRef.nativeElement.classList.add('d-none');
33+
}
34+
}));
2435
}
2536

2637
onClick() {

src/app/header/header.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
<nav role="navigation" [attr.aria-label]="'nav.user.description' | translate" class="navbar navbar-light navbar-expand-md flex-shrink-0 px-0">
99
<ds-themed-search-navbar></ds-themed-search-navbar>
10-
<ds-lang-switch></ds-lang-switch>
10+
<ds-themed-lang-switch></ds-themed-lang-switch>
1111
<ds-context-help-toggle></ds-context-help-toggle>
1212
<ds-themed-auth-nav-menu></ds-themed-auth-nav-menu>
1313
<ds-impersonate-navbar></ds-impersonate-navbar>
14-
<div class="pl-2">
15-
<button class="navbar-toggler" type="button" (click)="toggleNavbar()"
14+
<div *ngIf="isXsOrSm$ | async" class="pl-2">
15+
<button class="navbar-toggler px-0" type="button" (click)="toggleNavbar()"
1616
aria-controls="collapsingNav"
1717
aria-expanded="false" [attr.aria-label]="'nav.toggle' | translate">
1818
<span class="navbar-toggler-icon fas fa-bars fa-fw" aria-hidden="true"></span>

src/app/header/header.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@
2020
}
2121
}
2222

23+
.navbar {
24+
display: flex;
25+
gap: calc(var(--bs-spacer) / 3);
26+
align-items: center;
27+
}

src/app/header/header.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
1010
import { NO_ERRORS_SCHEMA } from '@angular/core';
1111
import { MenuService } from '../shared/menu/menu.service';
1212
import { MenuServiceStub } from '../shared/testing/menu-service.stub';
13+
import { HostWindowService } from '../shared/host-window.service';
14+
import { HostWindowServiceStub } from '../shared/testing/host-window-service.stub';
1315

1416
let comp: HeaderComponent;
1517
let fixture: ComponentFixture<HeaderComponent>;
@@ -26,6 +28,7 @@ describe('HeaderComponent', () => {
2628
ReactiveFormsModule],
2729
declarations: [HeaderComponent],
2830
providers: [
31+
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
2932
{ provide: MenuService, useValue: menuService }
3033
],
3134
schemas: [NO_ERRORS_SCHEMA]
@@ -40,7 +43,7 @@ describe('HeaderComponent', () => {
4043
fixture = TestBed.createComponent(HeaderComponent);
4144

4245
comp = fixture.componentInstance;
43-
46+
fixture.detectChanges();
4447
});
4548

4649
describe('when the toggle button is clicked', () => {

src/app/header/header.component.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Component } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import { MenuService } from '../shared/menu/menu.service';
44
import { MenuID } from '../shared/menu/menu-id.model';
5+
import { HostWindowService } from '../shared/host-window.service';
56

67
/**
78
* Represents the header with the logo and simple navigation
@@ -11,20 +12,25 @@ import { MenuID } from '../shared/menu/menu-id.model';
1112
styleUrls: ['header.component.scss'],
1213
templateUrl: 'header.component.html',
1314
})
14-
export class HeaderComponent {
15+
export class HeaderComponent implements OnInit {
1516
/**
1617
* Whether user is authenticated.
1718
* @type {Observable<string>}
1819
*/
1920
public isAuthenticated: Observable<boolean>;
20-
public showAuth = false;
21+
public isXsOrSm$: Observable<boolean>;
2122
menuID = MenuID.PUBLIC;
2223

2324
constructor(
24-
private menuService: MenuService
25+
protected menuService: MenuService,
26+
protected windowService: HostWindowService,
2527
) {
2628
}
2729

30+
ngOnInit(): void {
31+
this.isXsOrSm$ = this.windowService.isXsOrSm();
32+
}
33+
2834
public toggleNavbar(): void {
2935
this.menuService.toggleMenu(this.menuID);
3036
}

src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
</a>
1515
<ul @slide *ngIf="(active | async)" (click)="deactivateSection($event)"
1616
class="m-0 shadow-none border-top-0 dropdown-menu show">
17-
<ng-container *ngFor="let subSection of (subSections$ | async)">
17+
<li *ngFor="let subSection of (subSections$ | async)">
1818
<ng-container
1919
*ngComponentOutlet="(sectionMap$ | async).get(subSection.id).component; injector: (sectionMap$ | async).get(subSection.id).injector;"></ng-container>
20-
</ng-container>
20+
</li>
2121
</ul>
2222
</div>

src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { MenuService } from '../../shared/menu/menu.service';
44
import { slide } from '../../shared/animations/slide';
55
import { first } from 'rxjs/operators';
66
import { HostWindowService } from '../../shared/host-window.service';
7-
import { rendersSectionForMenu } from '../../shared/menu/menu-section.decorator';
87
import { MenuID } from '../../shared/menu/menu-id.model';
98

109
/**
@@ -16,7 +15,6 @@ import { MenuID } from '../../shared/menu/menu-id.model';
1615
styleUrls: ['./expandable-navbar-section.component.scss'],
1716
animations: [slide]
1817
})
19-
@rendersSectionForMenu(MenuID.PUBLIC, true)
2018
export class ExpandableNavbarSectionComponent extends NavbarSectionComponent implements OnInit {
2119
/**
2220
* This section resides in the Public Navbar

0 commit comments

Comments
 (0)