Skip to content

Commit

Permalink
add search result name to portrait alt
Browse files Browse the repository at this point in the history
  • Loading branch information
mk360 committed Sep 1, 2024
1 parent fd57364 commit 72e610c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
23 changes: 17 additions & 6 deletions script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
}

function addToBarracks() {
const newButtons = createHeroItem(this.dataset.unitId, true);
// const portraitImg = this.getElementsByClassName("portrait")[0];
// const newButtons = createHeroItem(this.dataset.unitId, true, portraitImg.alt);
const deleteIcon = createDeleteIcon();
const favoriteIcon = createFavoritesIcon(false);
favoriteIcon.onclick = handleFavoriteHeroEvent(newButtons.heroButton, false);
Expand Down Expand Up @@ -186,11 +187,21 @@

for (let elem of elements) {
const { wpn, mvt, id, name} = elem;
const { heroButton, iconsContainer } = createHeroItem(id, true);
const { heroButton, iconsContainer } = createHeroItem(id, true, name);
// const weaponTypeImage = document.createElement("img");
// const stringWeaponType = WEAPON_TYPES[wpn].replace(/ /g, "_");
// weaponTypeImage.src = `https://feheroes.fandom.com/wiki/Special:Filepath/Icon_Class_${stringWeaponType}.png`;
// weaponTypeImage.loading = "lazy";
// weaponTypeImage.src = `https://feheroes.fandom.com/wiki/Special:Redirect/file/Icon_Class_${stringWeaponType}.png`;
// weaponTypeImage.alt = stringWeaponType;
// weaponTypeImage.classList.add("top-left");

// const movementTypeImage = document.createElement("img");
// movementTypeImage.loading = "lazy";
// const stringMovementType = MOVEMENT_TYPES[mvt];
// movementTypeImage.src = `https://feheroes.fandom.com/wiki/Special:Redirect/file/Icon_Move_${stringMovementType}.png`;
// movementTypeImage.classList.add("top-right");

// iconsContainer.appendChild(movementTypeImage);
// iconsContainer.appendChild(weaponTypeImage);
SEARCH_RESULTS.appendChild(heroButton);
heroButton.onclick = addToBarracks;
Expand All @@ -215,11 +226,11 @@
});
}

function createHeroItem(heroId, addIcons) {
function createHeroItem(heroId, addIcons, alt) {
const heroButton = document.createElement("button");
heroButton.classList.add("hero-container");
const frame = document.createElement("img");
frame.alt = "";
frame.alt = alt ?? "";
frame.src = "./static/frame.webp";
frame.classList.add("hero-frame");

Expand Down Expand Up @@ -256,7 +267,7 @@
function createFavoritesIcon(initialState) {
const img = document.createElement("img");
img.src = initialState ? "./static/favorite-on.png" : "./static/favorite-off.png";
img.classList.add("favorite-button");
img.classList.add("top-left");
return img;
}

Expand Down
2 changes: 1 addition & 1 deletion script/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions static/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ main {
grid-template-rows: repeat(auto-fit, var(--cell-size));
}

.favorite-button {
.top-left {
z-index: 1;
border: 0;
outline: 1px solid transparent;
Expand All @@ -255,6 +255,16 @@ main {
}
}

.top-right {
z-index: 1;
border: 0;
outline: 1px solid transparent;
position: absolute;
top: 0;
right: 0;
height: 2rem;
}

#search-query {
width: 100%;
height: 100%;
Expand Down Expand Up @@ -366,7 +376,7 @@ main {
}
}

.favorite-button {
.top-left, .top-right {
height: 3rem;
}

Expand Down
Loading

0 comments on commit 72e610c

Please sign in to comment.