]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/header/suggestion.component.ts
69641b511b9612f55c40fe3155bb980f301b2808
[github/Chocobozzz/PeerTube.git] / client / src / app / header / suggestion.component.ts
1 import { Input, Component, Output, EventEmitter, OnInit, ChangeDetectionStrategy } from '@angular/core'
2 import { RouterLink } from '@angular/router'
3 import { ListKeyManagerOption } from '@angular/cdk/a11y'
4
5 export type Result = {
6 text: string
7 type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any'
8 routerLink?: RouterLink,
9 default?: boolean
10 }
11
12 @Component({
13 selector: 'my-suggestion',
14 templateUrl: './suggestion.component.html',
15 styleUrls: [ './suggestion.component.scss' ],
16 changeDetection: ChangeDetectionStrategy.OnPush
17 })
18 export class SuggestionComponent implements OnInit, ListKeyManagerOption {
19 @Input() result: Result
20 @Input() highlight: string
21 @Output() selected = new EventEmitter()
22
23 disabled = false
24 active = false
25
26 getLabel () {
27 return this.result.text
28 }
29
30 ngOnInit () {
31 if (this.result.default) this.active = true
32 }
33
34 selectItem () {
35 this.selected.emit(this.result)
36 }
37 }