Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggle see more/see less on wins card #1732

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions _sass/components/_wins-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@
@media #{$bp-below-mobile} {
.wins-card-text{
height: 80px;
margin-top: 16px;
}
.wins-card-overview{
height: 100%;
}
.wins-card{
padding: 24px;
Expand Down Expand Up @@ -308,9 +312,6 @@
height: 20px;
width: 20px;
}
.wins-card-text{
margin-top: 16px;
}

.wins-card-overview{
margin-top: 0;
Expand All @@ -323,6 +324,7 @@
//modal overlay
@media #{$bp-desktop-up} {
.wins-card-overview{
height: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
Expand Down Expand Up @@ -399,11 +401,12 @@
}
.expanded{
height: auto;
.wins-see-more-div {
position: relative;
text-align: right;
}
// .wins-see-more-div {
// position: relative;
// text-align: right;
// }
qiqicodes marked this conversation as resolved.
Show resolved Hide resolved
}

}

.wins-card-content > * {
Expand Down
3 changes: 3 additions & 0 deletions assets/images/wins-page/caret.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 29 additions & 32 deletions pages/wins/wins.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,18 @@

winsCardContainer.append(cloneCardTemplate);

const winText = cloneCardTemplate.querySelector('.wins-card-text')
function addSeeMore() {
let innerHeight = Array.from(winText.childNodes).reduce((acc, el) => (el.offsetHeight || 0) + acc, 0) - 22

//makes the see more span on the bottom of the card
if (innerHeight <= winText.offsetHeight) { //checks if see more is needed.
winText.querySelector('.wins-see-more-div').setAttribute('hidden', 'true')
} else {
winText.querySelector('.wins-see-more-div').removeAttribute('hidden')
winsBelowDesktop()
}
}
addSeeMore()
// const winText = cloneCardTemplate.querySelector('.wins-card-text')
// function addSeeMore() {
// let innerHeight = Array.from(winText.childNodes).reduce((acc, el) => (el.offsetHeight || 0) + acc, 0) - 22

// //makes the see more span on the bottom of the card
// if (innerHeight => winText.offsetHeight) { //checks if see more is needed.
// winsBelowDesktop()
// }
// }
// addSeeMore()

new ResizeObserver(addSeeMore).observe(winText)
// new ResizeObserver(addSeeMore).observe(winText)
qiqicodes marked this conversation as resolved.
Show resolved Hide resolved
})
}

Expand All @@ -395,39 +392,39 @@
if (screenWidth > 960){
updateOverlay(id);
}else{
mobileSeeMore(id);
toggleSeeMoreLess(id);
}
}

//Adds event listener to badge icons when viewers interface is below desktop size
//Click expands wins text and removes "see more"
//Click to toggle "see more" and "see less" to expand and collapse wins text
function winsBelowDesktop() {
document.querySelectorAll('.wins-badge-icon').forEach(img => img.addEventListener('click', function (event) {
const container = event.target.parentElement.parentElement;
const id = container.dataset.index
const id = container.dataset.index;

mobileSeeMore(id)
container.setAttribute('class', 'wins-tablet wins-icon-container');
toggleSeeMoreLess(id);
}))
}

function mobileSeeMore(id){
function toggleSeeMoreLess(id){
let span = document.getElementById(id);
let parent = span.parentElement.parentElement;
let winsInfo = span.parentElement.parentElement.parentElement.parentElement;
let winsIconContainer = winsInfo.nextElementSibling
parent.classList.add('expanded');
winsIconContainer.setAttribute('class', 'wins-tablet wins-icon-container');
//FIXME: this is here for when see more/see less logic is added
// if (parent.classList.contains('expanded')) {
// span.innerHTML = "see less";
// winsInfo.nextElementSibling.setAttribute('class', 'wins-tablet wins-icon-container');
// }
// else {
// span.innerHTML = "...see more";
// winsInfo.nextElementSibling.removeAttribute('class', 'wins-tablet');
// }
let winsIconContainer = winsInfo.nextElementSibling;

if (!parent.classList.contains('expanded')) {
parent.setAttribute('class','project-inner wins-card-text expanded');
span.innerHTML = '<img src="/assets/images/wins-page/caret.svg" alt="caret">&nbsp; see less';
winsIconContainer.setAttribute('class', 'wins-tablet wins-icon-container');
}
else {
parent.setAttribute('class','project-inner wins-card-text');
span.innerHTML = "...see more";
winsIconContainer.setAttribute('class', 'wins-icon-container');
}
}

// need to delete makeElement and makeIcon
function makeElement(elementType, parent, className) {
let child = document.createElement(elementType);
Expand Down