Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished skills assessment #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
91 changes: 91 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="phone-container">
<header class="phone-header">
<h1 class="phone-title">Contacts</h1>
</header>
<main class="phone-contact-container" id="phone-contact-container">
<div id="overlay" class="overlay"></div>
<div class="phone-contact">
<div class="contact-name green">Christian</div>
<div class="contact-info">
<div class="contact-email">[email protected]</div>
<div class="contact-phone hidden">323-555-1234</div>
<div class="contact-address hidden">6539 Wilton AVe.<br> Culver City CA 90234</div>
</div>
</div>
<div class="phone-contact">
<div class="contact-name green">Rich</div>
<div class="contact-info">
<div class="contact-email">[email protected]</div>
<div class="contact-phone hidden">323-555-1234</div>
<div class="contact-address hidden">6538 Wilton AVe.<br> Culver City CA 90234</div>
</div>
</div>
<div class="phone-contact">
<div class="contact-name green">Scott</div>
<div class="contact-info">
<div class="contact-email">[email protected]</div>
<div class="contact-phone hidden">323-555-1234</div>
<div class="contact-address hidden">6537 Wilton AVe.<br> Culver City CA 90234</div>
</div>
</div>
<div class="phone-contact">
<div class="contact-name green">Danny</div>
<div class="contact-info">
<div class="contact-email">[email protected]</div>
<div class="contact-phone hidden">323-555-1234</div>
<div class="contact-address hidden">6536 Wilton AVe.<br> Culver City CA 90234</div>
</div>
</div>
<div class="phone-contact">
<div class="contact-name red">Taka</div>
<div class="contact-info">
<div class="contact-email">[email protected]</div>
<div class="contact-phone hidden">323-555-1234</div>
<div class="contact-address hidden">6535 Wilton AVe.<br> Culver City CA 90234</div>
</div>
</div>
<div class="phone-contact">
<div class="contact-name yellow">Tim</div>
<div class="contact-info">
<div class="contact-email">[email protected]</div>
<div class="contact-phone hidden">323-555-1234</div>
<div class="contact-address hidden">6534 Wilton AVe.<br> Culver City CA 90234</div>
</div>
</div>
<div class="phone-contact">
<div class="contact-name green">Patrick</div>
<div class="contact-info">
<div class="contact-email">[email protected]</div>
<div class="contact-phone hidden">323-555-1234</div>
<div class="contact-address hidden">6533 Wilton AVe.<br> Culver City CA 90234</div>
</div>
</div>
<div class="phone-contact">
<div class="contact-name yellow">Jacques</div>
<div class="contact-info">
<div class="contact-email">[email protected]</div>
<div class="contact-phone hidden">323-555-1234</div>
<div class="contact-address hidden">6532 Wilton AVe.<br> Culver City CA 90234</div>
</div>
</div>
</main>
<footer class="phone-footer">
<select class="contact-sort-type" name="sort" id="sort">
<option value="email">Email address</option>
<option value="phone">Phone number</option>
</select>
</footer>
</div>
<script type="module" defer async src="main.js"></script>
</body>
</html>
48 changes: 48 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const contacts = document.querySelectorAll('.contact-info');
const overlay = document.getElementById('overlay');
const contactContainer = document.getElementById('phone-contact-container');
const sort = document.getElementById('sort');

overlay.addEventListener('click', e => {
e.stopPropagation();
e.target.classList.remove('show');
contacts.forEach(e => {
e.parentElement.classList.remove('selected');
Array.from(e.children).forEach((child, index) => {
if(index !== 0){
child.classList.add('hidden');
}
if(child.classList.contains('contact-email')){
const strippedString = child.innerHTML.replace(/(<([^>]+)>)/gi, "");
child.innerHTML = strippedString;
}
});
});
})

contactContainer.addEventListener('click', e => {
const contact = e.target.closest('.phone-contact');
const contactInfo = contact.querySelector('.contact-info');
overlay.classList.add('show');
contact.classList.add('selected');
Array.from(contactInfo.children).forEach(child => {
child.classList.remove('hidden');
if(child.classList.contains('contact-email')){
const innerHtml = child.innerHTML;
child.innerHTML = `<a href="#">${innerHtml}</a>`;
}

});
});

sort.addEventListener('change', selectEvent => {
contacts.forEach(e => {
if(!e.firstElementChild.classList.contains(`contact-${selectEvent.target.value}`)){
let target = e.querySelector(`.contact-${selectEvent.target.value}`);
target.classList.remove('hidden');
target.remove();
e.insertAdjacentElement('afterbegin', target);
e.children[1].classList.add('hidden');
}
});
});
187 changes: 187 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
:root {
--header-grey: #313131;
--row-light-grey: #212121;
--row-dark-grey: #1A1A1A;
--green: #07FD1C;
--red: #FF020A;
--yellow: #FFF801;
--blue-font: #05EDF9;
--muted-font: gray;
--selected-background: dimgray;
}

* {
box-sizing: border-box;
}

body {
margin: 0px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
width: 100vw;
color: #fff;
font-family: Arial, Helvetica, sans-serif;
}

a {
color: var(--blue-font);
}

.phone-container {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
border-radius: 12px;
max-width: 320px;
width: 100%;
-webkit-box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
-moz-box-shadow: rgba(0,0,0,0.3) 0 1px 3px;
box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px;
position: relative;
}

.phone-container .overlay{
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.6);
z-index: 0;
}

.phone-container .overlay.show{
z-index: 2;
}

.phone-container .phone-header {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
background-color: var(--header-grey);
width: 100%;
border-top-right-radius: 12px;
border-top-left-radius: 12px;
padding: 0px 24px;
height: 60px;
}

.phone-container .phone-header .phone-title {
font-size: 24px;
}

.phone-container .phone-contact-container {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
width: 100%;
position: relative;
overflow-x: hidden;
background-color: var(--row-dark-grey);
}

.phone-container .phone-contact-container .phone-contact {
display: flex;
flex-direction: row;
width: 100%;
align-items: flex-start;
justify-content: space-between;
border-top: solid 1px black;
position: relative;
z-index: 1;
}

.phone-container .phone-contact-container .phone-contact.selected {
z-index: 3;
background-color: var(--selected-background);
}

.phone-contact-container .phone-contact:nth-child(even) {
background: var(--row-light-grey);
}
.phone-contact-container .phone-contact:nth-child(odd) {
background: var(--row-dark-grey);
}

.phone-container .phone-contact-container .phone-contact .contact-name {
padding: 8px 16px 8px 16px;
border-right: solid 1px black;
width: 50%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
font-size: 15px;
}

.phone-container .phone-contact-container .phone-contact .contact-name::before {
width:8px;
height:8px;
border-radius:50%;
content: "";
margin-right: 12px;
}

.phone-container .phone-contact-container .phone-contact .contact-name.red::before {
background: var(--red);
}

.phone-container .phone-contact-container .phone-contact .contact-name.green::before {
background: var(--green);
}

.phone-container .phone-contact-container .phone-contact .contact-name.yellow::before {
background: var(--yellow);
}

.phone-container .phone-contact-container .phone-contact .contact-info {
display: flex;
flex-direction: column;
width: 100%;
align-items: flex-start;
justify-content: center;
padding: 8px 0px 8px 16px;
color: var(--muted-font);
font-size: 14px;
}

.phone-container .phone-contact-container .phone-contact.selected .contact-info {
position: absolute;
top: 0px;
left: 35%;
background-color: dimgray;
color: white;
background-color: var(--selected-background);
}

.phone-container .phone-contact-container .phone-contact .contact-info .contact-email {
margin-bottom: 8px;
}

.phone-container .phone-contact-container .phone-contact .contact-info .contact-phone {
margin-bottom: 8px;
}

.phone-footer {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
background-color: var(--header-grey);
width: 100%;
height: 50px;
border-bottom-right-radius: 12px;
border-bottom-left-radius: 12px;
padding: 0px 24px;
}

.hidden {
display: none;
}