Add "Copy URL" button

Closes #41
pull/44/head
Nikita Karamov 2023-01-23 05:49:37 +01:00
parent 63e5733a72
commit 2493e6d014
2 changed files with 15 additions and 0 deletions

View File

@ -73,6 +73,10 @@
vertical-align: bottom; vertical-align: bottom;
} }
.shareon > .copy-url:before {
background-image: url("data:image/svg+xml,%3Csvg fill='%23fff' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8.465 11.293c1.133-1.133 3.109-1.133 4.242 0l.707.707 1.414-1.414-.707-.707c-.943-.944-2.199-1.465-3.535-1.465s-2.592.521-3.535 1.465L4.929 12a5.008 5.008 0 0 0 0 7.071 4.983 4.983 0 0 0 3.535 1.462A4.982 4.982 0 0 0 12 19.071l.707-.707-1.414-1.414-.707.707a3.007 3.007 0 0 1-4.243 0 3.005 3.005 0 0 1 0-4.243l2.122-2.121z'/%3E%3Cpath d='m12 4.929-.707.707 1.414 1.414.707-.707a3.007 3.007 0 0 1 4.243 0 3.005 3.005 0 0 1 0 4.243l-2.122 2.121c-1.133 1.133-3.109 1.133-4.242 0L10.586 12l-1.414 1.414.707.707c.943.944 2.199 1.465 3.535 1.465s2.592-.521 3.535-1.465L19.071 12a5.008 5.008 0 0 0 0-7.071 5.006 5.006 0 0 0-7.071 0z'/%3E%3C/svg%3E");
}
.shareon > .facebook { .shareon > .facebook {
background-color: #1877f2; background-color: #1877f2;
} }

View File

@ -50,6 +50,17 @@ const init = () => {
for (let k = 0; k < classListLength; k += 1) { for (let k = 0; k < classListLength; k += 1) {
const cls = child.classList.item(k); const cls = child.classList.item(k);
// if it's "Copy URL"
if (cls === "copy-url") {
child.addEventListener("click", () => {
const url =
child.dataset.url ||
container.dataset.url ||
window.location.href;
navigator.clipboard.writeText(url);
});
}
// if it's one of the networks // if it's one of the networks
if (Object.prototype.hasOwnProperty.call(urlBuilderMap, cls)) { if (Object.prototype.hasOwnProperty.call(urlBuilderMap, cls)) {
const preset = { const preset = {