aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/forms
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-17 14:44:19 +0200
committerChocobozzz <me@florianbigard.com>2018-07-17 14:56:15 +0200
commit0f7fedc39857ebc0eb29182c1588a92b9adfb75a (patch)
treef1516e93a93d1042bbc4d14d10575b88cae6bba1 /client/src/app/shared/forms
parent4bdd9473fdecfa7e309e3c59b05b29d0a20ac397 (diff)
downloadPeerTube-0f7fedc39857ebc0eb29182c1588a92b9adfb75a.tar.gz
PeerTube-0f7fedc39857ebc0eb29182c1588a92b9adfb75a.tar.zst
PeerTube-0f7fedc39857ebc0eb29182c1588a92b9adfb75a.zip
Improve frontend accessibility
In particular checkboxes, likes/dislikes, share button, video thumbnails and help buttons
Diffstat (limited to 'client/src/app/shared/forms')
-rw-r--r--client/src/app/shared/forms/peertube-checkbox.component.html9
-rw-r--r--client/src/app/shared/forms/peertube-checkbox.component.scss23
-rw-r--r--client/src/app/shared/forms/peertube-checkbox.component.ts45
3 files changed, 77 insertions, 0 deletions
diff --git a/client/src/app/shared/forms/peertube-checkbox.component.html b/client/src/app/shared/forms/peertube-checkbox.component.html
new file mode 100644
index 000000000..820e7a621
--- /dev/null
+++ b/client/src/app/shared/forms/peertube-checkbox.component.html
@@ -0,0 +1,9 @@
1<div class="form-group">
2 <label class="form-group-checkbox">
3 <input type="checkbox" [(ngModel)]="checked" (ngModelChange)="onModelChange()" [id]="inputName" [disabled]="isDisabled" />
4 <span role="checkbox" [attr.aria-checked]="checked"></span>
5 <span *ngIf="labelText">{{ labelText }}</span>
6 </label>
7
8 <my-help *ngIf="helpHtml" tooltipPlacement="top" helpType="custom" i18n-customHtml [customHtml]="helpHtml"></my-help>
9</div> \ No newline at end of file
diff --git a/client/src/app/shared/forms/peertube-checkbox.component.scss b/client/src/app/shared/forms/peertube-checkbox.component.scss
new file mode 100644
index 000000000..cbc50dc96
--- /dev/null
+++ b/client/src/app/shared/forms/peertube-checkbox.component.scss
@@ -0,0 +1,23 @@
1@import '_variables';
2@import '_mixins';
3
4.form-group {
5 display: flex;
6 align-items: center;
7
8 .form-group-checkbox {
9 display: flex;
10
11 span {
12 font-weight: $font-regular;
13 margin: 0;
14 }
15
16 input {
17 @include peertube-checkbox(1px);
18
19 width: 10px;
20 margin-right: 10px;
21 }
22 }
23} \ No newline at end of file
diff --git a/client/src/app/shared/forms/peertube-checkbox.component.ts b/client/src/app/shared/forms/peertube-checkbox.component.ts
new file mode 100644
index 000000000..c626c4c5d
--- /dev/null
+++ b/client/src/app/shared/forms/peertube-checkbox.component.ts
@@ -0,0 +1,45 @@
1import { Component, forwardRef, Input } from '@angular/core'
2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3
4@Component({
5 selector: 'my-peertube-checkbox',
6 styleUrls: [ './peertube-checkbox.component.scss' ],
7 templateUrl: './peertube-checkbox.component.html',
8 providers: [
9 {
10 provide: NG_VALUE_ACCESSOR,
11 useExisting: forwardRef(() => PeertubeCheckboxComponent),
12 multi: true
13 }
14 ]
15})
16export class PeertubeCheckboxComponent implements ControlValueAccessor {
17 @Input() checked = false
18 @Input() inputName: string
19 @Input() labelText: string
20 @Input() helpHtml: string
21
22 isDisabled = false
23
24 propagateChange = (_: any) => { /* empty */ }
25
26 writeValue (checked: boolean) {
27 this.checked = checked
28 }
29
30 registerOnChange (fn: (_: any) => void) {
31 this.propagateChange = fn
32 }
33
34 registerOnTouched () {
35 // Unused
36 }
37
38 onModelChange () {
39 this.propagateChange(this.checked)
40 }
41
42 setDisabledState (isDisabled: boolean) {
43 this.isDisabled = isDisabled
44 }
45}