Skip to content

Commit 540de5e

Browse files
feat(Authoring): Use slider to set activity width (#2310)
Co-authored-by: Jonathan Lim-Breitbart <breity10@gmail.com>
1 parent 0369726 commit 540de5e

2 files changed

Lines changed: 51 additions & 17 deletions

File tree

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
11
import { Component } from '@angular/core';
2-
import { EditComponentFieldComponent } from '../edit-component-field.component';
3-
import { MatFormFieldModule } from '@angular/material/form-field';
4-
import { MatInputModule } from '@angular/material/input';
52
import { FormsModule } from '@angular/forms';
3+
import { MatIconModule } from '@angular/material/icon';
4+
import { MatTooltipModule } from '@angular/material/tooltip';
5+
import { MatButtonToggleModule } from '@angular/material/button-toggle';
6+
import { EditComponentFieldComponent } from '../edit-component-field.component';
67

78
@Component({
8-
imports: [FormsModule, MatFormFieldModule, MatInputModule],
9+
imports: [FormsModule, MatButtonToggleModule, MatIconModule, MatTooltipModule],
910
selector: 'edit-component-width',
10-
template: `<mat-form-field>
11-
<mat-label i18n>Activity Width</mat-label>
12-
<input
13-
matInput
14-
type="number"
15-
[(ngModel)]="componentContent.componentWidth"
16-
(ngModelChange)="inputChanged.next($event)"
17-
/>
18-
</mat-form-field> `
11+
template: `<div class="flex items-center gap-2 my-2">
12+
<span i18n>Activity width</span>
13+
<mat-icon
14+
tabindex="0"
15+
matTooltip="The activity's width determines how it appears on the screen. If two adjacent
16+
activities are set to 50% each (or 67% and 33%, for example), they will appear side-by-side."
17+
matTooltipPosition="above"
18+
i18n-matTooltip
19+
>help</mat-icon
20+
>
21+
</div>
22+
<mat-button-toggle-group
23+
[(ngModel)]="selectedValue"
24+
(change)="onWidthChange()"
25+
aria-label="Activity width"
26+
hideSingleSelectionIndicator="true"
27+
>
28+
@for (value of possibleValues; track $index) {
29+
<mat-button-toggle value="{{ value }}">{{ value }}%</mat-button-toggle>
30+
}
31+
</mat-button-toggle-group>`
1932
})
20-
export class EditComponentWidthComponent extends EditComponentFieldComponent {}
33+
export class EditComponentWidthComponent extends EditComponentFieldComponent {
34+
protected possibleValues = [25, 33, 50, 67, 75, 100];
35+
protected selectedValue = '100';
36+
37+
public override ngOnInit(): void {
38+
super.ngOnInit();
39+
this.selectedValue = String(this.componentContent.componentWidth ?? 100);
40+
}
41+
42+
protected onWidthChange(): void {
43+
this.componentContent.componentWidth = Number(this.selectedValue);
44+
this.inputChanged.next(Number(this.selectedValue));
45+
}
46+
}

src/messages.xlf

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,11 +1096,19 @@
10961096
<context context-type="linenumber">85</context>
10971097
</context-group>
10981098
</trans-unit>
1099-
<trans-unit id="2810375050239191789" datatype="html">
1100-
<source>Activity Width</source>
1099+
<trans-unit id="8084155234460667951" datatype="html">
1100+
<source>Activity width</source>
11011101
<context-group purpose="location">
11021102
<context context-type="sourcefile">src/app/authoring-tool/edit-component-width/edit-component-width.component.ts</context>
1103-
<context context-type="linenumber">11,15</context>
1103+
<context context-type="linenumber">12,15</context>
1104+
</context-group>
1105+
</trans-unit>
1106+
<trans-unit id="6520102811746443451" datatype="html">
1107+
<source>The activity&apos;s width determines how it appears on the screen. If two adjacent
1108+
activities are set to 50% each (or 67% and 33%, for example), they will appear side-by-side.</source>
1109+
<context-group purpose="location">
1110+
<context context-type="sourcefile">src/app/authoring-tool/edit-component-width/edit-component-width.component.ts</context>
1111+
<context context-type="linenumber">15,19</context>
11041112
</context-group>
11051113
</trans-unit>
11061114
<trans-unit id="8650499415827640724" datatype="html">

0 commit comments

Comments
 (0)