Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kit): Tooltip add DI options #9571

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions projects/core/directives/hint/hint-options.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const TUI_HINT_DEFAULT_OPTIONS: TuiHintOptions = {
showDelay: 500,
hideDelay: 200,
appearance: '',
/** TODO @deprecated use {@link TUI_TOOLTIP_OPTIONS} instead **/
icon: '@tui.circle-help',
};

Expand Down
2 changes: 0 additions & 2 deletions projects/core/directives/hint/hint.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
:host {
position: absolute;
max-inline-size: 18rem;
min-block-size: var(--tui-height-m);
padding: 0.75rem 1rem;
background: var(--tui-background-accent-1);
border-radius: var(--tui-radius-l);
Expand All @@ -12,7 +11,6 @@
font: var(--tui-font-text-s);
white-space: pre-line;
overflow-wrap: break-word;
line-height: 1.25rem;
transform-origin: var(--left) var(--top);

&::before {
Expand Down
1 change: 1 addition & 0 deletions projects/kit/directives/tooltip/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './tooltip.directive';
export * from './tooltip.options';
13 changes: 7 additions & 6 deletions projects/kit/directives/tooltip/tooltip.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {TUI_IS_MOBILE} from '@taiga-ui/cdk/tokens';
import {tuiWithStyles} from '@taiga-ui/cdk/utils/miscellaneous';
import {TuiTextfieldComponent} from '@taiga-ui/core/components/textfield';
import {
TUI_APPEARANCE_OPTIONS,
tuiAppearanceOptionsProvider,
tuiAppearanceState,
TuiWithAppearance,
} from '@taiga-ui/core/directives/appearance';
Expand All @@ -25,6 +25,8 @@ import {
import {TUI_ICON_START} from '@taiga-ui/core/tokens';
import {map} from 'rxjs';

import {TUI_TOOLTIP_OPTIONS} from './tooltip.options';

@Component({
standalone: true,
template: '',
Expand All @@ -41,13 +43,11 @@ class TuiTooltipStyles {}
standalone: true,
selector: 'tui-icon[tuiTooltip]',
providers: [
{
provide: TUI_APPEARANCE_OPTIONS,
useValue: {appearance: 'icon'},
},
tuiAppearanceOptionsProvider(TUI_TOOLTIP_OPTIONS),
{
provide: TUI_ICON_START,
useFactory: () => inject(TUI_HINT_OPTIONS).icon,
useFactory: () =>
inject(TUI_TOOLTIP_OPTIONS).icon || inject(TUI_HINT_OPTIONS).icon,
},
],
hostDirectives: [
Expand All @@ -63,6 +63,7 @@ class TuiTooltipStyles {}
],
host: {
tuiTooltip: '',
'(click.prevent)': '0',
'(mousedown)': 'onClick($event)',
},
})
Expand Down
6 changes: 6 additions & 0 deletions projects/kit/directives/tooltip/tooltip.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {tuiCreateOptions} from '@taiga-ui/cdk/utils/di';

export const [TUI_TOOLTIP_OPTIONS, tuiTooltipOptionsProvider] = tuiCreateOptions({
icon: '',
appearance: 'icon',
});
18 changes: 17 additions & 1 deletion projects/kit/directives/tooltip/tooltip.style.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
@import '@taiga-ui/core/styles/taiga-ui-local.less';

[tuiTooltip] {
border-width: 0.25rem;
border-width: 0.125rem;
border-radius: 100%;
cursor: pointer;
pointer-events: auto;
background-clip: content-box !important;

[tuiBlock],
[tuiCell][data-size='s'],
[tuiLabel][data-orientation='horizontal'] {
border-width: 0.25rem;
}

&::after {
.center-all();

inline-size: 1rem;
block-size: 1rem;
}
}

@media (hover: hover) {
Expand Down
1 change: 1 addition & 0 deletions projects/legacy/components/tooltip/tooltip.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {TuiHintHover, TuiHintOptionsDirective} from '@taiga-ui/core/directives/h
inputs: ['content', 'direction', 'appearance', 'showDelay', 'hideDelay'],
host: {
'[attr.data-appearance]': 'computedAppearance',
'(click.prevent)': '0',
'(mousedown)': 'stopOnMobile($event)',
},
})
Expand Down
Loading