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

🚀 - Customizable Tooltips #1258

Closed
WynieCronje opened this issue Jan 26, 2022 · 6 comments
Closed

🚀 - Customizable Tooltips #1258

WynieCronje opened this issue Jan 26, 2022 · 6 comments
Assignees
Labels
P2 This issue has medium priority

Comments

@WynieCronje
Copy link
Contributor

Which @taiga-ui/* package(s) are relevant/releated to the feature request?

core

Description

Allow css classes to be added to individual tooltips.

This will allow color changes as well as changing the styles of tooltips as needed.

@splincode
Copy link
Member

@waterplea if we could use a directive, would that be useful?

<div class="my-custom-class" tuiTooltip>
   Please don't touch this
<div>

<div class="my-custom-class" [tuiTooltip]="template"><div>
<ng-template #template>Please don't touch this</ng-template>

@waterplea waterplea changed the title 🚀 - Custom classes on Tooltips 🚀 - Customizable Tooltips Jan 26, 2022
@WynieCronje
Copy link
Contributor Author

WynieCronje commented Jan 26, 2022

I have 2 solutions in my mind. One is to simply add a property cssClass as an input. And this will enable styling overrides on global level.

Another is to move the styling away from the tui-hint-box component. And into global styles. but to configure we will need to have css classes being added to tui-hint-box anyway.

This approach will allow for overriding default styles. then a cssClass property can switch between the desired class rules.

View initial developement here: WynieCronje@34a8634

WynieCronje pushed a commit to WynieCronje/taiga-ui that referenced this issue Jan 26, 2022
@loxy
Copy link
Contributor

loxy commented Jan 26, 2022

We have some similar problems, but not regarding the tooltip. This pattern (restriction) is also used in other components.

Another option would be to add some CSS variables to the styles like:

:host {
   --tui-component-color: var(--tui-text-03);
   --tui-component-bg: transparent;

    .transition(color);
    position: relative;
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    vertical-align: middle;
    font-size: 0;
    line-height: 0;
    cursor: pointer;
    color: var(--tui-component-color);
    background: var(--tui-component-bg);
    ...
}

Then you can apply something like:

.my-namespace tui-tooltip {
  --tui-component-color: var(--my-color-var);
  --tui-component-bg: pink;
}

tui-tooltip.special {
  --tui-component-color: var(--my-other-color-var);
  --tui-component-bg: yellow;
}

@waterplea waterplea added P2 This issue has medium priority and removed state: need triage labels Feb 1, 2022
@waterplea
Copy link
Collaborator

So I've been stewing on this for some time and I don't like the idea of passing on the CSS class. Can't really tell why, just a gut feeling. I think I would move tui-hint-box into token for tooltip component and abstract all positioning away into service or something like that. This would allow for all sorts of customisation from complete layout control to Angular animations for appearance/disappearance and it would be a bit in the same style as alerts and dialogs. I would architect it next week once I finish things I'm working on at the moment.

P.S. CSS variables won't help here because of portal pattern where DI tree and DOM tree don't match. I really need to make myself write an article on this subject, I've been meaning to for a while now 😀

@waterplea
Copy link
Collaborator

So I have refactored tooltips for 3.0 to be very flexible. However I realize that sometimes one just needs to change a little bit of CSS on the bubble (even we need it with error mode for red bubbles). So I've changed tuiHintMode into tuiHintAppearance similar to what we have in tuiWrapper component — it is attached to the bubble as data-appearance attribute. This would allow you to customize it any way you like or even change it across entire project with DI token for default values. You can have a look at this PR while you wait for stable 3.0 release :)
#2256

@waterplea
Copy link
Collaborator

Fixed in 3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 This issue has medium priority
Development

No branches or pull requests

4 participants