-
Notifications
You must be signed in to change notification settings - Fork 47
/
header.component.ts
72 lines (66 loc) · 2.02 KB
/
header.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
@Component({
selector: 'ag-header-nav',
template: `<nav>
<div [ngClass]="classes">
<ng-content></ng-content>
</div>
</nav>`,
styleUrls: ['./headernav.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HeaderNavComponent {
@Input() css?: string;
public get classes(): string {
return ['header-nav', this.css ? `${this.css}` : '']
.filter((cl) => cl.length)
.join(' ');
}
}
@Component({
selector: 'ag-header-nav-item',
template: `<div [ngClass]="classes"><ng-content></ng-content></div>`,
styleUrls: ['./headernavitem.css'],
})
export class HeaderNavItemComponent {
@Input() css?: string;
public get classes(): string {
let klasses = ['header-nav-item', this.css ? `${this.css}` : ''];
klasses = klasses.filter((klass) => klass.length);
return klasses.join(' ');
}
}
@Component({
selector: 'ag-header',
template: `<nav [ngClass]="classes">
<div [ngClass]="headerContentClasses"><ng-content></ng-content></div>
</nav> `,
styleUrls: ['./header.css'],
})
export class HeaderComponent {
@Input() css?: string;
@Input() isSkinned?: boolean = true;
@Input() isHeaderContentStart?: boolean = false;
@Input() isHeaderContentEnd?: boolean = false;
@Input() isSticky?: boolean;
public get classes(): string {
const baseClass = this.isSkinned ? 'header' : 'header-base';
const isStickyClass = this.isSticky ? 'header-sticky' : '';
const overrides = this.css ? `${this.css}` : '';
return [baseClass, isStickyClass, overrides]
.filter((c) => c.length)
.join(' ');
}
public get headerContentClasses(): string {
const baseClass = 'header-content';
const headerContentStart = this.isHeaderContentStart
? 'header-content-start'
: '';
const headerContentEnd = this.isHeaderContentEnd
? 'header-content-end'
: '';
return [baseClass, headerContentStart, headerContentEnd]
.filter((c) => c.length)
.join(' ');
}
}