Skip to content

Commit

Permalink
feat(igxExpansionPanel): body is component now, collapse&expand anima…
Browse files Browse the repository at this point in the history
…tion, #307
  • Loading branch information
ViktorSlavov committed Sep 5, 2018
1 parent 35edd69 commit d9a7385
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<ng-content select="igx-expansion-panel-header"></ng-content>
<div #collapseBody [attr.aria-labelledby] = "labelledby" [attr.role] = "'region'"
[attr.aria-label] = "label || id + '-region'" style="border: 1px solid rgb(58, 53, 56); background-color:gainsboro">
<ng-content *ngIf="!collapsed" select="igx-expansion-panel-body"></ng-content>
<ng-content select="igx-expansion-panel-body"></ng-content>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ export class IgxExpansionPanelComponent {
}

collapse (evt?: Event) {
this.collapsed = true;
this.playCloseAnimation(
() => {
this.onCollapsed.emit({event: evt});
this.collapsed = true; }
}
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Directive, HostBinding, Input } from '@angular/core';
import { Directive, HostBinding, Input, Host, Component } from '@angular/core';
import { IgxExpansionPanelComponent } from './expansion-panel.component';
import { trigger, state, style, transition, animate } from '@angular/animations';

let NEXT_ID = 0;

Expand Down Expand Up @@ -30,11 +32,26 @@ export class IgxExpansionPanelDescriptionDirective {
public cssClass = `igx-expansion-panel__header-description`;
}

@Directive({
@Component({
// tslint:disable-next-line:directive-selector
selector: 'igx-expansion-panel-body'
selector: 'igx-expansion-panel-body',
template: '<div *ngIf="!panel.collapsed" [@enterAnimation]><ng-content></ng-content></div>',
animations: [
trigger('enterAnimation', [
transition(':enter', [
style({height: '0px', opacity: 0}),
animate('300ms', style({height: '*', opacity: 1}))
]),
transition(':leave', [
style({height: '*', opacity: 1}),
animate('300ms', style({height: '0px', opacity: 0}))
])
])
]
})
export class IgxExpansionPanelBodyDirective {
export class IgxExpansionPanelBodyComponent {
constructor(@Host() public panel: IgxExpansionPanelComponent) {
}
@HostBinding('class.igx-expansion-panel__header-body')
public cssClass = `igx-expansion-panel__header-body`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IgxIconModule } from '../icon/index';
import { IgxExpansionPanelComponent } from './expansion-panel.component';
import { IgxExpansionPanelHeaderComponent } from './expansion-panel-header.component';
import { IgxExpansionPanelDescriptionDirective, IgxExpansionPanelTitleDirective,
IgxExpansionPanelBodyDirective,
IgxExpansionPanelBodyComponent,
IgxExpansionPanelHeaderDirective,
IgxExpansionPanelIconDirective } from './expansion-panel.directives';

Expand All @@ -18,7 +18,7 @@ import { IgxExpansionPanelDescriptionDirective, IgxExpansionPanelTitleDirective,
IgxExpansionPanelHeaderDirective,
IgxExpansionPanelDescriptionDirective,
IgxExpansionPanelTitleDirective,
IgxExpansionPanelBodyDirective,
IgxExpansionPanelBodyComponent,
IgxExpansionPanelIconDirective
],
entryComponents: [
Expand All @@ -28,7 +28,7 @@ import { IgxExpansionPanelDescriptionDirective, IgxExpansionPanelTitleDirective,
IgxExpansionPanelHeaderComponent,
IgxExpansionPanelDescriptionDirective,
IgxExpansionPanelTitleDirective,
IgxExpansionPanelBodyDirective,
IgxExpansionPanelBodyComponent,
IgxExpansionPanelIconDirective,
IgxExpansionPanelHeaderDirective
],
Expand Down
4 changes: 4 additions & 0 deletions src/app/expansion-panel/expansion-panel-sample.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
display: none;
visibility: hidden;
}

.igx-expansion-panel__header-body {
display: block;
}
4 changes: 2 additions & 2 deletions src/app/expansion-panel/expansion-panel-sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ExpansionPanelSampleComponent implements OnInit {
params: Object.assign(scaleInVerTop.options.params, {
startOpacity: 0.5,
fromScale: 0,
duration: '250ms'
duration: '300ms'
})
}
}),
Expand All @@ -30,7 +30,7 @@ export class ExpansionPanelSampleComponent implements OnInit {
endOpacity: 0.5,
fromScale: 1,
toScale: 0,
duration: '350ms'
duration: '300ms'
})
}
})
Expand Down

0 comments on commit d9a7385

Please sign in to comment.