aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/header/suggestion.component.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-01-25 16:32:06 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-02-13 16:32:21 +0100
commit6af662a5961b48ac12682df2b8b971060a2cc67d (patch)
treede1efc71cbe8543b5b832e5de99a407a54c37220 /client/src/app/header/suggestion.component.ts
parentf409f0c3b91d85c66b4841d72ea65b5fbe1483d8 (diff)
downloadPeerTube-6af662a5961b48ac12682df2b8b971060a2cc67d.tar.gz
PeerTube-6af662a5961b48ac12682df2b8b971060a2cc67d.tar.zst
PeerTube-6af662a5961b48ac12682df2b8b971060a2cc67d.zip
Add keyboard navigation and hepler to typeahead
Diffstat (limited to 'client/src/app/header/suggestion.component.ts')
-rw-r--r--client/src/app/header/suggestion.component.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/client/src/app/header/suggestion.component.ts b/client/src/app/header/suggestion.component.ts
new file mode 100644
index 000000000..75c44a583
--- /dev/null
+++ b/client/src/app/header/suggestion.component.ts
@@ -0,0 +1,48 @@
1import { Input, Component, Output, EventEmitter, OnInit } from '@angular/core'
2import { RouterLink } from '@angular/router'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { ListKeyManagerOption } from '@angular/cdk/a11y'
5
6type Result = {
7 text: string
8 type: 'channel' | 'suggestion' | 'search-channel' | 'search-instance' | 'search-global' | 'search-any'
9 routerLink?: RouterLink
10}
11
12@Component({
13 selector: 'my-suggestion',
14 templateUrl: './suggestion.component.html',
15 styleUrls: [ './suggestion.component.scss' ]
16})
17export class SuggestionComponent implements OnInit, ListKeyManagerOption {
18 @Input() result: Result
19 @Input() highlight: string
20 @Output() selected = new EventEmitter()
21
22 inAllText: string
23 inThisChannelText: string
24 inThisInstanceText: string
25
26 disabled = false
27 active = false
28
29 constructor (
30 private i18n: I18n
31 ) {
32 this.inAllText = this.i18n('In the vidiverse')
33 this.inThisChannelText = this.i18n('In this channel')
34 this.inThisInstanceText = this.i18n('In this instance')
35 }
36
37 getLabel () {
38 return this.result.text
39 }
40
41 ngOnInit () {
42 this.active = false
43 }
44
45 selectItem () {
46 this.selected.emit(this.result)
47 }
48}