discourse/app/assets/stylesheets/common/float-kit/d-tooltip.scss
Joffrey JAFFEUX 043b4a4187
FIX: replaces data-tooltip usage by <DTooltip /> (#24062)
As much as possible I would like us to avoid having to go the with a global event listener on click/mouseover. For now I have removed all cases of `data-tooltip`, if we clearly identify a use case of a global event listener we might reconsider this.

The following changes are also included:
- by default tooltips won't attempt to focus first focusable element anymore
- tooltip will now use `cursor: pointer` by default
- a new service has been introduced: `InternalTooltip` which is responsible to track the current instance displayed by a `<DTooltip />`. Portal elements when replaced are not properly cleaned and I couldn't figure out a way to have a proper hook to ensure the previous `DTooltipInstance` is properly set as not expanded; this problem was very visible when using a tooltip as interactive and hovering another tooltip, which would replace the interactive tooltip as not closed.
2023-10-23 21:09:02 +02:00

93 lines
1.4 KiB
SCSS

@keyframes d-tooltip-opening {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.fk-d-tooltip {
background-color: var(--secondary);
border-radius: var(--d-border-radius);
border: 1px solid var(--primary-low);
box-shadow: var(--shadow-menu-panel);
z-index: z("max");
width: max-content;
position: absolute;
top: 0;
left: 0;
display: flex !important;
padding: 0;
&__trigger {
display: inline-flex;
cursor: pointer;
.touch & {
@include unselectable;
}
}
&.-animated {
animation: d-tooltip-opening 0.15s ease-in;
&[data-placement^="bottom"] {
transform-origin: top center;
}
&[data-placement^="top"] {
transform-origin: bottom center;
}
&[data-placement^="right"] {
transform-origin: center left;
}
&[data-placement^="left"] {
transform-origin: center right;
}
}
&__inner-content {
display: flex;
overflow: hidden;
overflow-wrap: break-word;
padding: 0.5rem;
align-items: center;
}
.arrow {
z-index: z("max");
position: absolute;
}
&[data-placement^="top"] {
.arrow {
bottom: -9px;
rotate: 180deg;
}
}
&[data-placement^="bottom"] {
.arrow {
top: -9px;
}
}
&[data-placement^="right"] {
.arrow {
rotate: -90deg;
left: -9px;
}
}
&[data-placement^="left"] {
.arrow {
rotate: 90deg;
right: -9px;
}
}
}