Skip to content

Commit 9f2a1d0

Browse files
Use gap instead of individual paddings for header icons
1 parent 404ccd9 commit 9f2a1d0

15 files changed

+97
-34
lines changed

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@
2020
}
2121
}
2222

23+
.navbar {
24+
display: flex;
25+
gap: 0.25rem;
26+
}

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/search-navbar/search-navbar.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div id="search-navbar-container" [title]="'nav.search' | translate" (dsClickOutside)="collapse()">
22
<div class="d-inline-block position-relative">
3-
<form [formGroup]="searchForm" (ngSubmit)="onSubmit(searchForm.value)" autocomplete="on">
3+
<form [formGroup]="searchForm" (ngSubmit)="onSubmit(searchForm.value)" autocomplete="on" class="d-flex">
44
<input #searchInput [@toggleAnimation]="isExpanded" [attr.aria-label]="('nav.search' | translate)" name="query"
55
formControlName="query" type="text" placeholder="{{searchExpanded ? ('nav.search' | translate) : ''}}"
6-
class="d-inline-block bg-transparent position-absolute form-control dropdown-menu-right p-1" [attr.data-test]="'header-search-box' | dsBrowserOnly">
6+
class="d-inline-block bg-transparent position-absolute form-control dropdown-menu-right pl-1" [attr.data-test]="'header-search-box' | dsBrowserOnly">
77
<button class="submit-icon btn btn-link btn-link-inline" [attr.aria-label]="'nav.search.button' | translate" type="button" (click)="searchExpanded ? onSubmit(searchForm.value) : expand()" [attr.data-test]="'header-search-icon' | dsBrowserOnly">
88
<em class="fas fa-search fa-lg fa-fw"></em>
99
</button>

src/app/search-navbar/search-navbar.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ input[type="text"] {
1212
cursor: pointer;
1313
position: sticky;
1414
top: 0;
15+
border: 0 !important;
1516

1617
color: var(--ds-header-icon-color);
1718
&:hover, &:focus {

src/app/shared/animations/slide.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const slideSidebarPadding = trigger('slideSidebarPadding', [
5555

5656
export const expandSearchInput = trigger('toggleAnimation', [
5757
state('collapsed', style({
58-
width: '30px',
58+
width: '0',
5959
opacity: '0'
6060
})),
6161
state('expanded', style({

src/app/shared/auth-nav-menu/auth-nav-menu.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<li *ngIf="!(isAuthenticated | async) && !(isXsOrSm$ | async) && (showAuth | async)" class="nav-item"
33
(click)="$event.stopPropagation();">
44
<div ngbDropdown #loginDrop display="dynamic" placement="bottom-right" class="d-inline-block" @fadeInOut>
5-
<a href="javascript:void(0);" class="dropdownLogin px-1" [attr.aria-label]="'nav.login' |translate"
5+
<a href="javascript:void(0);" class="dropdownLogin px-0.5" [attr.aria-label]="'nav.login' |translate"
66
(click)="$event.preventDefault()" [attr.data-test]="'login-menu' | dsBrowserOnly"
77
ngbDropdownToggle>{{ 'nav.login' | translate }}</a>
88
<div class="loginDropdownMenu" [ngClass]="{'pl-3 pr-3': (loading | async)}" ngbDropdownMenu
@@ -13,7 +13,7 @@
1313
</div>
1414
</li>
1515
<li *ngIf="!(isAuthenticated | async) && (isXsOrSm$ | async)" class="nav-item">
16-
<a routerLink="/login" routerLinkActive="active" class="loginLink px-1">
16+
<a routerLink="/login" routerLinkActive="active" class="loginLink px-0.5">
1717
{{ 'nav.login' | translate }}<span class="sr-only">(current)</span>
1818
</a>
1919
</li>

src/app/shared/impersonate-navbar/impersonate-navbar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ul class="navbar-nav" *ngIf="(isAuthenticated$ | async) && isImpersonating">
1+
<ul class="navbar-nav" *ngIf="isImpersonating$ | async">
22
<li class="nav-item">
33
<button class="btn btn-sm btn-dark" ngbTooltip="{{'nav.stop-impersonating' | translate}}" (click)="stopImpersonating()">
44
<i class="fa fa-user-secret"></i>

0 commit comments

Comments
 (0)