-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(package): added
mat-link-preview-container
component to render…
… the link preview
- Loading branch information
1 parent
21aadef
commit c965247
Showing
5 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/module/components/mat-link-preview-container/mat-link-preview-container.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 @@ | ||
<ng-container *ngFor="let link of linkPreviewService.links; trackBy: trackLinks"> | ||
<mat-link-preview [link]="link"></mat-link-preview> | ||
</ng-container> |
3 changes: 3 additions & 0 deletions
3
src/module/components/mat-link-preview-container/mat-link-preview-container.component.scss
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 @@ | ||
:host { | ||
display: block; | ||
} |
34 changes: 34 additions & 0 deletions
34
...module/components/mat-link-preview-container/mat-link-preview-container.component.spec.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,34 @@ | ||
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import {MatLinkPreviewContainerComponent} from './mat-link-preview-container.component'; | ||
import {MatProgressBarModule} from '@angular/material'; | ||
import {LinkPreviewService} from '../../..'; | ||
import {Link} from 'ngx-linkifyjs'; | ||
import {EventEmitter} from '@angular/core'; | ||
|
||
describe('MatLinkPreviewContainerComponent', () => { | ||
let component: MatLinkPreviewContainerComponent; | ||
let fixture: ComponentFixture<MatLinkPreviewContainerComponent>; | ||
const linkPreviewServicePartial: Partial<LinkPreviewService> = { | ||
onLinkFound: new EventEmitter<Array<Link>>() | ||
}; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [MatProgressBarModule], | ||
declarations: [MatLinkPreviewContainerComponent], | ||
providers: [{provide: LinkPreviewService, useValue: linkPreviewServicePartial}] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MatLinkPreviewContainerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
src/module/components/mat-link-preview-container/mat-link-preview-container.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,21 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import {LinkPreviewService} from '../../..'; | ||
import {Link} from 'ngx-linkifyjs'; | ||
|
||
@Component({ | ||
selector: 'mat-link-preview-container', | ||
templateUrl: './mat-link-preview-container.component.html', | ||
styleUrls: ['./mat-link-preview-container.component.scss'] | ||
}) | ||
export class MatLinkPreviewContainerComponent implements OnInit { | ||
|
||
constructor(public linkPreviewService: LinkPreviewService) { | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
trackLinks(index: number, link: Link) { | ||
return link ? link.href : undefined; | ||
} | ||
} |
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