Skip to content

Commit b7ea1db

Browse files
committed
Add close icon to tooltip
1 parent 7fff3d5 commit b7ea1db

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/js/popup.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,12 @@ function createBreakageNote(domain, i18n_message_key) {
569569
// return the tooltip we want (the breakage note, not Allow)
570570
$slider_allow.tooltipster('destroy').tooltipster({
571571
autoClose: false,
572-
content: chrome.i18n.getMessage(i18n_message_key),
572+
content: $(`<div>
573+
<a href="" id="dismiss-tooltip" role="button" aria-label="i18n_report_close">
574+
<img src="../icons/close.svg" alt="">
575+
</a>
576+
<div>${chrome.i18n.getMessage(i18n_message_key)}</div>
577+
</div>`),
573578
functionReady: function (tooltip) {
574579
// close on tooltip click/tap
575580
$(tooltip.elementTooltip()).on('click', function (e) {

src/lib/i18n.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ function setTextDirection() {
5959
['#fittslaw', '.overlay-close'].forEach((selector) => {
6060
toggle_css_value(selector, "float", "right", "left");
6161
});
62+
// Workaround for tooltipster dynamically inserted after localization
63+
let css = document.createElement("style");
64+
css.textContent = `
65+
#dismiss-tooltip {
66+
float: left;
67+
right: unset;
68+
left: -5px;
69+
}`;
70+
document.body.appendChild(css);
6271

6372
// options page
6473
} else if (document.location.pathname == "/skin/options.html") {

src/skin/popup.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,24 @@ a.overlay-close:hover {
533533
cursor: pointer;
534534
}
535535

536+
#dismiss-tooltip {
537+
float: right;
538+
margin: 5px;
539+
position: relative;
540+
top: -5px;
541+
right: -5px;
542+
}
543+
544+
#dismiss-tooltip img {
545+
height: 18px;
546+
filter: invert(100%) sepia(0%) saturate(7489%) hue-rotate(126deg) brightness(106%) contrast(100%);
547+
}
548+
549+
#dismiss-tooltip:hover img, #dismiss-tooltip:focus img {
550+
/* Calculated with https://codepen.io/sosuke/pen/Pjoqqp to match #fff */
551+
filter: invert(93%) sepia(8%) saturate(30%) hue-rotate(203deg) brightness(99%) contrast(94%);
552+
}
553+
536554
#firstparty-protections-container, #youtube-message-container {
537555
border-bottom: 1px solid #d3d3d3;
538556
margin: 10px 0;

0 commit comments

Comments
 (0)