-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add class list and cs169a notes
- Loading branch information
1 parent
d5299bd
commit 2672b97
Showing
64 changed files
with
1,174 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.itemListContainer{ | ||
display:flex; | ||
gap:40px; | ||
flex-wrap:wrap; | ||
justify-content:center; | ||
} | ||
.listItemContents{ | ||
position:relative; | ||
display:flex; | ||
flex-direction:column; | ||
justify-content: space-between; | ||
padding:30px; | ||
gap:30px; | ||
background:black; | ||
border-radius:15px; | ||
max-width:700px; | ||
margin:3px; | ||
} | ||
.clickable{ | ||
cursor: pointer; | ||
} | ||
|
||
.pillBox{ | ||
display:flex; | ||
flex-direction:row; | ||
gap:15px; | ||
} | ||
.pill{ | ||
padding:5px 8px; | ||
color:var(--tertiary-pink); | ||
background-color: rgba(211, 112, 219, 0.15); | ||
border-radius:10px; | ||
} | ||
|
||
@media screen and (max-width:700px){ | ||
.listItem{ | ||
padding:20px; | ||
height: fit-content !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Populates the class list. | ||
* @param {Array<Object>} classListData the json decoded class list data. | ||
*/ | ||
function populateClassList(classListData) { | ||
const classList = document.getElementById('classList'); | ||
classListData.forEach(classData => { | ||
classList.appendChild(getClassListItem(classData)); | ||
}); | ||
} | ||
|
||
/** | ||
* Gets a new class item instance. | ||
* @param {Object} classInfo the class information. | ||
* @return {DocumentFragment} the class list item to be rendered. | ||
*/ | ||
function getClassListItem(classInfo) { | ||
const classItem = document.querySelector('[listItemTemplate].classes') | ||
.content | ||
.cloneNode(true) | ||
.children[0]; | ||
classItem.querySelector('.itemTitle').textContent = classInfo.name; | ||
classItem.querySelector('.itemBody').textContent = `${classInfo.class}: ${classInfo.description}`; | ||
const pillBox = classItem.querySelector('.pillBox'); | ||
classInfo.tags.forEach(tag => { | ||
pillBox.appendChild(getPill(classItem, tag)); | ||
}); | ||
classItem.addEventListener('click', () => { | ||
window.location = `./${classInfo.name}`; | ||
}) | ||
return classItem; | ||
} | ||
|
||
/** | ||
* Gets a new pill instance. | ||
* @param {DocumentFragment} parent the parent node that defines the pill template. | ||
* @param {string} pillValue value of the pill. | ||
* @return {DocumentFragment} the pill to be rendered. | ||
*/ | ||
function getPill(parent, pillValue) { | ||
const pill = parent.querySelector('[PillTemplate]').content.cloneNode(true).children[0]; | ||
pill.textContent = pillValue; | ||
return pill; | ||
} | ||
|
||
fetch("./assets/json/classes.json").then(res => { | ||
res.json().then(classListData => { | ||
populateClassList(classListData); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ | ||
{ | ||
"class": "Introduction to Software Engineering", | ||
"name": "cs169a", | ||
"description": "Ideas and techniques for designing, developing, and modifying large software systems.", | ||
"tags": ["ruby", "agile", "saas"] | ||
} | ||
] |
62 changes: 62 additions & 0 deletions
62
public/classes/cs169a/assets/js/classOptionListPopulator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Populates the list. | ||
* @param {string} listName the name of the list being populated. | ||
* @param {Array<Object>} listData the json decoded list data. | ||
* @param {function} itemPopulator a function that populates the blank item instance. | ||
*/ | ||
function populateList(listName, listData, itemPopulator) { | ||
const listRef = document.getElementById(`${listName}List`); | ||
listData.forEach(listItemData => { | ||
listRef.appendChild(getListItem(listName, listItemData, itemPopulator)); | ||
}); | ||
} | ||
|
||
/** | ||
* Gets a new list item instance. | ||
* @param {string} listName the name of the list being populated. | ||
* @param {Object} itemData the item's information. | ||
* @param {function} populate a function that populates the blank item instance. | ||
* @return {Element} the class list item to be rendered. | ||
*/ | ||
function getListItem(listName, itemData, populate=()=>{}) { | ||
const itemInstance = document.querySelector(`[listItemTemplate].${listName}`) | ||
.content | ||
.cloneNode(true) | ||
.children[0]; | ||
const pillBox = itemInstance.querySelector('.pillBox'); | ||
itemData.tags?.forEach(tag => { | ||
pillBox.appendChild(getPill(itemInstance, tag)); | ||
}); | ||
if (itemData.title) { | ||
itemInstance.querySelector('.itemTitle').textContent = itemData.title; | ||
} | ||
if (itemData.body) { | ||
itemInstance.querySelector('.itemBody').textContent = itemData.body; | ||
} | ||
if (itemData.ref) { | ||
itemInstance.classList.add('clickable'); | ||
itemInstance.addEventListener('click', () => { | ||
window.location = itemData.ref; | ||
}); | ||
} | ||
populate(itemInstance, itemData); | ||
return itemInstance; | ||
} | ||
|
||
/** | ||
* Gets a new pill instance. | ||
* @param {Element} parent the parent node that defines the pill template. | ||
* @param {string} pillValue value of the pill. | ||
* @return {DocumentFragment} the pill to be rendered. | ||
*/ | ||
function getPill(parent, pillValue) { | ||
const pill = parent.querySelector('[PillTemplate]').content.cloneNode(true).children[0]; | ||
pill.textContent = pillValue; | ||
return pill; | ||
} | ||
|
||
fetch("./assets/json/options.json").then(res => { | ||
res.json().then(listData => { | ||
populateList('classOptions', listData); | ||
}); | ||
}); |
Oops, something went wrong.