@@ -31,21 +31,21 @@ const currentCategory = alphabetData[alphabet as keyof AlphabetsData];
3131
3232 <BackButton />
3333 <article class =" tv container__typing" >
34- <div class =" letter" >A</div >
34+ <div id = " letter " class =" letter" >A</div >
3535 <div class =" content__display" >
36- <div class =" emoji" >{ currentCategory .icon } </div >
37- <div class =" image__container" ></div >
36+ <div id = " emoji " class =" emoji" >{ currentCategory .icon } </div >
37+ <div id = " image-container " class =" image__container" ></div >
3838 </div >
39- <div class =" spelling" id =" spelling" ></div >
40- <div class =" description" id =" description" ></div >
39+ <div id =" spelling" class =" spelling" ></div >
40+ <div id =" description" class =" description" ></div >
4141 </article >
4242
4343 <script define:vars ={ { alphabetData: currentCategory .data , category: alphabet }} >
44- const letterDiv = document.querySelector(". letter");
45- const emojiDiv = document.querySelector(". emoji");
46- const imageContainer = document.querySelector(".image__container ");
47- const spellDiv = document.querySelector(". spelling");
48- const descriptionDiv = document.querySelector(". description");
44+ const letterDiv = document.getElementById(" letter");
45+ const emojiDiv = document.getElementById(" emoji");
46+ const imageContainer = document.getElementById("image-container ");
47+ const spellDiv = document.getElementById(" spelling");
48+ const descriptionDiv = document.getElementById(" description");
4949
5050 const addClass = function (className) {
5151 this.classList.add(className);
@@ -63,6 +63,10 @@ const currentCategory = alphabetData[alphabet as keyof AlphabetsData];
6363 const drawInfo = (letter, color) => {
6464 const info = alphabetData.find((item) => item.letter === letter);
6565 if (info) {
66+ spellDiv.style.fontSize = "";
67+ spellDiv.style.marginTop = "";
68+ spellDiv.style.display = "block";
69+
6670 spellDiv.innerHTML = info.text;
6771 spellDiv.style.color = color;
6872
@@ -83,6 +87,7 @@ const currentCategory = alphabetData[alphabet as keyof AlphabetsData];
8387 if (info.description && info.description.trim() !== "") {
8488 descriptionDiv.innerHTML = info.description;
8589 descriptionDiv.style.color = color;
90+ descriptionDiv.style.display = "block";
8691 document.documentElement.style.setProperty("--steps-desc", info.description.length * 2);
8792
8893 // Animation handling for description
@@ -92,6 +97,7 @@ const currentCategory = alphabetData[alphabet as keyof AlphabetsData];
9297 } else {
9398 descriptionDiv.classList.remove("animation");
9499 descriptionDiv.innerHTML = "";
100+ descriptionDiv.style.display = "none";
95101 }
96102
97103 if (info.image) {
@@ -107,18 +113,24 @@ const currentCategory = alphabetData[alphabet as keyof AlphabetsData];
107113 img.style.maxWidth = "100%";
108114 img.style.maxHeight = "100%";
109115 };
110- img.onerror = function () {
111- emojiDiv.style.display = "block";
112- imageContainer.style.display = "none";
113- };
116+
114117 img.src = `/assets/images/alphabets/${category}/${info.image}`;
115118 img.alt = info.text;
116-
119+ } else if (info.emoji) {
120+ emojiDiv.innerHTML = info.emoji;
117121 emojiDiv.style.display = "block";
118122 imageContainer.style.display = "none";
119123 } else {
120- emojiDiv.style.display = "block";
121- imageContainer.style.display = "none";
124+ // Move spelling to the content display area
125+ emojiDiv.style.display = "none";
126+ imageContainer.style.display = "flex";
127+ imageContainer.innerHTML = `<div class="content__spelling">${info.text}</div>`;
128+
129+ const contentSpelling = imageContainer.querySelector(".content__spelling");
130+ contentSpelling.style.color = color;
131+
132+ // Hide original spelling div
133+ spellDiv.style.display = "none";
122134 }
123135 }
124136 };
0 commit comments