This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcc62cb
commit ad0cf96
Showing
10 changed files
with
384 additions
and
83 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
projects/core/src/lib/popover/popover-element.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FivPopover } from './popover.component'; | ||
import { Directive, ElementRef, Input, AfterViewInit } from '@angular/core'; | ||
import { tap } from 'rxjs/operators'; | ||
|
||
@Directive({ | ||
selector: '[fivPopover]', | ||
exportAs: 'fivPopover' | ||
}) | ||
export class PopoverElementDirective implements AfterViewInit { | ||
_show: boolean; | ||
@Input() fivPopover: FivPopover; | ||
|
||
@Input('fivPopover.show') set show(visible: boolean) { | ||
this._show = visible; | ||
|
||
if (this.show) { | ||
this.fivPopover.openElementRef(this.el); | ||
} else if (this.fivPopover.overlay && this.fivPopover.overlay.open) { | ||
this.fivPopover.close(); | ||
} | ||
} | ||
get show() { | ||
return this._show; | ||
} | ||
|
||
constructor(private el: ElementRef) {} | ||
|
||
open() { | ||
this.show = true; | ||
} | ||
hide() { | ||
this.show = false; | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
this.fivPopover.overlay.afterInit | ||
.pipe( | ||
tap(() => { | ||
this.show = this._show; | ||
}) | ||
) | ||
.subscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
<fiv-overlay> | ||
<div *ngIf="backdrop" class="popover-backdrop" (click)="close()"> | ||
<div *ngIf="backdrop" class="fiv-popover-backdrop" (click)="close()"> | ||
</div> | ||
<div class="popover-container" [style.left]="left + 'px'" [style.top]="top + 'px'" [style.height]="height + 'px'" | ||
[style.width]="width + 'px'"> | ||
<div class="popover-container" [style]="containerStyles"> | ||
<ng-content> | ||
</ng-content> | ||
<svg *ngIf="arrow && !overlaysTarget" class="arrow" [style]="svgStyles"> | ||
<polygon [attr.points]="triangle" /> | ||
</svg> | ||
</div> | ||
|
||
</fiv-overlay> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.