1
0
Fork 0
peertube/client/src/app/header/suggestion.component.ts

34 lines
853 B
TypeScript
Raw Normal View History

2020-05-29 14:16:24 +00:00
import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy, OnChanges } from '@angular/core'
import { RouterLink } from '@angular/router'
import { ListKeyManagerOption } from '@angular/cdk/a11y'
2020-05-29 14:16:24 +00:00
export type SuggestionPayload = {
text: string
2020-05-29 14:16:24 +00:00
type: SuggestionPayloadType
routerLink?: RouterLink
default: boolean
}
2020-05-29 14:16:24 +00:00
export type SuggestionPayloadType = 'search-instance' | 'search-index'
@Component({
selector: 'my-suggestion',
templateUrl: './suggestion.component.html',
2020-05-29 14:16:24 +00:00
styleUrls: [ './suggestion.component.scss' ]
})
export class SuggestionComponent implements OnInit, ListKeyManagerOption {
2020-05-29 14:16:24 +00:00
@Input() result: SuggestionPayload
@Input() highlight: string
disabled = false
active = false
getLabel () {
return this.result.text
}
ngOnInit () {
if (this.result.default) this.active = true
}
}