Skip to content

Commit

Permalink
Merge pull request #1 from Thinking-Panda/accomplishments-about-page-…
Browse files Browse the repository at this point in the history
…different-years-4188

accomplishments-year-check
  • Loading branch information
Thinking-Panda authored Nov 22, 2023
2 parents a94f35a + ad13551 commit 400658a
Show file tree
Hide file tree
Showing 4 changed files with 248 additions and 20 deletions.
46 changes: 45 additions & 1 deletion _data/internal/accomplishments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,89 @@
In 9/2020 Hack for LA joined over 40 Code for America brigades in bringing together civic leaders,
public servants, designers, coders, and engaged citizens to partner with local government and community groups to help those most
in need of a social safety net services during COVID-19.
year: 2020
program-area: Justice

- title: Food Oasis
link: https://www.hackforla.org/projects/food-oasis
description: >
Launched 8/2020 the most comprehensive listing of Food Pantries and Meals to address food insecurity in Los Angeles (listed as a resource on LA County Public Health website).
year: 2020
project-file: food-oasis.md

- title: LA TDM Calculator
link: https://www.hackforla.org/projects/tdm-calculator
description: >
Hack for LA’s first software application in CI/CD on LA City Department of Transportation’s
Azure servers - launching publicly in Q4 2020
year: 2020
project-file: tdm-calculator.md

- title: 311-DATA
link: https://www.hackforla.org/projects/311-data
description: >
Launched 8/2020 a comprehensive 311 service report Neighborhood Council (NC) and City Council district
comparison tool using 311 data provided by LA City’s data portal. The product was created through extensive
Design thinking workshops with NC board members and LA Department of Neighborhood Empowerment
year: 2020
project-file: 311-data.md

- title: Climate Collabathon
link: https://www.collabathon.openclimate.earth/
description: >
Launched 4/2020 the Online Climate Collabathon in partnership with Yale Open Labs, Sensorica,
ESMT Berlin, and CoMakery. 15 speakers, and over 20 breakout and working sessions with experts
and professionals from across the sector all on Zoom.
year: 2020
program-area: Environment

- title: Undebate
link: https://www.hackforla.org/projects/undebate
description: >
Hack for LA has provided labor to this important tool which continues to increase engagement at local elections
throughout the country from the San Francisco City Attorney race, to Student Association Elections on College Campuses.
year: 2020
project-file: undebate.md

- title: Write for All
link: https://www.hackforla.org/projects/writeforall
description: >
Launched 04/2020. The Write For All project proof of concept finds exclusive language where inclusive language should exist.
year: 2020
project-file: writeforall.md

- title: New Schools Today
link: https://www.hackforla.org/projects/new-schools-today
description: >
Created and Presented 3/2020 three technical workshops for Title 1 school students at the UCLA Exploretech Conference.
The project from conception to delivery was executed by Hack for LA’s first team of all high school students.
The project from conception to delivery was executed by Hack for LA’s first team of all high school students.
year: 2020
project-file: new-schools-today.md

- title: Test Sample Acc 2021
link: https://www.hackforla.org/projects/new-schools-today
description: >
links to new school today project. program area is div/equality/incl.
year: 2021
project-file: new-schools-today.md

- title: Test Sample Acc 2022
link: https://www.hackforla.org/projects/undebate
description: >
links to undebate. program area is vote/rep.
year: 2022
project-file: undebate.md

- title: Test Sample Acc 2022
link: https://www.hackforla.org/projects/tdm-calculator
description: >
links to tdm calculator. program area is environment.
year: 2022
project-file: tdm-calculator.md

- title: Test Sample Acc 2021
link: https://www.hackforla.org/projects/new-schools-today
description: >
links to new school today project. program area is div/equality/incl.
year: 2021
project-file: new-schools-today.md
32 changes: 18 additions & 14 deletions _includes/about-page/about-card-accomplishments.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<div class="card-primary page-card-lg page-card--about">
<div class="about-us-section-header" data-hash="accomplishments"><span class="sec-head-img"><img src="/assets/images/about/section-header-elements/accomplishments.svg" alt="" /></span>Accomplishments</div>
<div class="about-us-section-content">
<div class="accomplishment-nav">
<select name="accomplishments-year" id="accomplishments-year-dropdown">
<option value="All">All</option>
<!--Years are added dynamically-->
</select>
<ul id="accomplishments-year-list">
<li id="All">All</li>
<!--Years are added dynamically-->
</ul>
</div>
<div class="flex-container">
<!--This is the top and then right cell-->
<div class="top-left-column top-left-column--acc">
<p class="text-bold accomplishment-highlights">Highlights from 2020</p>
{% for accomplishment in site.data.internal.accomplishments limit:4 %}
<div class="accomplishment-title"><a href="{{accomplishment.link}}" target="_blank" rel="noopener noreferrer"> {{accomplishment.title}} </a></div>
<div> {{ accomplishment.description }} </div>
{% endfor %}
</div>

<div class="bottom-right-column bottom-right-column--acc">
{% for accomplishment in site.data.internal.accomplishments limit:4 offset:4 %}
<div class="accomplishment-title"><a href="{{accomplishment.link}}" target="_blank" rel="noopener noreferrer"> {{accomplishment.title}} </a></div>
<div> {{ accomplishment.description }} </div>
{% endfor %}
</div>
{% assign accomplishments= site.data.internal.accomplishments %}
<div class="top-left-column top-left-column--acc"></div>
<div class="bottom-right-column bottom-right-column--acc"></div>
</div>
<div class="flex-container flex-container--wins">
<!--This is the top and then right cell-->
Expand All @@ -32,3 +31,8 @@
</div>
</div>
</div>
<script id="accScript"
src="/assets/js/about.js"
type="module"
accomplishments='{{ accomplishments }}'>
</script>
58 changes: 57 additions & 1 deletion _sass/components/_about.scss
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,66 @@ a.anchor {
display: none;
}

.accomplishment-nav select {
width: 100%;
height: 44px;
top: 56663px;
left: -6729px;
border-radius: 5px;
border: 1px solid rgba(0, 0, 0, 0.24);
}

.accomplishment-nav ul {

display: none;

}



@media #{$bp-mobile-up} {
.accomplishment-nav select {
display: none;
}
.accomplishment-nav ul {
display: inline-block;
list-style-type: none;
background-color:rgba(247, 245, 245, 1);
width: 100%;
text-align: left;
height: 67px;
padding: 20px 16px 20px 16px;
gap: 36px;

}

.accomplishment-nav ul li {
display: inline-block;
font-size: 20px;
font-weight: 700;
line-height: 27px;
letter-spacing: 0em;
text-align: left;
margin-left: 32px;
padding: 5px;
}

.accomplishment-nav ul li:hover {
color: rgb(250, 17, 79);
}
}


.accomplishment-program-area {
padding: 10px 0 0 0;
color: $color-black;
font-weight: 700;
}

.accomplishment-title {
color: $color-red;
text-decoration: underline;
margin: 25px 0 10px 0;
padding: 10px 0 5px 0;
font-weight: 500;
}

Expand Down
132 changes: 128 additions & 4 deletions assets/js/about.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---

---

// Constant setups for reuse throughout document
const ANCHOR_LINKS_ID = [...document.querySelectorAll(".anchor")].map((anchor) => anchor.id);
const NAVIGATION_LINK_ELEMENTS = document.querySelectorAll(".sticky-nav a");
Expand All @@ -11,8 +15,14 @@ const FLAGS = {

document.addEventListener("DOMContentLoaded", function () {

const accomplishments=retrieveAccomplishmentsData();
const accByProgramArea=sortAccomplishmentsByProgramArea(accomplishments);
displayAccomplishments(accByProgramArea);

// UI components are updated on page load
updateUI();

loadAccomplishmentYears();

// UI components are updated on location change
window.addEventListener("locationchange", updateUI);
Expand All @@ -22,6 +32,9 @@ document.addEventListener("DOMContentLoaded", function () {
document.addEventListener("wheel", scrollHandler);

document.querySelectorAll("#sticky-nav li a").forEach((navlink) => { navlink.addEventListener("click", toggleNavClass); });

document.querySelector("#accomplishments-year-dropdown").addEventListener("change", function(event) {yearEventHandler(accByProgramArea,event)});
document.querySelectorAll("#accomplishments-year-list li").forEach((item)=>{item.addEventListener("click", function(event) {yearEventHandler(accByProgramArea,event)})});
});

/**
Expand Down Expand Up @@ -50,18 +63,18 @@ function updateUI() {
}
setupAccordionEventLitseners();
changeDisplayMode();
stickItHere();
stickItHere();
}

function changeDisplayMode() {
if (window.innerWidth < BREAK_POINT && FLAGS.displayChanged) {
document.querySelectorAll(".page-card--about:nth-child(n+3)").forEach((pageCard) => {pageCard.lastElementChild.style.display = "none"; });
document.querySelectorAll(".page-card--about:nth-child(n+3)").forEach((pageCard) => {pageCard.lastElementChild.style.display = "none"; });
document.querySelector(`div[data-hash="${window.location.hash.split("#")[1]}"]`).parentElement.lastElementChild.style.display = "block";
document.querySelector(`div[data-hash="${window.location.hash.split("#")[1]}"]`).parentElement.children[0].classList.toggle("au_active")
FLAGS.displayChanged = false;
}
else if (window.innerWidth > BREAK_POINT && !FLAGS.displayChanged) {
document.querySelectorAll(".page-card--about:nth-child(n+3)").forEach((pageCard) => { pageCard.lastElementChild.style.display = "block"; });
document.querySelectorAll(".page-card--about:nth-child(n+3)").forEach((pageCard) => { pageCard.lastElementChild.style.display = "block"; });
document.querySelectorAll(".au_active").forEach((pageCard) => { pageCard.classList.remove("au_active"); });
FLAGS.displayChanged = true;
}
Expand Down Expand Up @@ -126,6 +139,21 @@ function stickItHere() {
}
}

//This function lists the years in the Accomplishments
function loadAccomplishmentYears() {
let d = new Date();
let year = d.getFullYear();
for (i=year; i>=2020; i--){
let optionsHtml='<option value="' + i + '">' + i + '</option>';
document.querySelector("#accomplishments-year-dropdown").insertAdjacentHTML ('beforeend',optionsHtml);
}
for (i=year; i>=2020; i--){
let listItemHtml='<li id="' + i + '">' + i + '</li>';
document.querySelector("#accomplishments-year-list").insertAdjacentHTML ('beforeend',listItemHtml);
}
console.log ("Accomplishment years have loaded");
}


/**
* Alignment of page card with its corresponding link on the sticky navigation
Expand Down Expand Up @@ -184,4 +212,100 @@ window.addEventListener(


}
)
);

function retrieveAccomplishmentsData() {
const scriptTag = document.getElementById("accScript");
let receivedData = scriptTag.getAttribute("accomplishments");
let accData=receivedData.replaceAll("}{", "},{").replaceAll("=>",":");
let jsonFormat="[" + accData + "]";
const accomplishmentsData=JSON.parse(jsonFormat);
return accomplishmentsData;
}

function sortAccomplishmentsByProgramArea(accomplishments){
let accData=[...accomplishments];
{% assign projects = site.projects %}
let projectData=[{%- for project in projects -%}
{"project-path":"{{project.path | split: '/' | last}}","program-area": "{{project.program-area}}"}
{%- unless forloop.last -%}, {% endunless %}
{%- endfor -%}];
accData.forEach(acc => {
if (acc["project-file"]){
projectData.forEach(project => {
if (project["project-path"] == acc["project-file"]){
acc["program-area"] = project["program-area"];
}
})
}
});
accData.sort( (a,b) => (a["program-area"] > b["program-area"]) ? 1 : -1);
return (accData);
}

function yearEventHandler(accByProgramArea,e){
let items=document.querySelectorAll("#accomplishments-year-list li");
items.forEach(year=>year.style.color="black");
let element=e.target.nodeName;
let accYear="";
let accToDisplay=[];
if(element=="LI"){
e.target.style.color = "rgb(250,17,80,255)";
accYear=e.target.id;
}
else {
accYear=e.target.value;
}
if (accYear == "All"){
accToDisplay=accByProgramArea;
}
else {
let year=parseInt(accYear,10);
accByProgramArea.forEach(acc => {
if(acc.year== year) {
accToDisplay.push(acc);
}
})
}
displayAccomplishments(accToDisplay);
}

function displayAccomplishments(accToDisplay) {
document.querySelector(".top-left-column--acc").innerHTML="";
document.querySelector(".bottom-right-column--acc").innerHTML="";
if(accToDisplay.length ==0){
document.querySelector(".top-left-column--acc").innerHTML="<p>Work In Progress...</p>";
}
let progAreaList=[];
let accCount = accToDisplay.length;
let colItems = Math.ceil(accCount/2);
let counter = 1;
accToDisplay.forEach(acc => {
if(!progAreaList.includes(acc["program-area"])) {
progAreaList.push(acc["program-area"]);
}
})
for( let i=0; i<=progAreaList.length-1;i++){
let progAreaHtml='<div class="accomplishment-program-area">' + progAreaList[i] + '</div>';
if (counter <= colItems){
document.querySelector(".top-left-column--acc").insertAdjacentHTML("beforeend",progAreaHtml);
}
else {
document.querySelector(".bottom-right-column--acc").insertAdjacentHTML("beforeend",progAreaHtml);
}
accToDisplay.forEach(acc => {
if(acc["program-area"]== progAreaList[i] && counter<=colItems){
counter++;
let accHtml= ` <div class="accomplishment-title"><a href="${acc.link}" target="_blank" rel="noopener noreferrer"> ${acc.title} </a></div>
<div> ${acc.description} </div>`;
document.querySelector(".top-left-column--acc").insertAdjacentHTML("beforeend",accHtml);
}
else if (acc["program-area"]== progAreaList[i] && counter>colItems) {
let accHtml= ` <div class="accomplishment-title"><a href="${acc.link}" target="_blank" rel="noopener noreferrer"> ${acc.title} </a></div>
<div> ${acc.description} </div>`;
document.querySelector(".bottom-right-column--acc").insertAdjacentHTML("beforeend",accHtml);
}
})
}
console.log ("accomplishments displayed")
}

0 comments on commit 400658a

Please sign in to comment.