Skip to content

Commit

Permalink
[Bug Fix] New Home Page Bug Fixes (Stirling-Tools#1973)
Browse files Browse the repository at this point in the history
* Fix favorites section being cut off if it has too many items.

* Fix the group collapse transition animation playing on page load.
  • Loading branch information
FiratUsta authored Sep 30, 2024
1 parent 86bb37a commit 092b4cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/main/resources/static/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@
display: grid;
grid-template-columns: repeat(auto-fill, minmax(15rem, 3fr));
gap: 30px 30px;
transition: 0.5s all;
overflow: hidden;
margin: -20px;
padding: 20px;
}

.feature-group-container.animated-group {
transition: 0.5s all;
}

.feature-group.collapsed>.feature-group-container {
max-height: 0 !important;
margin: 0;
Expand Down
18 changes: 15 additions & 3 deletions src/main/resources/static/js/homecard.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function filterCards() {

function updateFavoritesSection() {
const favoritesContainer = document.getElementById("groupFavorites").querySelector(".feature-group-container");
favoritesContainer.style.maxHeight = "none";
favoritesContainer.innerHTML = "";
const cards = Array.from(document.querySelectorAll(".feature-card"));
let favoritesAmount = 0;
Expand All @@ -40,6 +41,7 @@ function updateFavoritesSection() {
document.getElementById("groupFavorites").style.display = "flex";
};
reorderCards(favoritesContainer);
favoritesContainer.style.maxHeight = favoritesContainer.scrollHeight + "px";
};

function toggleFavorite(element) {
Expand Down Expand Up @@ -197,21 +199,31 @@ document.addEventListener("DOMContentLoaded", function () {
const container = header.parentNode.querySelector(".feature-group-container");
if (parent.id !== "groupFavorites") {
container.style.maxHeight = container.clientHeight + "px";
} else {
container.style.maxHeight = "500px";
}
header.onclick = () => {
expandCollapseToggle(parent);
};
})

const collapsed = localStorage.getItem("collapsedGroups") ? JSON.parse(localStorage.getItem("collapsedGroups")) : [];
const groupsArray = Array.from(document.querySelectorAll(".feature-group"));

Array.from(document.querySelectorAll(".feature-group")).forEach(group => {
groupsArray.forEach(group => {
if (collapsed.indexOf(group.id) !== -1) {
expandCollapseToggle(group, false);
}
})

// Necessary in order to not fire the transition animation on page load, which looks wrong.
// The timeout isn't doing anything visible to the user, so it's not making the page load look slower.
setTimeout(() => {
groupsArray.forEach(group => {
const container = group.querySelector(".feature-group-container");
container.classList.add("animated-group");
})
}, 500);



showFavoritesOnly();
});

0 comments on commit 092b4cc

Please sign in to comment.