-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
193 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 34 additions & 9 deletions
43
projects/design-angular-kit/src/lib/components/navigation/header/header.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,70 @@ | ||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, SimpleChanges, ViewChild } from '@angular/core'; | ||
import { ItAbstractComponent } from '../../../abstracts/abstract.component'; | ||
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 { ItButtonDirective } from '../../core/button/button.directive'; | ||
import { inputToBoolean } from '../../../utils/coercion'; | ||
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] | ||
imports: [NgIf, TranslateModule, ItIconComponent, ItButtonDirective, ItNavBarModule] | ||
}) | ||
export class ItHeaderComponent extends ItAbstractComponent { | ||
|
||
@Input({ transform: inputToBoolean }) light?: boolean; | ||
|
||
@Input({ transform: inputToBoolean }) showSlim?: boolean = true; | ||
@Input({ transform: inputToBoolean }) sticky?: boolean; | ||
|
||
@Input() slimTitle: string | undefined; | ||
|
||
@Input() loginStyle: 'none' | 'default' | 'full' = 'none'; | ||
@Input({ transform: inputToBoolean }) showSlim?: boolean = true; | ||
|
||
@Input({ transform: inputToBoolean }) smallHeader?: boolean = true; | ||
|
||
@Input({ transform: inputToBoolean }) showSearch?: boolean = true; | ||
|
||
@Input() slimTitle: string | undefined; | ||
|
||
@Input() loginStyle: 'none' | 'default' | 'full' = 'none'; | ||
|
||
@Output() loginClick: EventEmitter<Event>; | ||
|
||
@Output() searchClick: EventEmitter<Event>; | ||
|
||
/** | ||
* TODO: complete header | ||
*/ | ||
@ViewChild('headerWrapper') private headerWrapper?: ElementRef<HTMLButtonElement>; | ||
|
||
private stickyHeader?: HeaderSticky; | ||
|
||
|
||
constructor() { | ||
super(); | ||
|
||
this.loginClick = new EventEmitter<Event>(); | ||
this.searchClick = new EventEmitter<Event>(); | ||
} | ||
|
||
override ngAfterViewInit() { | ||
super.ngAfterViewInit(); | ||
this.updateListeners() | ||
} | ||
|
||
override ngOnChanges(changes: SimpleChanges): void { | ||
if (changes['sticky'] && !changes['sticky'].firstChange) { | ||
this.updateListeners(); | ||
} | ||
super.ngOnChanges(changes); | ||
} | ||
|
||
updateListeners() { | ||
if (this.headerWrapper && this.sticky) { | ||
this.stickyHeader = HeaderSticky.getOrCreateInstance(this.headerWrapper.nativeElement); | ||
} | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
...n-angular-kit/src/lib/components/navigation/navbar/navbar-item/navbar-item.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class="nav-item"> | ||
<ng-content></ng-content> | ||
</li> |
Empty file.
20 changes: 20 additions & 0 deletions
20
...ign-angular-kit/src/lib/components/navigation/navbar/navbar-item/navbar-item.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { ItAbstractComponent } from '../../../../abstracts/abstract.component'; | ||
import { NgIf } from '@angular/common'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'it-navbar-item', | ||
templateUrl: './navbar-item.component.html', | ||
styleUrls: ['./navbar-item.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
imports: [NgIf, TranslateModule] | ||
}) | ||
export class ItNavBarItemComponent extends ItAbstractComponent { | ||
|
||
constructor() { | ||
super(); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
projects/design-angular-kit/src/lib/components/navigation/navbar/navbar.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { ItNavBarComponent } from './navbar/navbar.component'; | ||
import { ItNavBarItemComponent } from './navbar-item/navbar-item.component'; | ||
|
||
const navbarComponents = [ItNavBarComponent, ItNavBarItemComponent]; | ||
|
||
@NgModule({ | ||
imports: navbarComponents, | ||
exports: navbarComponents | ||
}) | ||
export class ItNavBarModule { } |
19 changes: 19 additions & 0 deletions
19
...ects/design-angular-kit/src/lib/components/navigation/navbar/navbar/navbar.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<nav class="navbar" [class.navbar-expand-lg]="expand" [class.has-megamenu]="megamenu" [attr.aria-label]="'it.navbar.aria-label-main'|translate"> | ||
<button (click)="toggleCollapse()" #collapseButton class="custom-navbar-toggler" type="button" [attr.aria-label]="'it.navbar.aria-label-toggle'|translate"> | ||
<it-icon name="burger"></it-icon> | ||
</button> | ||
<div #collapseView class="navbar-collapsable" style="display: none;"> | ||
<div class="overlay" style="display: none;"></div> | ||
<div class="close-div"> | ||
<button class="btn close-menu" type="button"> | ||
<span class="visually-hidden">{{'it.navbar.hide'|translate}}</span> | ||
<it-icon name="close-big"></it-icon> | ||
</button> | ||
</div> | ||
<div class="menu-wrapper"> | ||
<ul class="navbar-nav"> | ||
<ng-content select="[navItems]"></ng-content> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> |
Empty file.
43 changes: 43 additions & 0 deletions
43
projects/design-angular-kit/src/lib/components/navigation/navbar/navbar/navbar.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { 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'; | ||
import { ItIconComponent } from '../../../utils/icon/icon.component'; | ||
import { ItButtonDirective } from '../../../core/button/button.directive'; | ||
import { inputToBoolean } from '../../../../utils/coercion'; | ||
|
||
import { NavBarCollapsible } from 'bootstrap-italia'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'it-navbar', | ||
templateUrl: './navbar.component.html', | ||
styleUrls: ['./navbar.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
imports: [NgIf, TranslateModule, ItIconComponent, ItButtonDirective] | ||
}) | ||
export class ItNavBarComponent extends ItAbstractComponent { | ||
|
||
private navbar?: NavBarCollapsible; | ||
@Input({ transform: inputToBoolean }) megamenu?: boolean; | ||
@Input({ transform: inputToBoolean }) expand?: boolean = true; | ||
@ViewChild('collapseButton') private collapseButton?: ElementRef<HTMLButtonElement>; | ||
@ViewChild('collapseView') private collapseView?: ElementRef<HTMLButtonElement>; | ||
|
||
|
||
constructor() { | ||
super(); | ||
} | ||
|
||
override ngAfterViewInit() { | ||
super.ngAfterViewInit(); | ||
if (this.collapseButton && this.collapseView) { | ||
this.navbar = NavBarCollapsible.getOrCreateInstance(this.collapseView.nativeElement); | ||
} | ||
} | ||
|
||
toggleCollapse() { | ||
this.navbar?.toggle(this.collapseButton?.nativeElement) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters