forked from buttons/github-buttons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-button.component.ts
More file actions
29 lines (23 loc) · 997 Bytes
/
github-button.component.ts
File metadata and controls
29 lines (23 loc) · 997 Bytes
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
import { Component, Input, ElementRef, OnChanges, AfterViewChecked } from '@angular/core'
import { render } from 'github-buttons'
@Component({
selector: 'github-button',
template: `<a [href]="href" [attr.data-icon]="dataIcon" [attr.data-size]="dataSize" [attr.data-show-count]="dataShowCount" [attr.data-text]="dataText" [attr.aria-label]="ariaLabel"><ng-content></ng-content></a>
`
})
export class GithubButtonComponent implements OnChanges, AfterViewChecked {
@Input() href: string = ""
@Input('data-icon') dataIcon: string
@Input('data-size') dataSize: string
@Input('data-show-count') dataShowCount: string
@Input('data-text') dataText: string
@Input('aria-label') ariaLabel: string
private _: Node
constructor(private el: ElementRef) {}
ngOnChanges() {
this._ && this.el.nativeElement.replaceChild(this._, this.el.nativeElement.firstChild) && (this._ = null)
}
ngAfterViewChecked() {
this._ || render(this._ = this.el.nativeElement.firstChild)
}
}