-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaq.ts
More file actions
54 lines (51 loc) · 1.85 KB
/
Copy pathfaq.ts
File metadata and controls
54 lines (51 loc) · 1.85 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Component, signal } from '@angular/core';
import { TranslatePipe } from '@ngx-translate/core';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { faChevronDown } from '@fortawesome/free-solid-svg-icons';
@Component({
selector: 'app-faq',
imports: [FontAwesomeModule, TranslatePipe],
styleUrl: './faq.scss',
template: `
<section id="faq" class="faq">
<div class="container">
<div class="section-header">
<div class="eyebrow">{{ 'faq.eyebrow' | translate }}</div>
<h2 class="section-title">{{ 'faq.title' | translate }}</h2>
<p class="section-description">
{{ 'faq.description' | translate }}
</p>
</div>
<div class="faq-list">
@for (i of indices; track i) {
<div class="faq-item" [class.is-open]="open() === i">
<button
type="button"
class="faq-q"
[attr.aria-expanded]="open() === i"
[attr.aria-controls]="'faq-a-' + i"
(click)="toggle(i)"
>
<span>{{ 'faq.items.' + i + '.q' | translate }}</span>
<fa-icon [icon]="faChevronDown" class="faq-icon" aria-hidden="true" />
</button>
<div class="faq-a-wrap" [id]="'faq-a-' + i" role="region">
<div class="faq-a-inner">
<div class="faq-a">{{ 'faq.items.' + i + '.a' | translate }}</div>
</div>
</div>
</div>
}
</div>
</div>
</section>
`,
})
export class Faq {
protected open = signal<number | null>(0);
protected readonly faChevronDown = faChevronDown;
protected readonly indices = [0, 1, 2, 3, 4, 5, 6, 7, 8];
toggle(index: number) {
this.open.update(current => (current === index ? null : index));
}
}