generated from satnaing/astro-paper
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a way to abstract UI browser code
- Loading branch information
Daveed
committed
Jan 4, 2025
1 parent
460f5e8
commit ba9e8ca
Showing
4 changed files
with
58 additions
and
27 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
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,30 @@ | ||
/** | ||
* | ||
*/ | ||
export const ProductSlideshow = function () { | ||
// Front matter TS is executed in the ~server during the build process | ||
// import confetti from 'canvas-confetti'; | ||
|
||
const buttons = document.querySelectorAll("[data-astro-image]"); | ||
|
||
// Add event listeners to fire confetti when a button is clicked. | ||
buttons.forEach(button => { | ||
button.addEventListener("click", e => { | ||
const jsonData = e.target?.getAttribute('data-astro-image'); | ||
|
||
try { | ||
const jsonObject = JSON.parse(jsonData || ''); // Parse the JSON string | ||
const heroImage = document.querySelector(".hero-image"); | ||
console.log({ heroImage }) | ||
|
||
if (heroImage) { | ||
heroImage.src = jsonObject.url; | ||
} | ||
|
||
console.log({ e, jsonData, jsonObject }); | ||
} catch (error) { | ||
console.error("Error parsing JSON", error); | ||
} | ||
}); | ||
}); | ||
}; |