Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(collapse): custom display styles #2893

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<div (collapsed)="collapsed($event)"
(expanded)="expanded($event)"
[collapse]="isCollapsed"
class="card card-block card-header">
styleDisplayOnShow="inline-block"
styleDisplayOnHide="none"
class="card card-header">
<div class="well well-lg">Some content</div>
</div>
14 changes: 12 additions & 2 deletions src/collapse/collapse.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export class CollapseDirective {
// animation state
@HostBinding('class.collapsing') isCollapsing = false;

/** This attribute indicates value of CSS display property when shown */
@Input()
public styleDisplayOnShow: string = 'block';

/** This attribute indicates value of CSS display property when hidden */
@Input()
public styleDisplayOnHide: string = 'none';

/** A flag indicating visibility of content (shown or hidden) */
@Input()
set collapse(value: boolean) {
Expand All @@ -49,6 +57,7 @@ export class CollapseDirective {
constructor(private _el: ElementRef, private _renderer: Renderer2) {
}


/** allows to manually toggle content visibility */
toggle(): void {
if (this.isExpanded) {
Expand All @@ -58,6 +67,7 @@ export class CollapseDirective {
}
}


/** allows to manually hide content */
hide(): void {
this.isCollapse = false;
Expand All @@ -69,7 +79,7 @@ export class CollapseDirective {
this.isCollapse = true;
this.isCollapsing = false;

this.display = 'none';
this.display = this.styleDisplayOnHide;
this.collapsed.emit(this);
}

Expand All @@ -81,7 +91,7 @@ export class CollapseDirective {
this.isExpanded = true;
this.isCollapsed = false;

this.display = 'block';
this.display = this.styleDisplayOnShow;
// this.height = 'auto';
this.isCollapse = true;
this.isCollapsing = false;
Expand Down