fix: 🐛 Tooltips respect popstatea

This commit is contained in:
ThatOneCalculator 2022-03-22 12:18:52 -07:00
parent 4184901345
commit 918068f0be
1 changed files with 53 additions and 39 deletions

View File

@ -36,47 +36,61 @@ githubButton.innerHTML += renderIconDefinitionToSVGElement(GithubOutlined, {
extraSVGAttrs: extraSVGAttrs,
})
let theme = "rosepine-extended"
function makeTooltips() {
let theme = "rosepine-extended"
if (window.location.pathname == "/") {
theme = "rosepine"
if (window.location.pathname == "/") {
theme = "rosepine"
}
tippy("#save-button", {
content: "Save paste<br><span class='keybind'>Ctrl + S</span>",
placement: "bottom",
animation: "scale",
theme: theme,
allowHTML: true,
})
tippy("#new-button", {
content: "New paste<br><span class='keybind'>Ctrl + N</span>",
placement: "bottom",
animation: "scale",
theme: theme,
allowHTML: true,
})
tippy("#copy-button", {
content: "Duplicate paste<br><span class='keybind'>Ctrl + D</span>",
placement: "bottom",
animation: "scale",
theme: theme,
allowHTML: true,
})
tippy("#github-button", {
content: `GitHub<br><span class='keybind'>
${renderIconDefinitionToSVGElement(StarOutlined, {
extraSVGAttrs: extraSVGAttrs,
})} ${renderIconDefinitionToSVGElement(ForkOutlined, {
extraSVGAttrs: extraSVGAttrs,
})} ${renderIconDefinitionToSVGElement(HeartOutlined, {
extraSVGAttrs: extraSVGAttrs,
})}</span>`,
placement: "bottom",
animation: "scale",
theme: theme,
allowHTML: true,
})
}
tippy("#save-button", {
content: "Save paste<br><span class='keybind'>Ctrl + S</span>",
placement: "bottom",
animation: "scale",
theme: theme,
allowHTML: true,
window.addEventListener("popstate", () => {
makeTooltips()
})
tippy("#new-button", {
content: "New paste<br><span class='keybind'>Ctrl + N</span>",
placement: "bottom",
animation: "scale",
theme: theme,
allowHTML: true,
})
tippy("#copy-button", {
content: "Duplicate paste<br><span class='keybind'>Ctrl + D</span>",
placement: "bottom",
animation: "scale",
theme: theme,
allowHTML: true,
})
tippy("#github-button", {
content: `GitHub<br><span class='keybind'>
${renderIconDefinitionToSVGElement(StarOutlined, {
extraSVGAttrs: extraSVGAttrs,
})} ${renderIconDefinitionToSVGElement(ForkOutlined, {
extraSVGAttrs: extraSVGAttrs,
})} ${renderIconDefinitionToSVGElement(HeartOutlined, {
extraSVGAttrs: extraSVGAttrs,
})}</span>`,
placement: "bottom",
animation: "scale",
theme: theme,
allowHTML: true,
})
document.addEventListener(
"DOMContentLoaded",
() => {
makeTooltips()
},
false
)