From 1abbc86cc744c932a0c97684ec1eaa3f590f9e08 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 14 Oct 2023 17:07:14 +0200 Subject: [PATCH] add custom style for tags --- static/js/index.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 1aa2558..1f9a0b3 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -1,14 +1,23 @@ +class Tag { + constructor(variant, style = "") { + this.variant = variant; + this.style = style; + } +} + window.addEventListener("load", () => { const tags = [ - "Comment ça marche un PC 😵‍💫", - "Idiot certifié", - "undefined", - "/api/v1/love", - "Étudiant qui va rater son master", - "Peak D2 sur Valo 🤡", - "1312", + new Tag("Comment ça marche un PC 😵‍💫"), + new Tag("Idiot certifié"), + new Tag("undefined"), + new Tag("/api/v1/love", "font-family: monospace"), + new Tag("Étudiant qui va rater son master"), + new Tag("Peak D2 sur Valo 🤡"), + new Tag("1312"), ]; - document.getElementById("subname").textContent = - tags[Math.round(Math.random() * (tags.length - 1))]; + const random = Math.round(Math.random() * (tags.length - 1)); + const element = document.getElementById("subname"); + element.textContent = tags[random].variant; + element.style = tags[random].style; });