Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix tooltips for Xeokit IFC viewer toolbar buttons. (#8649)

Wieland Lindenthalf31b62db3e7e
diff --git a/frontend/src/app/modules/bim/ifc_models/pages/viewer/styles/tooltips.sass b/frontend/src/app/modules/bim/ifc_models/pages/viewer/styles/tooltips.sass
index e23395dadd0..c793c401a69 100644
--- a/frontend/src/app/modules/bim/ifc_models/pages/viewer/styles/tooltips.sass
+++ b/frontend/src/app/modules/bim/ifc_models/pages/viewer/styles/tooltips.sass
@@ -1,16 +1,22 @@
+// Reusing the global tooltips selectively. The toolbar buttons already have :before CSS rules applied, such as the
+// actual icons in the buttons. So we need to be careful not to overwrite them. Thus we pick (@extend) only the styles
+// from the global tooltips that we want to use. And we accept that our tooltip speech bubbles do not have triangle
+// tips.
@import "~global_styles/content/tooltips"
.xeokit-toolbar [data-tippy-content]
- @extend .tooltip--bottom
+ +tooltip--colorize
+
&:after
- position: absolute
- visibility: hidden
- z-index: 99999
- box-sizing: content-box
- transform: translate3d(0, 0, 0)
+ @extend %tooltip--reset-styles
+ @extend %tooltip--after
content: attr(data-tippy-content)
- opacity: 1
+ // Here in the Xeokit viewer the toolbar alligns with the right border of the viewer's canvas. We need to make sure
+ // that the tooltips of the last button don't get cut off on the right
left: 0
- &:hover:after
- visibility: visible
+ &:hover, &:focus
+ &::before, &::after
+ @extend %tooltip--show
+
+ @extend [data-tooltip].tooltip--bottom
\ No newline at end of file
diff --git a/frontend/src/global_styles/content/_tooltips.lsg b/frontend/src/global_styles/content/_tooltips.lsg
index 1b6957f17f3..cec42e70581 100644
--- a/frontend/src/global_styles/content/_tooltips.lsg
+++ b/frontend/src/global_styles/content/_tooltips.lsg
@@ -4,7 +4,13 @@ Adds tooltips to arbitrary elements.
## Simple Tooltips
-These can contain simple texts but are not suitable for HTML within the Tooltip.
+These can contain simple texts.
+
+Attention:
+
+* They are not suitable for HTML within the Tooltip.
+* Also, if the are already :before or :after CSS rules for
+the decorated element, things will break as these rules will get overwritten.
### Right
diff --git a/frontend/src/global_styles/content/_tooltips.sass b/frontend/src/global_styles/content/_tooltips.sass
index 7a00547241a..8ea0f6b672c 100644
--- a/frontend/src/global_styles/content/_tooltips.sass
+++ b/frontend/src/global_styles/content/_tooltips.sass
@@ -72,6 +72,33 @@ $advanced-tooltip--border: 1px solid #a7cbe1
background-color: $tooltip--background-color
color: var(--tooltip--font-color)
+%tooltip--reset-styles
+ position: absolute
+ visibility: hidden
+ opacity: 0
+ z-index: 99999
+ box-sizing: content-box
+ transform: translate3d(0, 0, 0)
+
+%tooltip--before
+ content: ''
+ border: $tooltip--arrow-size solid transparent
+
+%tooltip--after
+ height: $tooltip--height
+ padding: $tooltip--height/2 $tooltip--height/2 0 $tooltip--height/2
+ font-size: 13px
+ line-height: $tooltip--height/2
+ white-space: nowrap
+ content: attr(data-tooltip)
+ border: $tooltip--border
+
+%tooltip--show
+ opacity: 1
+ visibility: visible
+
+// Note: Only use this attribute to add tooltips on elements that don't apply :before and :after CSS rules. Otherwise,
+// those get overwritten.
[data-tooltip]
position: relative
display: inline-block
@@ -81,31 +108,18 @@ $advanced-tooltip--border: 1px solid #a7cbe1
+tooltip--colorize
&:before, &:after
- position: absolute
- visibility: hidden
- opacity: 0
- z-index: 99999
- box-sizing: content-box
- transform: translate3d(0, 0, 0)
+ @extend %tooltip--reset-styles
&:before
- content: ''
- border: $tooltip--arrow-size solid transparent
+ @extend %tooltip--before
&:after
- height: $tooltip--height
- padding: $tooltip--height/2 $tooltip--height/2 0 $tooltip--height/2
- font-size: 13px
- line-height: $tooltip--height/2
- white-space: nowrap
- content: attr(data-tooltip)
- border: $tooltip--border
+ @extend %tooltip--after
&:hover, &:focus
background-color: transparent
&::before, &::after
- opacity: 1
- visibility: visible
+ @extend %tooltip--show
&.-multiline
&:after