Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
86 changes: 67 additions & 19 deletions components/Article.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const data = [
{
title: 'BloomTech Students: "We\'re the best!"',
date: 'Nov 5th, 2018',
date: "Nov 5th, 2018",
firstParagraph: `Lucas ipsum dolor sit amet ben twi'lek padmé darth darth darth moff hutt organa twi'lek. Ben amidala secura skywalker lando
moff wicket tatooine luke.Solo wampa wampa calrissian yoda moff.Darth grievous darth gonk darth hutt.Darth baba skywalker
watto fett jango maul han.Mon ewok sidious sidious lando kenobi grievous gamorrean solo.Yoda wedge utapau darth calamari.
Expand All @@ -21,11 +21,11 @@ const data = [
thirdParagraph: `Dagobah hutt jawa leia calamari ventress skywalker yoda. Binks wicket hutt coruscant sidious
naboo ackbar tatooine. Hutt lars padmé darth. Maul solo darth darth jabba qui-gon chewbacca darth maul. Moff baba wicket
han. C-3po antilles moff qui-gon ahsoka aayla dooku amidala. Palpatine droid amidala droid k-3po twi'lek padmé wookiee. Leia
moff calamari mon obi-wan. Solo grievous lando coruscant. Jinn darth palpatine obi-wan mon.`
moff calamari mon obi-wan. Solo grievous lando coruscant. Jinn darth palpatine obi-wan mon.`,
},
{
title: 'Javascript and You, ES6',
date: 'May 7th, 2019',
title: "Javascript and You, ES6",
date: "May 7th, 2019",
firstParagraph: `Alohamora wand elf parchment, Wingardium Leviosa hippogriff, house dementors betrayal. Holly, Snape centaur portkey ghost
Hermione spell bezoar Scabbers. Peruvian-Night-Powder werewolf, Dobby pear-tickle half-moon-glasses, Knight-Bus. Padfoot
snargaluff seeker: Hagrid broomstick mischief managed. Snitch Fluffy rock-cake, 9 ¾ dress robes I must not tell lies. Mudbloods
Expand All @@ -41,11 +41,11 @@ const data = [
thirdParagraph: `Toad-like smile Flourish and Blotts he knew I’d come back Quidditch World Cup. Fat Lady baubles banana fritters fairy lights
Petrificus Totalus. So thirsty, deluminator firs’ years follow me 12 inches of parchment. Head Boy start-of-term banquet Cleansweep Seven
roaring lion hat. Unicorn blood crossbow mars is bright tonight, feast Norwegian Ridgeback. Come seek us where our voices sound, we cannot
sing above the ground, Ginny Weasley bright red. Fanged frisbees, phoenix tears good clean match.`
sing above the ground, Ginny Weasley bright red. Fanged frisbees, phoenix tears good clean match.`,
},
{
title: 'React vs Angular vs Vue',
date: 'June 7th, 2019',
title: "React vs Angular vs Vue",
date: "June 7th, 2019",
firstParagraph: `Bulbasaur Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ivysaur Lorem ipsum dolor sit amet, consectetur adipiscing
elit. Venusaur Lorem ipsum dolor sit amet, consectetur adipiscing elit. Charmander Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Charmeleon Lorem ipsum dolor sit amet, consectetur adipiscing elit. Charizard Lorem ipsum dolor sit amet,
Expand All @@ -69,11 +69,11 @@ const data = [

thirdParagraph: `Gotta catch 'em all Horsea gym Ninjask Absol Sinnoh Poliwag. Gotta catch 'em all Youngster wants to fight Soda Pop Floatzel
Leech Life Seismitoad Ariados. Earthquake Pokemon Glitch City Tail Whip Skitty Ekans Dialga. Ut aliquip ex ea commodo consequat James
Castform Lotad the power that's inside Burnt Berry Makuhita. Ghost Ariados Corphish Dusclops Golbat Gligar Zweilous.`
Castform Lotad the power that's inside Burnt Berry Makuhita. Ghost Ariados Corphish Dusclops Golbat Gligar Zweilous.`,
},
{
title: 'Professional Software Development in 2019',
date: 'Jan 1st, 2019',
title: "Professional Software Development in 2019",
date: "Jan 1st, 2019",
firstParagraph: `Hodor hodor HODOR! Hodor hodor - hodor, hodor. Hodor hodor... Hodor hodor hodor; hodor hodor. Hodor hodor hodor, hodor, hodor
hodor. Hodor, hodor. Hodor. Hodor, hodor - hodor... Hodor hodor hodor; hodor HODOR hodor, hodor hodor?! Hodor hodor, hodor.
Hodor hodor hodor hodor hodor! Hodor hodor - HODOR hodor, hodor hodor hodor hodor hodor; hodor hodor? `,
Expand All @@ -85,23 +85,18 @@ const data = [

thirdParagraph: `Hodor hodor - hodor... Hodor hodor hodor hodor. Hodor. Hodor! Hodor hodor, hodor hodor hodor hodor hodor; hodor hodor? Hodor!
Hodor hodor, HODOR hodor, hodor hodor?! Hodor! Hodor hodor, HODOR hodor, hodor hodor, hodor, hodor hodor. Hodor, hodor.
Hodor. Hodor, hodor, hodor. Hodor hodor... Hodor hodor hodor?! Hodor, hodor... Hodor hodor HODOR hodor, hodor hodor. Hodor.`
}
Hodor. Hodor, hodor, hodor. Hodor hodor... Hodor hodor hodor?! Hodor, hodor... Hodor hodor HODOR hodor, hodor hodor. Hodor.`,
},
];

/*
Step 1: Write a component called 'articleMaker' to create an article.
Your component is a function that takes an article object as its only argument,
and returns a DOM node looking like the one below:

<div class="article">
<h2>{title of the article}</h2>
<p class="date">{date of the article}</p>


{three separate paragraph elements}

<span class="expandButton">+</span>
</div>


Step 2: Still inside `articleMaker`, add an event listener to the span.expandButton.
This listener should toggle the class 'article-open' on div.article.
Expand All @@ -113,4 +108,57 @@ const data = [

Step 5: Try adding new article object to the data array. Make sure it is in the same format as the others.
Refresh the page to see the new article.


<div class="article">
<h2>{title of the article}</h2>
<p class="date">{date of the article}</p>

{three separate paragraph elements}

<span class="expandButton">+</span>
</div>
*/
const articles = document.querySelector("div.articles");

function articleMaker(obj) {
const articleDiv = document.createElement("div");
const articleTitle = document.createElement("h2");
const paragraphDate = document.createElement("p");
const paragraphOne = document.createElement("p");
const paragraphTwo = document.createElement("p");
const paragraphThree = document.createElement("p");
const expand = document.createElement("span");

articleDiv.appendChild(articleTitle);
articleDiv.appendChild(paragraphDate);
articleDiv.appendChild(paragraphOne);
articleDiv.appendChild(paragraphTwo);
articleDiv.appendChild(paragraphThree);
articleDiv.appendChild(expand);

articleDiv.classList.add("article", "article-open");
paragraphDate.classList.add("date");
paragraphOne.classList.add("one");
paragraphTwo.classList.add("two");
paragraphThree.classList.add("three");
expand.classList.add("expandButton");

articleTitle.textContent = obj.title;
paragraphDate.textContent = obj.date;
paragraphOne.textContent = obj.firstParagraph;
paragraphTwo.textContent = obj.secondParagraph;
paragraphThree.textContent = obj.thirdParagraph;
expand.textContent = "+";

expand.addEventListener("click", () => {
articleDiv.classList.toggle("article-open");
});

return articleDiv;
}

data.forEach((article) => {
const articlesFromData = articleMaker(article);
articles.appendChild(articlesFromData);
});
43 changes: 36 additions & 7 deletions components/Menu.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// This is the data we will be using, study it but don't change anything, yet.

let menuItems = [
'Students',
'Faculty',
"Students",
"Faculty",
"What's New",
'Tech Trends',
'Music',
'Log Out'
"Tech Trends",
"Music",
"Log Out",
];

/*
Step 1: Write a component called 'menuMaker' to create a menu like the markup below:

<div class="menu">
<ul>
{each menu item as an <li>}
</ul>
</div>


The 'menuMaker' takes an array of menu items as its only argument.

Expand All @@ -30,4 +30,33 @@ let menuItems = [
Step 5: Don't forget to return your div.menu.

Step 6: Use 'menuMaker' to create a menu using the 'menuItems' array, and append the returned menu to the header.
*/

*/

const header = document.querySelector(".header");

function menuMaker(array) {
const menuBar = document.createElement("div");
const menuItems = document.createElement("ul");

array.forEach((item) => {
let listItem = document.createElement("li");
menuItems.appendChild(listItem);
listItem.textContent = item;
});

menuBar.appendChild(menuItems);

menuBar.classList.add("menu", "menu--open");

const buttonOnMenu = document.querySelector(".menu-button");

buttonOnMenu.addEventListener("click", () => {
menuBar.classList.toggle("menu--open");
});

return menuBar;
}

const menuElements = menuMaker(menuItems);
header.appendChild(menuElements);
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
<html>
<head>
<title>BloomTech Newsfeed</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="./styles/index.less">
<link
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="./styles/index.less" />
<script src="./components/Menu.js" defer></script>
<script src="./components/Article.js" defer></script>
</head>
<body>
<div class="header">
<img class="menu-button" src="./assets/menu.png"/>
<img class="menu-button" src="./assets/menu.png" />
<h1>BloomTech Newsfeed</h1>
</div>
<div class="articles"></div>
Expand Down