Select random accent font on page load

This commit is contained in:
TheThomaas 2025-05-27 21:41:33 +02:00
parent 04f0fb83f7
commit 2e3a000f30

View file

@ -22,4 +22,16 @@ const observer = new IntersectionObserver(entries => {
document.querySelectorAll('section').forEach(function(section, i) {
observer.observe(section);
});
});
// Random accent font & color
const random = (min, max) => {
return Math.floor(Math.random() * (max-min+1) + min);
}
function randomFont() {
let randomNumber = random(1, 3);
document.documentElement.style.setProperty("--accent-font", `var(--accent-font-${randomNumber})`);
}
randomFont();