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
17 changes: 17 additions & 0 deletions components/Box/Box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

.Block {
padding: 10px;
border: 1px solid black;
}
.Block__H {
padding: 5px;
}
.Block__Header {
margin-bottom: 10px;
font-weight: bold;
font-size: 20px;
}

.Block__Text {
line-height: 1.3;
}
33 changes: 33 additions & 0 deletions components/Dropdown/Dropdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.Dropdown {
position: absolute; /* keeps dropdown going down*/
padding-top: 45px;
padding-left: 15px;
cursor: pointer;
}

.Dropdown__Title {
padding: 10px;
border: 2px solid black;
}

.Dropdown__List {
margin-top: 10px;
padding: 10px;
display: none;
flex-direction: column;
line-height: 2;
width: 78px;
background: white;
border: 2px solid black;
}

.display {
display: flex;
align-self: center;
}

@media (max-width: 600px) {
.Dropdown {
padding: 20px 0 0 20px;
}
}
21 changes: 21 additions & 0 deletions components/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

class Dropdown {
constructor(element, hideClass) {
this.element = element, // 1st step w js element functions
this.clicked = false, // the default Boolean value is false-on is true
this.child = [...this.element.children].find(child => child.className === hideClass),
this.element.addEventListener('click', () => this.handleClickEvent())
}
// element function causing the class list to display if it is not displayed
handleClickEvent() {
if (this.clicked && this.child.classList) this.child.classList.remove('display')
else this.child.classList.add('display')
this.toggleDropdown()
}
// toggle allows the event to be turned off and therefore repeated
toggleDropdown() {
this.clicked = !this.clicked
}
}
// const must be displayed at the bottom here and in this 'assign New Class' format
const dropdown = new Dropdown(document.querySelector('.Dropdown'),'Dropdown__List')
9 changes: 9 additions & 0 deletions components/Section/Section.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.Section {
display: flex;
}

@media (max-width: 600px) {
.Section {
flex-direction: column;
}
}
38 changes: 38 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
<!DOCTYPE html>
<!-- js script added with dropdown; block titles with layered div column layout to organize boxes;
added folders and files to main project folder; all addiitonal css files are imported in the styles.css -->
<hml>

<head>
<title>Introduction to the DOM</title>
<link rel="stylesheet" href="./styles.css">
<script defer="defer" src="./index.js"></script>
</head>
<body>
<div class="Block Block__H">
<script async src="components/Dropdown/Dropdown.js"></script>
<div class="Dropdown">
<div class="Dropdown__Title">Dropdown</div>
<div class="Dropdown__List">
<a href="#">Lambda</a>
<a href="#">Google</a>
<a href="#">MDN</a>
</div>
</div>
<h3>Header</h3>
</div>
<div class="Section">
<div class="Block">
<h4 class="Block__Header">Placeholder</h4>
<p class="Block__Text">
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 class="Block">
<h4 class="Block__Header">Placeholder</h4>
<p class="Block__Text">
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>
14 changes: 14 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
@import './components/Section/Section.css';
@import './components/Box/Box.css';
@import './components/Header/Header.css';
@import './components/Dropdown/Dropdown.css';

body {
box-sizing: border-box;
min-width: 300px;
margin: 0;
}
h3 {
font-weight: bold;
text-align: center;
font-size: 40px;
}

@media (max-width: 600px) {
.Header {
font-size: 32px;

}
}