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
4 changes: 4 additions & 0 deletions components/Box/Box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Box {
border: 2px solid black;
padding: 0;
}
23 changes: 23 additions & 0 deletions components/Dropdown/Dropdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.Box__headDropTitle {
padding: 10px;
}

.Box__headDropdown {
margin-left: 20px;
position: absolute;
}

.Box__headDropUl {
display: none;
}

.Box__headDropA {
display: block;
text-align: center;
padding: 18px;
}

.Box__headDropdown--expanded {
position: absolute;
background-color: white;
}
9 changes: 9 additions & 0 deletions components/Header/Header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.Box__header {
text-align: center;
display: flex;
align-items: center;
}

.Box__headTitle {
width: 100%;
}
7 changes: 7 additions & 0 deletions components/Section/Section.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.Box__placeholder {
display: flex;
}

.Box__section {
padding: 10px;
}
40 changes: 40 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,47 @@
<head>
<title>Introduction to the DOM</title>
<link rel="stylesheet" href="./styles.css">
<script type="text/javascript" src="./index.js" async></script>
</head>
<body>
<div class="Box">
<div class="Box Box__header">
<div class="Box__headDropdown">
<div class="Box Box__headDropTitle">Dropdown</div>
<div class="Box__headDropdown--expanded">
<ul class="Box Box__headDropUl">
<a class="Box__headDropA" href="#">Lambda</a>
<a class="Box__headDropA" href="#">Google</a>
<a class="Box__headDropA" href="#">MDN</a>
</ul>
</div>
</div>
<h1 class="Box__headTitle">Header</h1>
</div>
<div class="Box__placeholder">
<div class="Box Box__section">
<h3 class="Box__sectionTitle">PlaceHolder</h3>
<p class="Box__sectionText">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="Box Box__section">
<h3 class="Box__sectionTitle">PlaceHolder</h3>
<p class="Box__sectionText">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>
</body>
</hml>
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Set up references to the DOM
const dropdown = document.querySelector(".Box__headDropdown");
const dropUl = document.querySelector(".Box__headDropUl");

//Make dropdown component class
class Dropdown {
constructor(elements, trigger) {
//console.log(elements);
//Expand functionality
trigger.addEventListener('click', () => {
//console.log(elements);
elements.classList.toggle('Box__headDropUl');
});
}
}
//Initialized Event Listener
new Dropdown(dropUl, dropdown);
4 changes: 3 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@import './components/Section/Section.css';
@import './components/Box/Box.css';
@import './components/Header/Header.css';
@import './components/Dropdown/Dropdown.css';
@import './components/Section/Section.css';

body {
box-sizing: border-box;
Expand Down