-
Notifications
You must be signed in to change notification settings - Fork 14
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
146f1e8
commit ee2fb62
Showing
2 changed files
with
36 additions
and
8 deletions.
There are no files selected for viewing
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
40 changes: 34 additions & 6 deletions
40
projects/ngx-tippy-demo/src/app/pages/grouped-tooltips/grouped-tooltips.component.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 |
---|---|---|
@@ -1,21 +1,49 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { AfterViewInit, ChangeDetectorRef, Component } from '@angular/core'; | ||
import { Schemes } from '@interfaces'; | ||
import { DestroyService, SchemeService } from '@services'; | ||
import { NgxTippyProps } from 'ngx-tippy-wrapper'; | ||
import { takeUntil } from 'rxjs'; | ||
import { SNIPPETS } from './snippets'; | ||
|
||
@Component({ | ||
selector: 'app-grouped-tooltips', | ||
templateUrl: './grouped-tooltips.component.html', | ||
styleUrls: ['./grouped-tooltips.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
providers: [DestroyService], | ||
}) | ||
export class GroupedTooltipsComponent implements OnInit { | ||
export class GroupedTooltipsComponent implements AfterViewInit { | ||
public readonly snippets = SNIPPETS; | ||
public readonly groupedProps: NgxTippyProps = { | ||
public isShowDemo: boolean = false; | ||
public groupedProps: NgxTippyProps = { | ||
arrow: false, | ||
placement: 'top', | ||
}; | ||
|
||
constructor() {} | ||
constructor( | ||
private readonly schemeService: SchemeService, | ||
private readonly destroy$: DestroyService, | ||
private readonly cdr: ChangeDetectorRef | ||
) {} | ||
|
||
ngOnInit(): void {} | ||
ngAfterViewInit() { | ||
this.listenForSchemeChange(); | ||
} | ||
|
||
private listenForSchemeChange() { | ||
this.schemeService.scheme$.pipe(takeUntil(this.destroy$)).subscribe(scheme => { | ||
const theme = scheme === Schemes.Dark ? 'light' : 'dark'; | ||
this.groupedProps = { | ||
...this.groupedProps, | ||
theme, | ||
}; | ||
|
||
this.isShowDemo = false; | ||
this.cdr.markForCheck(); | ||
|
||
setTimeout(() => { | ||
this.isShowDemo = true; | ||
this.cdr.markForCheck(); | ||
}, 0); | ||
}); | ||
} | ||
} |