Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Added activeIndex class to repeater #51

Merged
merged 15 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions e2e/repeater.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ import {
} from '@skyux-sdk/e2e';

describe('Repeater', () => {
it('should match the baseline sort screenshot', (done) => {
SkyHostBrowser.get('visual/sort');
Blackbaud-SteveBrush marked this conversation as resolved.
Show resolved Hide resolved
SkyHostBrowser.setWindowBreakpoint('lg');
SkyHostBrowser.scrollTo('#screenshot-sort-full');
expect('#screenshot-sort-full').toMatchBaselineScreenshot(done, {
screenshotName: 'sort'
});
});

it('should match previous repeater screenshot', (done) => {
SkyHostBrowser.get('visual/repeater');
SkyHostBrowser.setWindowBreakpoint('lg');
Expand All @@ -22,6 +13,15 @@ describe('Repeater', () => {
});
});

it('should match previous repeater screenshot when an item is active', (done) => {
SkyHostBrowser.get('visual/repeater');
SkyHostBrowser.setWindowBreakpoint('lg');
SkyHostBrowser.scrollTo('#screenshot-repeater-with-active-item');
expect('#screenshot-repeater-with-active-item').toMatchBaselineScreenshot(done, {
screenshotName: 'repeater-with-active-item'
});
});

it('should match previous repeater screenshot when all are collapsed', (done) => {
SkyHostBrowser.get('visual/repeater');
SkyHostBrowser.setWindowBreakpoint('lg');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<sky-repeater [expandMode]="expandMode">
<sky-repeater-item
[isActive]="isActive"
(collapse)="onCollapse()"
(expand)="onExpand()"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ import {
templateUrl: './repeater.component.fixture.html'
})
export class RepeaterTestComponent {
@ViewChild(SkyRepeaterComponent)
public repeater: SkyRepeaterComponent;

public showContextMenu: boolean;

public removeLastItem: boolean;

public expandMode = 'single';

public isActive = false;

public lastItemExpanded: boolean;

public lastItemSelected = false;

public removeLastItem: boolean;

public showContextMenu: boolean;

@ViewChild(SkyRepeaterComponent)
public repeater: SkyRepeaterComponent;

public onCollapse(): void {}

public onExpand(): void {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div
class="sky-repeater-item sky-padding-even-default"
[ngClass]="{
'sky-repeater-item-active': isActive,
'sky-repeater-item-collapsible': isCollapsible,
'sky-repeater-item-selected': isSelected
}"
Expand Down
7 changes: 7 additions & 0 deletions src/app/public/modules/repeater/repeater-item.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
padding-top:10px;
}
}

&.sky-repeater-item-active {
background-color: #eeeeef;
color: #212327;
padding-left: 6px;
border-left: 4px solid #00b4f1;
}
Copy link
Contributor Author

@Blackbaud-AlexKingman Blackbaud-AlexKingman Jul 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

.sky-repeater-item-left {
Expand Down
3 changes: 3 additions & 0 deletions src/app/public/modules/repeater/repeater-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class SkyRepeaterItemComponent implements OnDestroy {
this._isSelected = value;
}

@Input()
public isActive: boolean = false;

@Input()
public showInlineForm: boolean = false;

Expand Down
25 changes: 25 additions & 0 deletions src/app/public/modules/repeater/repeater.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,31 @@ describe('Repeater item component', () => {
}));
});

it('should add and remove active css class when isActive value changes', fakeAsync(() => {
let fixture = TestBed.createComponent(RepeaterTestComponent);
let cmp: RepeaterTestComponent = fixture.componentInstance;
let el = fixture.nativeElement;
fixture.detectChanges();
tick();

let activeRepeaterItem = el.querySelectorAll('.sky-repeater-item-active');
expect(activeRepeaterItem.length).toBe(0);

cmp.isActive = true;
fixture.detectChanges();
tick();

activeRepeaterItem = el.querySelectorAll('.sky-repeater-item-active');
expect(activeRepeaterItem.length).toBe(1);

cmp.isActive = false;
fixture.detectChanges();
tick();

activeRepeaterItem = el.querySelectorAll('.sky-repeater-item-active');
expect(activeRepeaterItem.length).toBe(0);
}));

describe('with inline-form', () => {
let fixture: ComponentFixture<RepeaterInlineFormFixtureComponent>;
let el: HTMLElement;
Expand Down
23 changes: 23 additions & 0 deletions src/app/visual/repeater/repeater-visual.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ <h3>Basic repeater</h3>
</sky-repeater>
</div>

<div
class="app-screenshot sky-margin-stacked-default"
id="screenshot-repeater-with-active-item"
>
<h3>Repeater with isActive enabled on click</h3>
<sky-repeater>
<sky-repeater-item
[isActive]="activeId === 1"
(click)="activeId = 1"
>
<sky-repeater-item-title>Title 1</sky-repeater-item-title>
<sky-repeater-item-content>Content 1</sky-repeater-item-content>
</sky-repeater-item>
<sky-repeater-item
[isActive]="activeId === 2"
(click)="activeId = 2"
>
<sky-repeater-item-title>Title 2</sky-repeater-item-title>
<sky-repeater-item-content>Content 2</sky-repeater-item-content>
</sky-repeater-item>
</sky-repeater>
</div>

<div
class="app-screenshot sky-margin-stacked-default"
id="screenshot-repeater-collapsed"
Expand Down
6 changes: 4 additions & 2 deletions src/app/visual/repeater/repeater-visual.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
})
export class RepeaterVisualComponent {

public activeId = 1;

public activeInlineFormId: number;

public customConfig: SkyInlineFormConfig = {
buttonLayout: SkyInlineFormButtonLayout.Custom,
buttons: [
Expand Down Expand Up @@ -46,8 +50,6 @@ export class RepeaterVisualComponent {
}
];

public activeInlineFormId: number;

public onCollapse(): void {
console.log('Collapsed.');
}
Expand Down