mirror of
https://codeberg.org/vlw/victorwesterlund.com.git
synced 2025-09-14 03:23:41 +02:00
v9.0-pre-c
Finalized default interaction "copyText()"
This commit is contained in:
parent
2a500d8e11
commit
3005b28d8c
3 changed files with 21 additions and 13 deletions
|
@ -32,9 +32,11 @@ const interactions = {
|
|||
// Remove transition CSS when finished. Wonky resize effects otherwise
|
||||
setTimeout(() => menu.style.removeProperty("transition"),transition + 1);
|
||||
},
|
||||
// Open page defined with data-value as a card
|
||||
newCard: (event) => {
|
||||
const module = import("./modules/Modals.mjs");
|
||||
const interactions = {
|
||||
// Like newCard() except it closes the previous card
|
||||
getContact: (event) => {
|
||||
const service = event.target.dataset.value;
|
||||
module.then(modals => {
|
||||
|
@ -43,19 +45,25 @@ const interactions = {
|
|||
card.openPage(service);
|
||||
});
|
||||
},
|
||||
// Copy text defined in data-value to clipboard and play animation
|
||||
copyText: (event) => {
|
||||
event.target.classList.add("copied");
|
||||
const copied = document.createElement("p");
|
||||
copied.innerText = "copied!";
|
||||
event.target.appendChild(copied);
|
||||
|
||||
setTimeout(() => {
|
||||
event.target.classList.remove("copied");
|
||||
destroy(copied);
|
||||
},1000);
|
||||
const copy = navigator.clipboard.writeText(event.target.dataset.value);
|
||||
copy.then(() => {
|
||||
event.target.classList.add("copied");
|
||||
const copied = document.createElement("p");
|
||||
copied.innerText = "copied!";
|
||||
event.target.appendChild(copied);
|
||||
|
||||
// Reset button state
|
||||
setTimeout(() => {
|
||||
event.target.classList.remove("copied");
|
||||
destroy(copied);
|
||||
},1000);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Create card and open the specified page asynchronously
|
||||
module.then(modals => {
|
||||
const card = new modals.Card(interactions);
|
||||
card.openPage(event.target.dataset.value);
|
||||
|
@ -67,5 +75,5 @@ const interactions = {
|
|||
const theme = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
theme.addEventListener("change",updateTheme);
|
||||
|
||||
new Interaction(interactions,document.body);
|
||||
new Interaction(interactions,document.body); // Initialize default interactions
|
||||
updateTheme();
|
|
@ -59,7 +59,7 @@
|
|||
<h1>hello@victorwesterlund.com</h1>
|
||||
<p>You can also <a class="button" href="mailto:hello@victorwesterlund.com?subject=Hello Victor!">here</a> to send a mail directly from your mail app</p>
|
||||
<p></p>
|
||||
<div class="button solid" data-action="copyText">
|
||||
<div class="button solid" data-action="copyText" data-value="hello@victorwesterlund.com">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18 2H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h9c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H9V4h9v12zM3 15v-2h2v2H3zm0-5.5h2v2H3v-2zM10 20h2v2h-2v-2zm-7-1.5v-2h2v2H3zM5 22c-1.1 0-2-.9-2-2h2v2zm3.5 0h-2v-2h2v2zm5 0v-2h2c0 1.1-.9 2-2 2zM5 6v2H3c0-1.1.9-2 2-2z"/></svg>
|
||||
<p>copy email</p>
|
||||
</div>
|
|
@ -68,9 +68,9 @@
|
|||
}
|
||||
</style>
|
||||
<img id="logo_signal" src="assets/img/icons/signal.svg"/>
|
||||
<h1 id="number">+4670-2452459</h1>
|
||||
<h1 id="number">+4670-245-2459</h1>
|
||||
<p>Signal is a free and encrypted message platform with apps for all major platforms.</p>
|
||||
<div class="button solid" data-action="copyText">
|
||||
<div class="button solid" data-action="copyText" data-value="+46702452459">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18 2H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h9c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H9V4h9v12zM3 15v-2h2v2H3zm0-5.5h2v2H3v-2zM10 20h2v2h-2v-2zm-7-1.5v-2h2v2H3zM5 22c-1.1 0-2-.9-2-2h2v2zm3.5 0h-2v-2h2v2zm5 0v-2h2c0 1.1-.9 2-2 2zM5 6v2H3c0-1.1.9-2 2-2z"/></svg>
|
||||
<p>copy number</p>
|
||||
</div>
|
Loading…
Add table
Reference in a new issue