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
19 changes: 19 additions & 0 deletions components/Box/Box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.Box {
width: 49%;
height: 200px;
border: 2px solid black;
float: left;
margin-right: 0;
}

.Box--2 {
width: 50%;
}

.Box__header {
margin: 20px;
}

.Box__text {
margin: 20px;
}
26 changes: 26 additions & 0 deletions components/Dropdown/Dropdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

.Dropdown__button {
margin-top: 30px;
align-items: center;
min-width: 160px;
height: 30px;
border: 3px solid black;
padding-left: 12px;
padding-top: 5px;
padding-right: 0;
position: absolute;
}

.Dropdown__Menu {
visibility: hidden;
list-style: none;
}

.Dropdown__Menu li {
border: 1px solid black;
background-color: #F9F9F9;
}

.show {
visibility: visible;
}
35 changes: 35 additions & 0 deletions components/Dropdown/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// function myFunction() {
// document.getElementById('myDropdown').classList.toggle('show')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thought process here! I would have also probably used the toggle method as well.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, thank you for commenting out your prior work! I love seeing you progress and make changes. 🔥

// }
// let button = document.querySelector('.Dropdown__button')
// button.onclick = function(event) {
// let dropdowns = document.getElementById('myDropdown')
// console.log(dropdowns)
// dropdowns.classList.toggle('show')
// }

//Refactoring my JS to match what Dan did

class Dropdown {
constructor(element, hideClass) {
this.element = element,
this.clicked = false,
this.child = [...this.element.children].find(child => child.className === hideClass),
this.element.addEventListener('click', () => this.handleClickEvent())
}

// display hidden menu
handleClickEvent() {
if (this.clicked && this.child.classList)this.child.classList.remove('display')
else this.child.classList.add('show')
this.toggleDropdown()
}

// toggle allows the event to turn on/off
toggleDropdown() {
this.clicked = !this.clicked
}
}

// const must be at the bottom in the 'new Class' format
const dropdown = new Dropdown(document.querySelector('.Dropdown'), 'Dropdown__Menu')
14 changes: 14 additions & 0 deletions components/Section/Section.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.Header {
display: flex;
border: 2px solid black;
height: 80px;
justify-content: space-evenly;
flex-direction: row-reverse;
}

.Header__headline {
margin-right: 45%;
margin-left: 400px;
}


44 changes: 41 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
<!DOCTYPE html>
<hml>
<html>
<head>
<title>Introduction to the DOM</title>
<link rel="stylesheet" href="./styles.css">
<link rel="stylesheet" href="./styles.css">
</head>
<body>
<div class="Header">
<script src="components/Dropdown/index.js" async></script>
<h1 class="Header__headline">Header</h1>
<div class="Dropdown">
<h4 class="Dropdown__button">Dropdown</h4>
<ul id="myDropdown" class="Dropdown__Menu">
<li><a href="https://lambdaschool.com/">Lambda School</a></li>
<li><a href="https://www.google.com/">Google</a></li>
<li><a href="https://developer.mozilla.org/en-US/">MDN</a></li>
</ul>
</div>
</div>
<div class="Box">
<div class="Box__header">
<h3 class="Box__headerHeadline">Placeholder</h2>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make thing look something like Box__header--Headline. Just a suggestion but if you will have anything nested, the third element will usually come after --.

Item1__Item2--Item3--Item4 etc

</div>
<div class="Box__text">
<p class="Box__textParagraph">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Fusce risus nibh, gravida nec felis quis, facilisis facilisis lectus. Nulla ac orci pretium,
condimentum orci quis, accumsan nisi. Aliquam erat volutpat. Curabitur cursus mattis libero,
at viverra risus hendrerit quis. Fusce imperdiet tristique tortor non tincidunt. Mauris accumsan
urna nec augue feugiat porta. Proin vitae magna in ex malesuada laoreet eget a nulla. Aliquam tristique
et elit at consequat. In hac habitasse platea dictumst.</p>
</div>
</div>
<div class="Box Box--2">
<div class="Box__header">
<h3 class="Box__headerHeadline">Placeholder</h3>
</div>
<div class="Box__text">
<p class="Box__textParagraph">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Fusce risus nibh, gravida nec felis quis, facilisis facilisis lectus. Nulla ac orci pretium,
condimentum orci quis, accumsan nisi. Aliquam erat volutpat. Curabitur cursus mattis libero,
at viverra risus hendrerit quis. Fusce imperdiet tristique tortor non tincidunt. Mauris accumsan
urna nec augue feugiat porta. Proin vitae magna in ex malesuada laoreet eget a nulla. Aliquam tristique
et elit at consequat. In hac habitasse platea dictumst.</p>
</div>
</div>
</body>
</hml>
</html>
2 changes: 2 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import './components/Section/Section.css';
@import './components/Dropdown/Dropdown.css';
@import './components/Box/Box.css';


body {
box-sizing: border-box;
min-width: 300px;
Expand Down