Skip to content

Commit

Permalink
chore: use new tooltip in legacy (#9591)
Browse files Browse the repository at this point in the history
Co-authored-by: taiga-family-bot <[email protected]>
  • Loading branch information
waterplea and taiga-family-bot authored Oct 23, 2024
1 parent 37dd61d commit d178edf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 85 deletions.
5 changes: 4 additions & 1 deletion projects/kit/directives/tooltip/tooltip.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
}

@media (hover: hover) {
tui-textfield:hover [tuiTooltip][data-appearance='icon']::after {
tui-textfield:hover [tuiTooltip][data-appearance='icon']::after,
tui-textarea:hover [tuiTooltip][data-appearance='icon']::after,
tui-primitive-textfield:hover [tuiTooltip][data-appearance='icon']::after,
tui-input-tag:hover [tuiTooltip][data-appearance='icon']::after {
color: var(--tui-text-secondary);
}
}
35 changes: 2 additions & 33 deletions projects/legacy/components/tooltip/tooltip.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import {
ChangeDetectionStrategy,
Component,
inject,
Input,
ViewChild,
} from '@angular/core';
import {TUI_IS_MOBILE} from '@taiga-ui/cdk/tokens';
import {TuiHintHover, TuiHintOptionsDirective} from '@taiga-ui/core/directives/hint';
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {TuiHintOptionsDirective} from '@taiga-ui/core/directives/hint';

/**
* @deprecated: drop in v5.0 use {@link TuiTooltip}
Expand All @@ -16,37 +9,13 @@ import {TuiHintHover, TuiHintOptionsDirective} from '@taiga-ui/core/directives/h
standalone: false,
selector: 'tui-tooltip',
templateUrl: './tooltip.template.html',
styleUrls: ['./tooltip.style.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
inputs: ['content', 'direction', 'appearance', 'showDelay', 'hideDelay'],
host: {
'[attr.data-appearance]': 'computedAppearance',
'(click.prevent)': '0',
'(mousedown)': 'stopOnMobile($event)',
},
})
export class TuiTooltipComponent<C = any> extends TuiHintOptionsDirective {
private readonly isMobile = inject(TUI_IS_MOBILE);

@ViewChild(TuiHintHover)
protected readonly driver$?: TuiHintHover;

@Input()
public describeId = '';

@Input()
public context?: C;

protected get computedAppearance(): string {
return this.appearance || '';
}

protected stopOnMobile(event: MouseEvent): void {
if (this.isMobile) {
event.preventDefault();
event.stopPropagation();
} else {
this.driver$?.toggle();
}
}
}
7 changes: 2 additions & 5 deletions projects/legacy/components/tooltip/tooltip.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {TuiIcon} from '@taiga-ui/core/components/icon';
import {TuiHint} from '@taiga-ui/core/directives/hint';
import {TuiWrapperModule} from '@taiga-ui/legacy/directives';
import {PolymorpheusOutlet} from '@taiga-ui/polymorpheus';
import {TuiTooltip} from '@taiga-ui/kit/directives/tooltip';

import {TuiTooltipComponent} from './tooltip.component';

Expand All @@ -12,7 +9,7 @@ import {TuiTooltipComponent} from './tooltip.component';
* https://taiga-ui.dev/components/tooltip
*/
@NgModule({
imports: [CommonModule, TuiIcon, PolymorpheusOutlet, ...TuiHint, TuiWrapperModule],
imports: [TuiIcon, TuiTooltip],
declarations: [TuiTooltipComponent],
exports: [TuiTooltipComponent],
})
Expand Down
30 changes: 0 additions & 30 deletions projects/legacy/components/tooltip/tooltip.style.less

This file was deleted.

21 changes: 5 additions & 16 deletions projects/legacy/components/tooltip/tooltip.template.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
<span
#driver="tuiHintHover"
appearance="icon"
<tui-icon
automation-id="tui-tooltip__icon"
tuiWrapper
class="t-tooltip-icon"
[hover]="(driver | async) || null"
[tuiHint]="content"
[tuiHintAppearance]="computedAppearance"
[tuiHintAppearance]="appearance || ''"
[tuiHintContext]="context"
[tuiHintDescribe]="describeId"
[tuiHintDirection]="direction"
[tuiHintHideDelay]="hideDelay"
[tuiHintShowDelay]="showDelay"
>
<tui-icon
*polymorpheusOutlet="icon as src"
class="t-icon"
[icon]="src"
/>
</span>
[tuiTooltip]="content"
[tuiTooltipDescribe]="describeId"
/>

0 comments on commit d178edf

Please sign in to comment.