diff --git a/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html b/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html index 47f37ea2c55..0366965dc59 100644 --- a/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html +++ b/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html @@ -4,41 +4,53 @@
} - @if (avatars.length === 1) { -
Your {{ label }}:
- } @else { + @if (selectedAvatar == null) {
Choose Your {{ label }}:
+
+ @for (avatar of avatars; track avatar.id) { + + } +
+ } @else { +
Your {{ label }}:
+ + {{ selectedAvatar.name }} +
+ {{ selectedAvatar.name }} +
+
} - - @for (avatar of avatars; track avatar.id) { - - {{ avatar.name }} -
- {{ avatar.name }} -
-
- } -
- - - + @if (selectedAvatar != null) { + + @if (avatars.length > 1) { + + + } + + + } diff --git a/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.scss b/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.scss index 1adac3c5791..7ada7dd1fca 100644 --- a/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.scss +++ b/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.scss @@ -11,36 +11,45 @@ } } -/* TODO(mdc-migration): The following rule targets internal classes of button that may no longer apply for the MDC version. */ -.mat-button-toggle-group { - border: 0 none; - margin-top: 16px; +.avatar-button{ + height: auto; + text-transform: none; } -/* TODO(mdc-migration): The following rule targets internal classes of button that may no longer apply for the MDC version. */ -/* TODO(mdc-migration): The following rule targets internal classes of button that may no longer apply for the MDC version. */ -.mat-button-toggle-group-appearance-standard { - /* TODO(mdc-migration): The following rule targets internal classes of button that may no longer apply for the MDC version. */ - .mat-button-toggle, .mat-button-toggle + .mat-button-toggle { - border-left: 0 none; - border-radius: variables.$card-border-radius; - margin: 4px; - } +.avatar-image { + width: 88px; + height: auto; + border-radius: 50%; + padding: 8px 0; } -/* TODO(mdc-migration): The following rule targets internal classes of button that may no longer apply for the MDC version. */ -.mat-button-toggle-disabled.mat-button-toggle-checked { - background-color: transparent; +.name { + line-height: 1; + padding-bottom: 8px; } -.avatar-image { - width: 88px; + +.selected-avatar-image { + width: 168px; height: auto; border-radius: 50%; padding: 8px 0; } -.name { +.selected-avatar-name { line-height: 1; padding-bottom: 8px; } + +@keyframes pulse { + 0%, 100% { + transform: scale(1); + } + 50% { + transform: scale(1.06); + } +} + +.pulse { + animation: pulse 2s ease-in-out infinite; +} diff --git a/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.spec.ts b/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.spec.ts index a69385a3b4c..a7e63bae3c9 100644 --- a/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.spec.ts +++ b/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.spec.ts @@ -33,13 +33,45 @@ describe('ComputerAvatarSelectorComponent', () => { ngOnInit(); selectAvatar(); + onlyOneAvatar(); }); +function onlyOneAvatar() { + describe('only one avatar', () => { + beforeEach(() => { + component.computerAvatarSettings.ids = ['robot']; + component.ngOnInit(); + fixture.detectChanges(); + }); + + it('should automatically select the avatar and only show the continue button', () => { + expect(fixture.debugElement.queryAll(By.css('.avatar-button')).length).toEqual(0); + expect(fixture.debugElement.query(By.css('.selected-avatar-image'))).toBeTruthy(); + expect( + fixture.debugElement.query(By.css('.selected-avatar-name')).nativeElement.textContent.trim() + ).toEqual('Robot'); + + const backButton = fixture.debugElement + .queryAll(By.css('button')) + .find((btn) => btn.nativeElement.textContent.includes('Back')); + + expect(getContinueButton()).toBeTruthy(); + expect(backButton).toBeUndefined(); + }); + + it('clicking continue should emit selected avatar', () => { + const spy = spyOn(component.chooseAvatarEvent, 'emit'); + getContinueButton().nativeElement.click(); + fixture.detectChanges(); + expect(spy).toHaveBeenCalledWith(avatars[0]); + }); + }); +} + function ngOnInit() { describe('ngOnInit()', () => { - it('should show avatars and the continue button should be disabled', () => { - expect(fixture.debugElement.queryAll(By.css('mat-button-toggle')).length).toEqual(2); - expect(getContinueButton().nativeElement.disabled).toBeTrue(); + it('should show avatars', () => { + expect(fixture.debugElement.queryAll(By.css('.avatar-button')).length).toEqual(2); }); }); } @@ -47,7 +79,7 @@ function ngOnInit() { function selectAvatar() { describe('select avatar', () => { beforeEach(() => { - fixture.debugElement.queryAll(By.css('mat-button-toggle'))[0].nativeElement.click(); + fixture.debugElement.queryAll(By.css('.avatar-button'))[0].nativeElement.click(); fixture.detectChanges(); }); it('should enable the continue button', () => { @@ -72,5 +104,5 @@ function clickContinueButton_shouldEmitAvatar() { function getContinueButton() { return fixture.debugElement .queryAll(By.css('button')) - .find((buttonDebugEl) => buttonDebugEl.nativeElement.textContent.includes('Continue')); + .find((buttonDebugEl) => buttonDebugEl.nativeElement.textContent.includes('Chat with')); } diff --git a/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.ts b/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.ts index a981d63392c..c300dc8c907 100644 --- a/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.ts +++ b/src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.ts @@ -2,14 +2,13 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; -import { MatButtonToggleModule } from '@angular/material/button-toggle'; import { MatDividerModule } from '@angular/material/divider'; import { ComputerAvatar } from '../../common/computer-avatar/ComputerAvatar'; import { ComputerAvatarService } from '../../services/computerAvatarService'; import { ComputerAvatarSettings } from '../../common/computer-avatar/ComputerAvatarSettings'; @Component({ - imports: [FormsModule, MatButtonModule, MatButtonToggleModule, MatCardModule, MatDividerModule], + imports: [FormsModule, MatButtonModule, MatCardModule, MatDividerModule], selector: 'computer-avatar-selector', styleUrl: './computer-avatar-selector.component.scss', templateUrl: './computer-avatar-selector.component.html' diff --git a/src/messages.xlf b/src/messages.xlf index ac72758374c..53fc1c833a4 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -1551,6 +1551,10 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.src/assets/wise5/classroomMonitor/dataExport/export-student-work/export-student-work.component.html 7,10 + + src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html + 42,46 + Back @@ -23258,32 +23262,25 @@ If this problem continues, let your teacher know and move on to the next activit 70,73 - - Your : - - src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html - 8,9 - - Choose Your : src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html - 10,12 + 8,9 - - Selected avatar + + Your : src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html - 16,19 + 26,27 - - Continue + + Chat with src/assets/wise5/vle/computer-avatar-selector/computer-avatar-selector.component.html - 41,45 + 52,54