Skip to content

Commit

Permalink
fix: removed unused ItAbstractComponent from header and navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoninoBonanno committed Jan 22, 2024
1 parent 13ad966 commit 0ebe1e2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, SimpleChanges, ViewChild } from '@angular/core';
import { ItAbstractComponent } from '../../../abstracts/abstract.component';
import {
AfterViewInit,
ChangeDetectionStrategy,
Component,
ElementRef,
EventEmitter,
Input,
OnChanges,
Output,
SimpleChanges,
ViewChild,
} from '@angular/core';
import { NgIf } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
import { ItIconComponent } from '../../utils/icon/icon.component';
import { ItNavBarModule } from '../../navigation/navbar/navbar.module';
import { ItNavBarModule } from '../navbar/navbar.module';

import { ItButtonDirective } from '../../core/button/button.directive';
import { inputToBoolean } from '../../../utils/coercion';
import { HeaderSticky, Sticky } from 'bootstrap-italia';
import { HeaderSticky } from 'bootstrap-italia';

@Component({
standalone: true,
selector: 'it-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, TranslateModule, ItIconComponent, ItButtonDirective, ItNavBarModule]
imports: [NgIf, TranslateModule, ItIconComponent, ItButtonDirective, ItNavBarModule],
})
export class ItHeaderComponent extends ItAbstractComponent {

export class ItHeaderComponent implements AfterViewInit, OnChanges {
@Input({ transform: inputToBoolean }) light?: boolean;

@Input({ transform: inputToBoolean }) sticky?: boolean;
Expand All @@ -41,36 +50,30 @@ export class ItHeaderComponent extends ItAbstractComponent {

private stickyHeader?: HeaderSticky;


constructor() {
super();

this.loginClick = new EventEmitter<Event>();
this.searchClick = new EventEmitter<Event>();
}

override ngAfterViewInit() {
super.ngAfterViewInit();
this.updateListeners()
ngAfterViewInit() {
this.updateListeners();
}

override ngOnChanges(changes: SimpleChanges): void {
ngOnChanges(changes: SimpleChanges): void {
if (changes['sticky'] && changes['sticky'].currentValue == true && !changes['sticky'].firstChange) {
this.updateListeners();

Check warning on line 64 in projects/design-angular-kit/src/lib/components/navigation/header/header.component.ts

View check run for this annotation

Codecov / codecov/patch

projects/design-angular-kit/src/lib/components/navigation/header/header.component.ts#L64

Added line #L64 was not covered by tests
}
if (changes['sticky'] && changes['sticky'].currentValue == false){
if (changes['sticky'] && changes['sticky'].currentValue == false) {
this.stickyHeader?._elementObj?._unsetSticky();
this.stickyHeader?._elementObj?.dispose()
this.stickyHeader?._elementObj?.dispose();
delete this.stickyHeader;
this.stickyHeader = undefined;

Check warning on line 70 in projects/design-angular-kit/src/lib/components/navigation/header/header.component.ts

View check run for this annotation

Codecov / codecov/patch

projects/design-angular-kit/src/lib/components/navigation/header/header.component.ts#L67-L70

Added lines #L67 - L70 were not covered by tests
}
super.ngOnChanges(changes);
}

updateListeners() {
if (!this.stickyHeader && this.headerWrapper && this.sticky) {
this.stickyHeader = new HeaderSticky(this.headerWrapper.nativeElement);

Check warning on line 76 in projects/design-angular-kit/src/lib/components/navigation/header/header.component.ts

View check run for this annotation

Codecov / codecov/patch

projects/design-angular-kit/src/lib/components/navigation/header/header.component.ts#L76

Added line #L76 was not covered by tests
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { ItAbstractComponent } from '../../../../abstracts/abstract.component';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIf } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';

Expand All @@ -9,12 +8,6 @@ import { TranslateModule } from '@ngx-translate/core';
templateUrl: './navbar-item.component.html',
styleUrls: ['./navbar-item.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, TranslateModule]
imports: [NgIf, TranslateModule],
})
export class ItNavBarItemComponent extends ItAbstractComponent {

constructor() {
super();
}

}
export class ItNavBarItemComponent {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { ItAbstractComponent } from '../../../../abstracts/abstract.component';
import { NgIf } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
Expand All @@ -14,30 +14,24 @@ import { NavBarCollapsible } from 'bootstrap-italia';
templateUrl: './navbar.component.html',
styleUrls: ['./navbar.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NgIf, TranslateModule, ItIconComponent, ItButtonDirective]
imports: [NgIf, TranslateModule, ItIconComponent, ItButtonDirective],
})
export class ItNavBarComponent extends ItAbstractComponent {

private navbar?: NavBarCollapsible;
export class ItNavBarComponent implements AfterViewInit {
@Input({ transform: inputToBoolean }) megamenu?: boolean;
@Input({ transform: inputToBoolean }) expand?: boolean = true;

@ViewChild('collapseButton') private collapseButton?: ElementRef<HTMLButtonElement>;
@ViewChild('collapseView') private collapseView?: ElementRef<HTMLButtonElement>;

private navbar?: NavBarCollapsible;

constructor() {
super();
}

override ngAfterViewInit() {
super.ngAfterViewInit();
ngAfterViewInit() {
if (this.collapseButton && this.collapseView) {
this.navbar = NavBarCollapsible.getOrCreateInstance(this.collapseView.nativeElement);
}
}

toggleCollapse() {
this.navbar?.toggle(this.collapseButton?.nativeElement)
this.navbar?.toggle(this.collapseButton?.nativeElement);

Check warning on line 35 in projects/design-angular-kit/src/lib/components/navigation/navbar/navbar/navbar.component.ts

View check run for this annotation

Codecov / codecov/patch

projects/design-angular-kit/src/lib/components/navigation/navbar/navbar/navbar.component.ts#L35

Added line #L35 was not covered by tests
}

}

0 comments on commit 0ebe1e2

Please sign in to comment.