Skip to content

Commit

Permalink
Fix theme for grouped tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
farengeyt451 committed Sep 21, 2023
1 parent 146f1e8 commit ee2fb62
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="tui-text_h3">Grouped tooltips</h1>
[languages]="s.languages"
></t-demo-code>

<t-demo>
<t-demo *ngIf="isShowDemo">
<ngx-tippy-group [groupedProps]="groupedProps">
<button
*ngFor="let btn of [0, 1, 2, 3, 4]"
Expand Down Expand Up @@ -60,7 +60,7 @@ <h1 class="tui-text_h3">Grouped tooltips</h1>
[languages]="s.languages"
></t-demo-code>

<t-demo>
<t-demo *ngIf="isShowDemo">
<ngx-tippy-group [groupedProps]="groupedProps">
<button
data-tippy-grouped
Expand Down
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);
});
}
}

0 comments on commit ee2fb62

Please sign in to comment.