Skip to content

Commit

Permalink
Add close icon to tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
lenacohen committed Nov 21, 2024
1 parent 51991ff commit 5ce9620
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,12 @@ function createBreakageNote(domain, i18n_message_key) {
// return the tooltip we want (the breakage note, not Allow)
$slider_allow.tooltipster('destroy').tooltipster({
autoClose: false,
content: chrome.i18n.getMessage(i18n_message_key),
content: $(`<div>
<a href="" id="dismiss-tooltip" role="button" aria-label="i18n_report_close">
<img src="../icons/close.svg" alt="">
</a>
<div>${chrome.i18n.getMessage(i18n_message_key)}</div>
</div>`),
functionReady: function (tooltip) {
// close on tooltip click/tap
$(tooltip.elementTooltip()).on('click', function (e) {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ function setTextDirection() {
['#fittslaw', '.overlay-close'].forEach((selector) => {
toggle_css_value(selector, "float", "right", "left");
});
// Workaround for tooltipster dynamically inserted after localization
let css = document.createElement("style");
css.textContent = `
#dismiss-tooltip {
float: left;
right: unset;
left: -5px;
}`;
document.body.appendChild(css);

// options page
} else if (document.location.pathname == "/skin/options.html") {
Expand Down
18 changes: 18 additions & 0 deletions src/skin/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,24 @@ a.overlay-close:hover {
cursor: pointer;
}

#dismiss-tooltip {
float: right;
margin: 5px;
position: relative;
top: -5px;
right: -5px;
}

#dismiss-tooltip img {
height: 18px;
filter: invert(100%) sepia(0%) saturate(7489%) hue-rotate(126deg) brightness(106%) contrast(100%);
}

#dismiss-tooltip:hover img, #dismiss-tooltip:focus img {
/* Calculated with https://codepen.io/sosuke/pen/Pjoqqp to match #fff */
filter: invert(93%) sepia(8%) saturate(30%) hue-rotate(203deg) brightness(99%) contrast(94%);
}

#firstparty-protections-container, #youtube-message-container {
border-bottom: 1px solid #d3d3d3;
margin: 10px 0;
Expand Down

0 comments on commit 5ce9620

Please sign in to comment.