refactor: 💄 Share button to top bar

This commit is contained in:
ThatOneCalculator 2022-04-04 12:14:25 -07:00
parent 648b6aac4e
commit f001286f5b
3 changed files with 11 additions and 11 deletions

View File

@ -46,13 +46,13 @@ html(lang='en')
//- - }
button#new-button.btn(aria-label='New paste')
button#copy-button.btn(aria-label='Copy')
button#share-button.btn(aria-label='Share')
a(href='https://github.com/zer0bin-dev/zer0bin' aria-label='GitHub repo')
button#github-button.btn(aria-label='GitHub')
span.viewcounter.noselect#viewcounter-label(style='visibility: hidden; display: none') Views: 
span.viewcounter.noselect#viewcounter-count(style='visibility: hidden; display: none')
.bottom-button-wrapper
button#share-button.btn(aria-label='Share' style='visibility: hidden')
button#hide-button.btn(aria-label='Hide')
.scrollbar-container

View File

@ -93,6 +93,14 @@ tippy("#copy-button", {
allowHTML: true,
})
tippy("#share-button", {
content: `Share paste<br><span class='keybind'>Copies URL</span>`,
placement: "top",
animation: "scale",
theme: "rosepine",
allowHTML: true,
})
tippy("#github-button", {
content: `GitHub<br><span class='keybind'>
${renderIconDefinitionToSVGElement(StarOutlined, {
@ -116,14 +124,6 @@ tippy("#hide-button", {
allowHTML: true,
})
tippy("#share-button", {
content: "Share paste",
placement: "top",
animation: "scale",
theme: "rosepine",
allowHTML: true,
})
const observer = new MutationObserver(callback)
function callback() {

View File

@ -117,6 +117,7 @@ function newPaste() {
enable(saveButton)
disable(newButton)
disable(copyButton)
disable(shareButton)
enable(singleViewButton)
editor.value = ""
@ -128,7 +129,6 @@ function newPaste() {
hide(codeViewPre)
hide(viewCounterLabel)
hide(viewCounter)
hide(shareButton)
viewCounterLabel.style.display = "none"
viewCounter.style.display = "none"
}
@ -167,7 +167,7 @@ function viewPaste(content: string, views: string, singleView: boolean) {
addMessage("This is a single-view paste!")
}
show(shareButton)
enable(shareButton)
shareButton.addEventListener("click", function () {
const url = window.location.toString()
if (navigator.canShare) {