Skip to content

Commit 57ec6ef

Browse files
style(Component Selection): Group by function (#2302)
Co-authored-by: Jonathan Lim-Breitbart <breity10@gmail.com>
1 parent 88ecf2e commit 57ec6ef

21 files changed

Lines changed: 223 additions & 122 deletions

src/app/authoring-tool/add-component/choose-new-component/choose-new-component.component.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<h2 mat-dialog-title i18n>Add New Activity</h2>
2-
<mat-dialog-content>
2+
<mat-dialog-content class="@container">
33
<p class="flex flex-wrap justify-start items-center gap-2">
44
<span i18n>Select the activity you want to add or</span>
55
<button mat-raised-button color="primary" (click)="goToImportComponent()" i18n>
66
import from another unit
77
</button>
88
</p>
9-
<div class="flex flex-wrap justify-start items-center">
10-
@for (componentType of componentTypes; track componentType.type) {
11-
<component-type-button
12-
[componentType]="componentType.type"
13-
(componentSelectedEvent)="selectComponent(componentType.type)"
9+
<div class="@lg:columns-2 @2xl:columns-3 @4xl:columns-4 gap-2">
10+
@for (componentGroup of componentGroups; track componentGroup.name) {
11+
<component-type-group
12+
class="mb-2 block break-inside-avoid-column"
13+
[componentGroup]="componentGroup"
14+
(componentSelectedEvent)="selectComponent($event.type)"
1415
/>
1516
}
1617
</div>

src/app/authoring-tool/add-component/choose-new-component/choose-new-component.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import { Component } from '@angular/core';
22
import { MatButtonModule } from '@angular/material/button';
33
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
4-
import { ComponentTypeButtonComponent } from '../../../../assets/wise5/authoringTool/components/component-type-button/component-type-button.component';
4+
import { ComponentTypeGroupComponent } from '../../component-type-group/component-type-group.component';
55
import { ComponentTypeService } from '../../../../assets/wise5/services/componentTypeService';
66

77
@Component({
8-
imports: [ComponentTypeButtonComponent, MatButtonModule, MatDialogModule],
8+
imports: [ComponentTypeGroupComponent, MatButtonModule, MatDialogModule],
99
styles: ['component-type-button { width: 250px; padding: 4px; }'],
1010
templateUrl: 'choose-new-component.component.html'
1111
})
1212
export class ChooseNewComponent {
13-
protected componentTypes: any[];
13+
protected componentGroups: any[];
1414

1515
constructor(
1616
private componentTypeService: ComponentTypeService,
1717
private dialogRef: MatDialogRef<ChooseNewComponent>
1818
) {}
1919

2020
ngOnInit(): void {
21-
this.componentTypes = this.componentTypeService.getComponentTypes();
21+
this.componentGroups = this.componentTypeService.getComponentGroups();
2222
}
2323

2424
protected goToImportComponent(): void {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<mat-card appearance="filled">
2+
<mat-card-header>
3+
<mat-card-title class="pb-2">{{ componentGroup.name }}</mat-card-title>
4+
</mat-card-header>
5+
<mat-card-content>
6+
<div class="@container">
7+
<div class="grid @sm:grid-cols-2 gap-2">
8+
@for (componentType of componentGroup.types; track componentType.type) {
9+
<component-type-button
10+
[componentType]="componentType.type"
11+
(componentSelectedEvent)="componentSelectedEvent.emit(componentType)"
12+
/>
13+
}
14+
</div>
15+
</div>
16+
</mat-card-content>
17+
</mat-card>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Component, EventEmitter, Input, Output } from '@angular/core';
2+
import { ComponentTypeButtonComponent } from '../../../assets/wise5/authoringTool/components/component-type-button/component-type-button.component';
3+
import { MatCardModule } from '@angular/material/card';
4+
5+
@Component({
6+
imports: [ComponentTypeButtonComponent, MatCardModule],
7+
selector: 'component-type-group',
8+
styles: `
9+
@import 'tailwindcss';
10+
:host {
11+
--mat-card-filled-container-color: var(--color-gray-100);
12+
--mat-card-title-text-size: var(--mat-sys-title-medium-font-size);
13+
--mat-card-title-text-line-height: var(--mat-sys-title-medium-line-height);
14+
}
15+
.mat-mdc-card-header {
16+
padding: 12px 12px 0;
17+
}
18+
.mat-mdc-card-content {
19+
padding-left: 12px;
20+
padding-right: 12px;
21+
22+
&:last-child {
23+
padding-bottom: 12px;
24+
}
25+
}
26+
`,
27+
templateUrl: './component-type-group.component.html'
28+
})
29+
export class ComponentTypeGroupComponent {
30+
@Input() componentGroup: any;
31+
@Output() componentSelectedEvent = new EventEmitter<any>();
32+
}

src/assets/wise5/authoringTool/addNode/add-your-own-node/add-your-own-node.component.html

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<form role="form" [formGroup]="addNodeFormGroup">
1+
<form role="form" [formGroup]="addNodeFormGroup" class="@container">
22
<mat-form-field appearance="fill" class="title-field">
33
<mat-label i18n>Step Title</mat-label>
44
<input matInput type="text" id="title" name="title" formControlName="title" required />
@@ -7,8 +7,11 @@
77
}
88
</mat-form-field>
99
<h5 i18n>Select activities to add to your new step (optional):</h5>
10-
<div class="flex flex-col md:flex-row">
11-
<div class="initial-components notice-bg-bg flex items-start md:w-1/3 lg:w-1/4">
10+
<p class="info mat-small" i18n>
11+
*Note: You can always add or remove content later by editing the step.
12+
</p>
13+
<div class="grid @lg:grid-cols-2 @2xl:grid-cols-3 gap-3">
14+
<div class="initial-components flex items-start p-3">
1215
@if (initialComponents.length == 0) {
1316
<div class="mat-small" i18n>No activities added</div>
1417
}
@@ -32,20 +35,16 @@ <h5 i18n>Select activities to add to your new step (optional):</h5>
3235
</div>
3336
}
3437
</div>
35-
<div class="flex flex-col md:w-2/3 lg:w-3/4">
36-
<div class="flex flex-wrap justify-stretch items-center">
37-
@for (componentType of componentTypes; track componentType.type) {
38-
<div class="component-type">
39-
<component-type-button
40-
[componentType]="componentType.type"
41-
(componentSelectedEvent)="addComponent(componentType)"
42-
/>
43-
</div>
38+
<div class="flex flex-col @2xl:col-span-2 @container">
39+
<div class="@2xl:columns-2 gap-2">
40+
@for (componentGroup of componentGroups; track componentGroup.name) {
41+
<component-type-group
42+
class="mb-2 block break-inside-avoid-column"
43+
[componentGroup]="componentGroup"
44+
(componentSelectedEvent)="addComponent($event)"
45+
/>
4446
}
4547
</div>
46-
<p class="info mat-small" i18n>
47-
*Note: You can always add or remove content later by editing the step.
48-
</p>
4948
</div>
5049
</div>
5150
<div class="nav-controls">

src/assets/wise5/authoringTool/addNode/add-your-own-node/add-your-own-node.component.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@use '@angular/material' as mat;
2+
@import 'tailwindcss';
23

34
$border-color: #dddddd;
45
$transform: transform 250ms cubic-bezier(0, 0, 0.2, 1);
@@ -10,8 +11,7 @@ $transform: transform 250ms cubic-bezier(0, 0, 0.2, 1);
1011
}
1112

1213
.initial-components {
13-
padding: 8px;
14-
margin: 4px;
14+
background-color: var(--color-gray-100);
1515
}
1616

1717
.component-list {

src/assets/wise5/authoringTool/addNode/add-your-own-node/add-your-own-node.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ActivatedRoute, Router, RouterModule } from '@angular/router';
1414
import { TeacherProjectService } from '../../../services/teacherProjectService';
1515
import { MatFormFieldModule } from '@angular/material/form-field';
1616
import { MatIconModule } from '@angular/material/icon';
17-
import { ComponentTypeButtonComponent } from '../../components/component-type-button/component-type-button.component';
17+
import { ComponentTypeGroupComponent } from '../../../../../app/authoring-tool/component-type-group/component-type-group.component';
1818
import { MatDividerModule } from '@angular/material/divider';
1919
import { MatButtonModule } from '@angular/material/button';
2020
import { MatProgressBarModule } from '@angular/material/progress-bar';
@@ -25,7 +25,7 @@ import { ensureDefaultIcon } from '../../../common/Node';
2525

2626
@Component({
2727
imports: [
28-
ComponentTypeButtonComponent,
28+
ComponentTypeGroupComponent,
2929
DragDropModule,
3030
FormsModule,
3131
MatButtonModule,
@@ -44,7 +44,7 @@ export class AddYourOwnNodeComponent {
4444
protected addNodeFormGroup: FormGroup = this.fb.group({
4545
title: new FormControl($localize`New Step`, [Validators.required])
4646
});
47-
protected componentTypes: any[];
47+
protected componentGroups: any[];
4848
protected initialComponents: string[] = [];
4949
protected submitting: boolean;
5050
protected target: AddStepTarget;
@@ -58,7 +58,7 @@ export class AddYourOwnNodeComponent {
5858
private route: ActivatedRoute,
5959
private router: Router
6060
) {
61-
this.componentTypes = this.componentTypeService.getComponentTypes();
61+
this.componentGroups = this.componentTypeService.getComponentGroups();
6262
}
6363

6464
ngOnInit(): void {

src/assets/wise5/authoringTool/components/component-type-button/component-type-button.component.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ mat-card {
66
width: 100%;
77
justify-content: flex-start;
88
text-transform: capitalize;
9+
text-align: start;
10+
padding: 0 8px;
911
}

src/assets/wise5/components/dialogGuidance/DialogGuidanceInfo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { ComponentInfo } from '../ComponentInfo';
22

33
export class DialogGuidanceInfo extends ComponentInfo {
44
protected description: string = $localize`Students chat with a computer avatar about a specific topic.`;
5-
protected label: string = $localize`Dialog Guidance`;
5+
protected label: string = $localize`Dialog`;
66
protected previewExamples: any[] = [
77
{
8-
label: $localize`Dialog Guidance`,
8+
label: $localize`Dialog`,
99
content: {
1010
id: 'abcde12345',
1111
type: 'DialogGuidance',

src/assets/wise5/components/dialogGuidance/dialogGuidanceService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class DialogGuidanceService extends ComponentService {
1010
}
1111

1212
getComponentTypeLabel(): string {
13-
return $localize`Dialog Guidance`;
13+
return $localize`Dialog`;
1414
}
1515

1616
createComponent() {

0 commit comments

Comments
 (0)