From 929c0fe708eaef206ea8a57f529c11b78a88946d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B8=D0=BC=D1=83=D1=80=20=D0=90=D1=85=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=B7=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Sat, 3 Aug 2024 14:19:40 +0500 Subject: [PATCH] added health btn --- index.html | 6 ++++++ js/battle.js | 28 ++++++++++++++++++++++++++- styles/char-styles.css | 44 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 3216b2a..97025e8 100644 --- a/index.html +++ b/index.html @@ -66,7 +66,13 @@

Name

diff --git a/js/battle.js b/js/battle.js index 5df9470..552dfd6 100644 --- a/js/battle.js +++ b/js/battle.js @@ -134,16 +134,42 @@ function clearCharacters() { function openCharInfo(id) { if (document.querySelector(".char-addinfo-container") != null) { if (document.querySelector(".char-addinfo-container").id == id + "-info") { + document.querySelector("#" + id).children[1].children[1].classList.remove("info-btn-opened"); document.querySelector(".char-addinfo-container").remove(); return; } + let last_id = document.querySelector(".char-addinfo-container").id; + last_id = last_id.substring(0, last_id.length - 5); + + document.querySelector("#" + last_id).children[1].children[1].classList.remove("info-btn-opened"); document.querySelector(".char-addinfo-container").remove(); } const info = document.createElement('div'); info.classList.add("char-addinfo-container"); info.id = id + "-info"; - info.innerHTML = '
'; + + const box = document.createElement('div'); + box.id = "char-addinfo"; + + const health_btn = document.createElement('button'); + health_btn.id = "health-btn"; + health_btn.classList.add("add-info-btn"); + health_btn.innerHTML = '' + + '' + + '' + + '

Health

' + + box.appendChild(health_btn); + + info.appendChild(box); + + document.querySelector("#" + id).children[1].children[1].classList.add("info-btn-opened"); document.querySelector("#" + id).insertAdjacentElement("afterend", info); } diff --git a/styles/char-styles.css b/styles/char-styles.css index d03619c..592c52d 100644 --- a/styles/char-styles.css +++ b/styles/char-styles.css @@ -29,7 +29,11 @@ margin-right: 20px; height: 200px; - width: 220px; + width: 200px; + + display: flex; + flex-direction: column; + align-items: center; } .char-name { @@ -51,6 +55,10 @@ background: transparent; } +.info-btn-opened { + transform: rotate(180deg); +} + .bi-chevron-compact-down { width: 27px; height: 27px; @@ -80,4 +88,38 @@ .high-hp { color: #56949f; /* border: 1px solid #56949f; */ +} + +#health-btn { + border: 2px solid #56949f; + + color: #56949f; +} + +.add-info-btn { + background: transparent; + border-radius: 10px; + + width: 120px; + height: 40px; + + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + + margin-top: 15px; + + font-family: "Montserrat"; + font-size: 20px; +} + +.add-info-btn > p { + margin: 0; +} + +#health-btn > .bi-heart { + width: 20px; + height: 20px; + margin-top: 3px; } \ No newline at end of file