-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
import { getLangFromUrl, useTranslations } from "@i18n/utils"; | ||
import { Icon } from "astro-icon/components"; | ||
const lang = getLangFromUrl(Astro.url); | ||
const t = useTranslations(lang); | ||
const alertMessage = t("Lien copié"); | ||
--- | ||
|
||
<div class="z-50 mt-4 lg:mt-0 lg:text-right"> | ||
<a | ||
target="_blank" | ||
class="copyLink btn btn-responsive btn-outline relative inline-flex items-center justify-end gap-4 font-normal no-underline" | ||
> | ||
<Icon name="tabler:share" size={20} /> | ||
<span>{t("Permalien")}</span> | ||
</a> | ||
</div> | ||
<script define:vars={{ alertMessage: alertMessage }}> | ||
const buttons = document.querySelectorAll("a.copyLink"); | ||
buttons.forEach((button) => { | ||
button.addEventListener("click", (e) => { | ||
copyLink(e); | ||
}); | ||
}); | ||
const copyLink = (e) => { | ||
navigator.clipboard.writeText(window.location.href); | ||
e.target.insertAdjacentHTML( | ||
"afterend", | ||
"<div class='linktooltips-container font-bold'>" + | ||
alertMessage + | ||
"</div>", | ||
); | ||
setTimeout(() => { | ||
document | ||
.querySelectorAll(".linktooltips-container") | ||
.forEach((el) => el.remove()); | ||
}, 3000); | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters