Skip to content

Commit

Permalink
Animation unit tests (blackbaud#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-SteveBrush authored Feb 7, 2018
1 parent ca847cb commit 6c184af
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 70 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</sky-colorpicker>
</div>

<div id="screenshot-colorpicker2">
<div id="screenshot-colorpicker2" style="height:520px;padding:10px;">
<sky-colorpicker #colorPickerExample2>
<input
[skyColorpickerInput]="colorPickerExample2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Colorpicker', () => {
SkyVisualTest.moveCursorOffScreen();
return SkyVisualTest.compareScreenshot({
screenshotName: 'colorpicker-opened',
selector: '.sky-colorpicker-container',
selector: '#screenshot-colorpicker2',
checkAccessibility: false
});
});
Expand Down
13 changes: 13 additions & 0 deletions src/modules/animation/slide.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { skyAnimationSlide } from './slide';

describe('Animation slide', () => {
it('should define an animation trigger', () => {
const definitions: any = skyAnimationSlide.definitions;

expect(skyAnimationSlide.name).toEqual('skyAnimationSlide');
expect(definitions[0].name).toEqual('down');
expect(definitions[1].name).toEqual('up');
expect(definitions[2].expr).toEqual('up <=> down');
expect(definitions[2].animation.timings).toEqual('150ms ease-in');
});
});
9 changes: 5 additions & 4 deletions src/modules/animation/slide.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
trigger,
animate,
AnimationEntryMetadata,
state,
style,
transition,
animate
trigger
} from '@angular/core';

export default trigger('slide', [
export const skyAnimationSlide = trigger('skyAnimationSlide', [
state('down', style({
overflow: 'hidden',
height: '*'
Expand All @@ -19,4 +20,4 @@ export default trigger('slide', [
'up <=> down',
animate('150ms ease-in')
)
]) as any;
]) as AnimationEntryMetadata;
6 changes: 3 additions & 3 deletions src/modules/repeater/repeater-item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
>

<div class="sky-repeater-item-left">
<sky-checkbox
*ngIf="selectable"
<sky-checkbox
*ngIf="selectable"
class="sky-repeater-item-checkbox"
[checked]="isSelected"
[label]="'repeater_item_checkbox_label' | skyResources"
Expand Down Expand Up @@ -37,7 +37,7 @@ <h1 class="sky-repeater-item-title" #titleEl>
</sky-chevron>
</div>
</header>
<div class="sky-repeater-item-content" [@slide]="slideDirection">
<div class="sky-repeater-item-content" [@skyAnimationSlide]="slideDirection">
<ng-content select="sky-repeater-item-content"></ng-content>
</div>
</div>
Expand Down
24 changes: 4 additions & 20 deletions src/modules/repeater/repeater-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {
animate,
Component,
Input,
trigger,
state,
style,
transition
Input
} from '@angular/core';

import { skyAnimationSlide } from '../animation/slide';

import { SkyRepeaterService } from './repeater.service';
import { SkyLogService } from '../log/log.service';
import { SkyCheckboxChange } from '../checkbox/checkbox.component';
Expand All @@ -16,20 +13,7 @@ import { SkyCheckboxChange } from '../checkbox/checkbox.component';
selector: 'sky-repeater-item',
styleUrls: ['./repeater-item.component.scss'],
templateUrl: './repeater-item.component.html',
animations: [trigger('slide', [
state('down', style({
overflow: 'hidden',
height: '*'
})),
state('up', style({
overflow: 'hidden',
height: 0
})),
transition(
'up <=> down',
animate('150ms ease-in')
)
])]
animations: [skyAnimationSlide]
})
export class SkyRepeaterItemComponent {
public get isExpanded(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/tiles/tile/tile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1 class="sky-tile-title">
</div>
</div>
</header>
<div class="sky-tile-content" [@slide]="isCollapsed ? 'up' : 'down'">
<div class="sky-tile-content" [@skyAnimationSlide]="isCollapsed ? 'up' : 'down'">
<ng-content select="sky-tile-content"></ng-content>
</div>
</section>
44 changes: 4 additions & 40 deletions src/modules/tiles/tile/tile.component.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
import {
AfterViewInit,
animate,
Component,
ElementRef,
EventEmitter,
Input,
Optional,
Output,
trigger,
state,
style,
transition
Output
} from '@angular/core';

import { skyAnimationSlide } from '../../animation/slide';
import { SkyTileDashboardService } from '../tile-dashboard/tile-dashboard.service';

@Component({
selector: 'sky-tile',
styleUrls: ['./tile.component.scss'],
templateUrl: './tile.component.html',
animations: [trigger('slide', [
state('down', style({
overflow: 'hidden',
height: '*'
})),
state('up', style({
overflow: 'hidden',
height: 0
})),
transition(
'up <=> down',
animate('150ms ease-in')
)
])]
animations: [skyAnimationSlide]
})
export class SkyTileComponent implements AfterViewInit {
export class SkyTileComponent {
public isInDashboardColumn = false;

@Output()
Expand All @@ -59,15 +41,10 @@ export class SkyTileComponent implements AfterViewInit {
this._isCollapsed = value;
}

if (this.viewInitialized) {
this.slideForCollapsed(true);
}

this.isCollapsedChange.emit(value);
}

private _isCollapsed = false;
private viewInitialized = false;

constructor(
public elementRef: ElementRef,
Expand All @@ -91,17 +68,4 @@ export class SkyTileComponent implements AfterViewInit {
public chevronDirectionChange(direction: string) {
this.isCollapsed = direction === 'down';
}

public ngAfterViewInit() {
this.viewInitialized = true;

if (this.isCollapsed) {
this.slideForCollapsed(false);
}
}

private slideForCollapsed(animate: boolean) {
// let direction = this.isCollapsed ? 'up' : 'down';
// this.slideService.slide(this.elementRef, '.sky-tile-content', direction, animate);
}
}

0 comments on commit 6c184af

Please sign in to comment.