Skip to content

Commit

Permalink
feat: add @output() method to expose current tooltip status as boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
timhecker committed Sep 22, 2020
1 parent da61453 commit 409ad7f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ Now you can use it:
</button>
```

#### Handle current status as boolean

```html
<button helipopper="Helpful Message" (helipopperShowing)="handleStatus($event)">
Click Me
</button>
```

and on .ts

```ts
handleStatus($event: boolean): void {
console.log('show tooltip', $event);
}
```

#### Text Overflow:

```html
Expand Down Expand Up @@ -237,6 +253,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Expand Down
4 changes: 4 additions & 0 deletions projects/ngneat/helipopper/src/lib/helipopper.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export class HelipopperDirective implements OnDestroy {
}

@Output() helipopperClose = new Subject();
@Output() helipopperShowing = new Subject<boolean>();
// @Output() helipopperShowing = new EventEmitter<boolean>();

private _content: Content;
private _destroy = new Subject();
Expand Down Expand Up @@ -217,11 +219,13 @@ export class HelipopperDirective implements OnDestroy {
onShow: instance => {
this.zone.run(() => this.instance.setContent(this.resolveContent()));
this.helipopperAllowClose && this.isPopper && this.addCloseButton(instance as InstanceWithClose);
this.helipopperShowing.next(true);
},
onHidden: instance => {
this.helipopperAllowClose && this.isPopper && this.removeCloseButton(instance as InstanceWithClose);
this.destroyView();
this.helipopperClose.next();
this.helipopperShowing.next(false);
},
...this.resolveTheme(),
...this.helipopperOptions
Expand Down
9 changes: 8 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,14 @@ <h2>Sticky</h2>

<div class="block">
<h2>Custom Component</h2>
<button [helipopper]="comp" helipopperVariation="popper" (helipopperClose)="close()">Open component</button>
<button
[helipopper]="comp"
helipopperVariation="popper"
(helipopperClose)="close()"
(helipopperShowing)="handleStatus($event)"
>
Open component
</button>
</div>

<div class="block">
Expand Down
4 changes: 4 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ export class AppComponent implements AfterViewInit {
this.popperWithComp = this.service.open(this.inputNameComp, this.comp);
}
}

handleStatus($event: boolean): void {
console.log('show tooltip', $event);
}
}

0 comments on commit 409ad7f

Please sign in to comment.