Skip to content

Instantly share code, notes, and snippets.

@karan-kang
Last active August 4, 2017 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karan-kang/5f0facd761b2bd6f760bda1ca9ba83c8 to your computer and use it in GitHub Desktop.
Save karan-kang/5f0facd761b2bd6f760bda1ca9ba83c8 to your computer and use it in GitHub Desktop.
import { Component, ElementRef, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { AppPanelService } from './appPanel.service';
/**
* This component allows the user to toggle the app panel size between full screen and normal
* views.
*/
@Component({
selector: 'expand-panel',
template: `
<a class="panel-expand" (click)="expand()">
<i class="fa" [ngClass]="{ 'fa-expand': !expanded, 'fa-compress': expanded }"></i>
</a>
`,
encapsulation: ViewEncapsulation.None,
viewProviders: [
AppPanelService
]
})
export class ExpandPanelComponent implements OnInit, OnDestroy {
private panel: Element;
public expanded = false;
constructor(private element: ElementRef, private appPanelService: AppPanelService) {
}
/**
* Initialize this component
*/
public ngOnInit() {
this.panel = this.appPanelService.getPanelElement(this.element.nativeElement);
}
/**
* Destroy this component
*/
public ngOnDestroy() {
this.panel = undefined;
}
public expand() {
this.expanded = this.appPanelService.expandPanel(this.panel);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment