Skip to content

Commit

Permalink
feat(node-authoring): Show divider animation on add component button …
Browse files Browse the repository at this point in the history
…hover
  • Loading branch information
breity committed Dec 20, 2024
1 parent d535cfd commit c8b372d
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/app/teacher/authoring-tool.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import { NodeAuthoringParentComponent } from '../../assets/wise5/authoringTool/n
import { AddLessonChooseTemplateComponent } from '../../assets/wise5/authoringTool/addLesson/add-lesson-choose-template/add-lesson-choose-template.component';
import { EditNodeTitleComponent } from '../../assets/wise5/authoringTool/node/edit-node-title/edit-node-title.component';
import { EditProjectLanguageSettingComponent } from '../../assets/wise5/authoringTool/project-info/edit-project-language-setting/edit-project-language-setting.component';
import { AddComponentButtonComponent } from '../../assets/wise5/authoringTool/node/add-component-button/add-component-button.component';
import { CopyComponentButtonComponent } from '../../assets/wise5/authoringTool/node/copy-component-button/copy-component-button.component';
import { ProjectAuthoringLessonComponent } from '../../assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component';
import { ProjectAuthoringStepComponent } from '../../assets/wise5/authoringTool/project-authoring-step/project-authoring-step.component';
Expand All @@ -59,6 +58,7 @@ import { CreateBranchComponent } from '../../assets/wise5/authoringTool/create-b
import { EditBranchComponent } from '../../assets/wise5/authoringTool/edit-branch/edit-branch.component';
import { ComponentTypeButtonComponent } from '../../assets/wise5/authoringTool/components/component-type-button/component-type-button.component';
import { MatExpansionModule } from '@angular/material/expansion';
import { AddComponentComponent } from '../../assets/wise5/authoringTool/node/add-component/add-component.component';

@NgModule({
declarations: [
Expand All @@ -81,7 +81,7 @@ import { MatExpansionModule } from '@angular/material/expansion';
RubricAuthoringComponent
],
imports: [
AddComponentButtonComponent,
AddComponentComponent,
AddLessonButtonComponent,
AddLessonChooseTemplateComponent,
AddLessonConfigureComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div fxLayout="row" fxLayoutAlign="end center">
<mat-divider class="component-divider" [ngClass]="{ active: focus }" />
<add-component-button
[insertAfterComponentId]="afterComponentId"
[node]="node"
(newComponentsEvent)="newComponentsEvent.emit($event)"
(mouseover)="focus = true"
(mouseleave)="focus = false"
(focusin)="focus = true"
(focusout)="focus = false"
/>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.component-divider {
width: 100%;
position: relative;

&:after {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
border-bottom-style: solid;
content: "";
border-bottom-width: var(--mdc-filled-text-field-focus-active-indicator-height);
border-bottom-color: var(--mdc-filled-text-field-focus-active-indicator-color);
transform: scaleX(0);
transform-origin: 100%;
transition: transform 360ms cubic-bezier(0.4, 0, 0.2, 1),opacity 360ms cubic-bezier(0.4, 0, 0.2, 1);
opacity: 0;
}

&.active {
&:after {
transform: scaleX(1);
opacity: 1;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AddComponentComponent } from './add-component.component';
import { CreateComponentService } from '../../../services/createComponentService';
import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { TeacherProjectService } from '../../../services/teacherProjectService';
import { provideRouter } from '@angular/router';
import { Node } from '../../../common/Node';

describe('AddComponentComponent', () => {
let component: AddComponentComponent;
let fixture: ComponentFixture<AddComponentComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AddComponentComponent, StudentTeacherCommonServicesModule],
providers: [
CreateComponentService,
provideHttpClient(withInterceptorsFromDi()),
provideRouter([]),
TeacherProjectService
]
}).compileComponents();

fixture = TestBed.createComponent(AddComponentComponent);
component = fixture.componentInstance;
component.node = new Node();
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { AddComponentButtonComponent } from '../add-component-button/add-component-button.component';
import { MatDividerModule } from '@angular/material/divider';
import { Node } from '../../../common/Node';
import { CommonModule } from '@angular/common';
import { FlexLayoutModule } from '@angular/flex-layout';

@Component({
selector: 'add-component',
standalone: true,
imports: [AddComponentButtonComponent, CommonModule, FlexLayoutModule, MatDividerModule],
templateUrl: './add-component.component.html',
styleUrl: './add-component.component.scss'
})
export class AddComponentComponent {
@Input() afterComponentId: string;
@Input() node: Node;
@Output() newComponentsEvent: EventEmitter<any> = new EventEmitter<any>();
protected focus: boolean;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
<ng-template #addComponentButton let-afterComponentId="insertAfterComponentId">
<div fxLayout="row" fxLayoutAlign="end center">
<mat-divider fxFlex></mat-divider>
<add-component-button
class="add-component"
[insertAfterComponentId]="afterComponentId"
[node]="node"
(newComponentsEvent)="highlightComponents($event)"
/>
</div>
</ng-template>

<div
class="node-authoring-header"
fxLayout="row wrap"
Expand All @@ -34,11 +22,7 @@
</div>
@if (components.length === 0 && !isGroupNode) {
<p i18n>This step does not have any components.</p>
<add-component-button
class="add-component"
[node]="node"
(newComponentsEvent)="highlightComponents($event)"
/>
<add-component [node]="node" (newComponentsEvent)="highlightComponents($event)" />
}
<div
cdkDropList
Expand All @@ -48,10 +32,9 @@
cdkScrollable
fxLayout="column"
>
<ng-container
[ngTemplateOutlet]="addComponentButton"
[ngTemplateOutletContext]="{ insertAfterComponentId: null }"
/>
@if (components.length > 0) {
<add-component [node]="node" (newComponentsEvent)="highlightComponents($event)" />
}
@for (component of components; track component.id; let i = $index; let last = $last) {
<div cdkDrag [cdkDragDisabled]="components.length < 2">
<div fxLayout="row">
Expand Down Expand Up @@ -138,9 +121,10 @@
>
</mat-card>
</div>
<ng-container
[ngTemplateOutlet]="addComponentButton"
[ngTemplateOutletContext]="{ insertAfterComponentId: component.id }"
<add-component
[node]="node"
[afterComponentId]="component.id"
(newComponentsEvent)="highlightComponents($event)"
/>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ component-authoring {
border: dotted 3px #999;
min-height: 40px;
min-width: 360px;
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}

.mat-icon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { ActivatedRoute, Router, convertToParamMap } from '@angular/router';
import { of } from 'rxjs';
import { TeacherNodeService } from '../../../services/teacherNodeService';
import { EditNodeTitleComponent } from '../edit-node-title/edit-node-title.component';
import { AddComponentButtonComponent } from '../add-component-button/add-component-button.component';
import { CopyComponentButtonComponent } from '../copy-component-button/copy-component-button.component';
import { ProjectLocale } from '../../../../../app/domain/projectLocale';
import { TeacherProjectTranslationService } from '../../../services/teacherProjectTranslationService';
Expand All @@ -33,6 +32,7 @@ import { CreateComponentService } from '../../../services/createComponentService
import { VLEProjectService } from '../../../vle/vleProjectService';
import { NotebookService } from '../../../services/notebookService';
import { MatDividerModule } from '@angular/material/divider';
import { AddComponentComponent } from '../add-component/add-component.component';

let component: NodeAuthoringComponent;
let component1: any;
Expand All @@ -51,7 +51,7 @@ describe('NodeAuthoringComponent', () => {
await TestBed.configureTestingModule({
declarations: [NodeAuthoringComponent],
imports: [
AddComponentButtonComponent,
AddComponentComponent,
BrowserAnimationsModule,
ComponentAuthoringModule,
ComponentTypeServiceModule,
Expand Down
12 changes: 6 additions & 6 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html</context>
<context context-type="linenumber">71</context>
<context context-type="linenumber">54</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/components/common/feedbackRule/edit-feedback-rules/edit-feedback-rules.component.html</context>
Expand Down Expand Up @@ -1220,7 +1220,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html</context>
<context context-type="linenumber">114</context>
<context context-type="linenumber">97</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/components/common/feedbackRule/edit-feedback-rules/edit-feedback-rules.component.html</context>
Expand All @@ -1239,7 +1239,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html</context>
<context context-type="linenumber">126</context>
<context context-type="linenumber">109</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/components/common/feedbackRule/edit-feedback-rules/edit-feedback-rules.component.html</context>
Expand Down Expand Up @@ -10252,7 +10252,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html</context>
<context context-type="linenumber">27</context>
<context context-type="linenumber">15</context>
</context-group>
</trans-unit>
<trans-unit id="d9921e33c659c824a3c39062f76cb572394ff373" datatype="html">
Expand Down Expand Up @@ -12029,14 +12029,14 @@ The branches will be removed but the steps will remain in the unit.</source>
<source>This step does not have any components.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html</context>
<context context-type="linenumber">36</context>
<context context-type="linenumber">24</context>
</context-group>
</trans-unit>
<trans-unit id="46c242cc262ba3a868dfd6bd37f555c1ada6877c" datatype="html">
<source>Delete Component</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html</context>
<context context-type="linenumber">91</context>
<context context-type="linenumber">74</context>
</context-group>
</trans-unit>
<trans-unit id="3122407218727181695" datatype="html">
Expand Down

0 comments on commit c8b372d

Please sign in to comment.