File
Implements
Metadata
changeDetection |
ChangeDetectionStrategy.OnPush |
selector |
div[related-links-footer-sole] |
styleUrls |
./related-links-footer-sole.component.scss |
templateUrl |
./related-links-footer-sole.component.html |
Index
Properties
|
|
Methods
|
|
Inputs
|
|
HostBindings
|
|
Methods
actOnResize
|
actOnResize()
|
|
|
ngOnDestroy
|
ngOnDestroy()
|
|
|
parseJson
|
parseJson(data: any)
|
|
Parameters :
Name |
Type |
Optional |
data |
any
|
No
|
|
copyrightLabel
|
Type : string
|
Default value : '[copyright]'
|
|
import { Component, OnInit, Input, ChangeDetectionStrategy, ChangeDetectorRef, HostBinding, OnDestroy, Inject } from '@angular/core';
import { UtilService } from 'src/app/core/services/util-service/util.service';
import { ComponentLinkService } from 'src/app/core/services/component-link-service/component-link.service';
import { LabelService } from 'src/app/core/services/label-service/label-service.service';
import { ComponentLink } from 'src/app/core/interfaces/interfaces.component';
import { ResizeContentService } from 'src/app/core/services/resize-service/resize-content.service';
import { IdGeneratorService } from 'src/app/core/services/id-generator.service';
import { ConstantsService } from 'src/app/shared/constants/constants.service';
import { DOCUMENT } from '@angular/common';
interface IRelatedLinks {
icon: string;
title: string;
links: ComponentLink[];
}
@Component({
selector: 'div[related-links-footer-sole]',
templateUrl: './related-links-footer-sole.component.html',
styleUrls: ['./related-links-footer-sole.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class RelatedLinksFooterSoleComponent implements OnInit, OnDestroy {
@Input() entity;
data: IRelatedLinks;
copyrightLabel = '[copyright]';
componentId: string;
inDesktop: boolean;
@HostBinding('class') get class() { return 'bg-blue bd-y-white'; }
constructor(
private util: UtilService,
private linkService: ComponentLinkService,
private labels: LabelService,
private changeDetector: ChangeDetectorRef,
private idGenerator: IdGeneratorService,
private resizer: ResizeContentService,
private constants: ConstantsService,
@Inject(DOCUMENT) private doc
) { }
ngOnInit() {
this.labels.getLabel('copyright').then(label => {
this.copyrightLabel = label;
this.changeDetector.detectChanges();
});
if (this.entity) {
this.data = this.parseJson(this.entity);
}
this.componentId = this.idGenerator.getId();
this.resizer.registerCallback(this.componentId, () => this.actOnResize());
// Run the function manually once to set the inDesktop variable to it's correct value
this.actOnResize();
}
actOnResize() {
const width = (window.innerWidth || this.doc.documentElement.clientWidth);
this.inDesktop = width >= this.constants.BOOTSTRAP_BREAKPOINTS.LG;
}
ngOnDestroy(): void {
this.resizer.destroyCallback(this.componentId);
}
parseJson(data: any): IRelatedLinks {
return {
icon: this.util.extract(data, 'Icon'),
title: this.util.extract(data, 'Title'),
links: (this.util.extract(data, 'LinkTargets') || []).map(link => this.linkService.parseLink(link))
};
}
}
<div [ngClass]="{'container': inDesktop, 'container-fluid': !inDesktop}">
<nav class="navbar navbar-expand-lg navbar-dark bg-blue" *ngIf="data">
<div class="navbar-brand"><img src="v2/assets/img/skf-logo-white.svg"></div>
<ul class="navbar-nav">
<li class="nav-item">
© {{copyrightLabel}}
</li>
<li class="nav-item" *ngFor="let link of data.links">
<a component-link [linkObject]="link.linkObject" class="nav-link">
<i *ngIf="link.linkObject?.LinkModelTarget?.MimeType === 'application/zip' " class="icon-link-download"></i>
{{link.title}}
</a>
</li>
</ul>
</nav>
</div>
@import "src/app/styles/helpers";
.container-fluid {
@include media-breakpoint-down(lg) {
padding-left: 0;
padding-right: 0;
}
}
.navbar {
padding: calc-rem(10) 0;
justify-content: flex-start;
&-nav {
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
&-brand {
margin-left: calc-rem(24);
margin-right: calc-rem(60);
padding-bottom: calc-rem(10);
width: 100px;
}
}
.nav-item {
@include font-scale(14, medium);
padding-left: calc-rem(15);
padding-right: calc-rem(15);
color: $white;
::ng-deep .nav-link {
color: $light-blue;
&:hover {
color: $light-blue;
text-decoration: underline;
}
&[target=_blank]:after {
content: none;
}
}
}
Legend
Html element with directive