forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tippy-1-tooltip' into keyboard-shortcuts
- Loading branch information
Showing
18 changed files
with
191 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import tippy from "tippy.js" | ||
|
||
const TOOLTIP_BASE = { | ||
arrow: false, | ||
theme: "tooltip", | ||
animation: "tooltip", | ||
appendTo: document.body | ||
} | ||
|
||
let tooltipInstances = [] | ||
const globalPlugin = { | ||
fn() { | ||
return { | ||
onCreate(instance) { | ||
tooltipInstances = tooltipInstances.concat(instance); | ||
}, | ||
onDestroy(instance) { | ||
tooltipInstances = tooltipInstances.filter(i => i !== instance); | ||
} | ||
} | ||
} | ||
} | ||
|
||
tippy.setDefaultProps({ | ||
plugins: [globalPlugin] | ||
}) | ||
|
||
registerTooltips() | ||
|
||
/** | ||
* Registers tooltips for the page | ||
* If called again, destroys existing tooltips and registers them again (useful for progressive rendering) | ||
* @param {HTMLElement} container - Registers the tooltips for the given container | ||
*/ | ||
function registerTooltips(container = document) { | ||
tooltipInstances.forEach(instance => { | ||
if (instance.props.container === container) { | ||
instance.destroy() | ||
} | ||
}) | ||
|
||
tippy(container.querySelectorAll("[tooltip]:not([tooltip=\"\"])"), { | ||
content: element => element.getAttribute("tooltip") | ||
.replace("<br>", "\n") | ||
.replace("<br/>", "\n") | ||
.replace("\\n", "\n"), | ||
container: container, | ||
...TOOLTIP_BASE | ||
}) | ||
|
||
tippy(container.querySelectorAll("[html-tooltip]"), { | ||
content: element => element.getAttribute("html-tooltip"), | ||
allowHTML: true, | ||
container: container, | ||
...TOOLTIP_BASE | ||
}) | ||
} | ||
|
||
/** | ||
* Displays a tooltip for three seconds on the provided element after interaction | ||
* @param {string} text - The tooltip text | ||
* @param {HTMLElement} element - The element to show the tooltip | ||
*/ | ||
function hoverNotification(text, element) { | ||
const tooltip = tippy(element, { | ||
interactive: true, | ||
trigger: "hover", | ||
offset: [0, 0], | ||
content: text, | ||
...TOOLTIP_BASE, | ||
onShow(instance) { | ||
setTimeout(() => { | ||
instance.hide() | ||
}, 3000) | ||
}, | ||
}) | ||
tooltip.show() | ||
} | ||
|
||
window.registerTooltips = registerTooltips | ||
window.hoverNotification = hoverNotification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
@import '../abstracts/theme.less'; | ||
|
||
html { | ||
position: relative; | ||
height: 100%; | ||
box-sizing: border-box; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,46 @@ | ||
.jenkins-tooltip { | ||
position: absolute; | ||
padding: 5px 10px; | ||
.tippy-box[data-theme~='tooltip'] { | ||
background: var(--tooltip-background); | ||
color: var(--tooltip-color); | ||
padding: 0.55rem 0.8rem; | ||
border-radius: 10px; | ||
background: var(--tooltip-background-color); | ||
box-shadow: var(--tooltip-shadow); | ||
color: var(--tooltip-foreground-color); | ||
font-size: 0.8rem; | ||
z-index: 1001 !important; | ||
overflow: hidden; | ||
max-width: none !important; | ||
box-shadow: var(--tooltip-box-shadow); | ||
font-weight: 500; | ||
font-size: 0.75rem; | ||
backdrop-filter: saturate(2) blur(15px); | ||
max-width: unset !important; | ||
white-space: pre-line; | ||
|
||
.tippy-content { | ||
padding: 0; | ||
} | ||
|
||
// We style tables as they have additional margin/border radius when in tooltips | ||
.jenkins-tooltip--table-wrapper { | ||
background-color: rgba(black, 0.05); | ||
margin: -0.55rem -0.8rem; | ||
border-radius: 10px; | ||
} | ||
|
||
.jenkins-table { | ||
--table-background: transparent; | ||
--table-border-radius: 8px; | ||
|
||
margin: 0; | ||
width: 450px; | ||
} | ||
} | ||
|
||
.tippy-box[data-animation='tooltip'][data-state='hidden'] { | ||
opacity: 0; | ||
transform: scale(0.995); | ||
|
||
&[data-placement^="top"] { | ||
transform-origin: bottom; | ||
transform: translateY(2px) scale(0.995); | ||
} | ||
|
||
&[data-placement^="bottom"] { | ||
transform-origin: top; | ||
transform: translateY(-2px) scale(0.995); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.