Skip to content

Commit

Permalink
Add new professor popup
Browse files Browse the repository at this point in the history
  • Loading branch information
AsteroidusTv committed May 5, 2024
1 parent d9408dd commit 886287c
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 2 deletions.
1 change: 1 addition & 0 deletions templates/images/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/images/upload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 22 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- Styles -->
<link rel="stylesheet" href="./styles/styles.css">
<link rel="stylesheet" href="./styles/header.css">

<!-- Standard assets -->
<link rel="stylesheet" href="./styles/standard-assets/button.css">
<link rel="stylesheet" href="./styles/standard-assets/input.css">
<link rel="stylesheet" href="./styles/standard-assets/popup.css">
<link rel="stylesheet" href="./styles/standard-assets/card.css">

<!-- Scripts -->
<script src="./scripts/scripts.js" defer></script>
<script src="./scripts/popup.js" defer></script>

<title>Document</title>
</head>
<body>
Expand All @@ -26,7 +32,7 @@ <h1 class="main-header-title-text2">cl</p>
<img class="main-header-search-img" src="./images/search.png" alt="search icon">
</div>

<button class="standard-button main-header-button">
<button class="standard-button main-header-button" onclick="openPopup('addPopup')">
<p class="main-header-button-text">Ajouter un prof</p>
<img class="main-header-button-img" src="./images/plus.png" alt="plus icon">
</button>
Expand Down Expand Up @@ -124,5 +130,20 @@ <h1 class="standard-card-name">Mathieu Raetz</h1>
<div class="standard-button standard-card-button">Lire les avis</div>
</div>
</main>

<!-- Popups -->
<div id="addPopup" class="standard-popup">
<button class="standard-button standard-popup-close" onclick="closePopup('addPopup')">
<img class="standard-popup-close-img" src="./images/close.svg" alt="close icon">
</button>
<div class="standard-popup-content add-popup">
<div class="select-image">
<input id="uploadPhoto" class="upload-photo" type="file">
<img id="previewImage" class="preview-image" src="./images/upload.png">
</div>
<input class="standard-input insert-name" type="text" placeholder="Entrer un nom">
<button class="standard-button send-request">Envoyer</button>
</div>
</div>
</body>
</html>
30 changes: 30 additions & 0 deletions templates/scripts/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function openPopup(id) {
const popup = document.getElementById(id);
popup.classList.add("show");
localStorage.setItem("openPopupId", id);
}

function closePopup(id) {
const popup = document.getElementById(id);
popup.classList.add("closing");
setTimeout(() => {
popup.classList.remove("show", "closing");
}, 250);
localStorage.removeItem("openPopupId");
}

document.addEventListener("DOMContentLoaded", function() {
const openPopupId = localStorage.getItem("openPopupId");
if (openPopupId) {
openPopup(openPopupId);
}
});

document.addEventListener("keydown", function (event) {
if (event.key === "Escape") {
const popups = document.querySelectorAll(".show");
popups.forEach(function (popup) {
closePopup(popup.id);
});
}
});
15 changes: 15 additions & 0 deletions templates/scripts/scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const imageInput = document.getElementById('uploadPhoto');
const previewImage = document.getElementById('previewImage');

imageInput.addEventListener('change', function(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
previewImage.src = e.target.result;
};
reader.readAsDataURL(file);
} else {
previewImage.src = '#';
}
});
2 changes: 1 addition & 1 deletion templates/styles/standard-assets/input.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
padding-left: 4px;
font-size: 20px;
box-shadow: var(--border-width) var(--border-width) var(--border-color);
text-transform: uppercase;
color: var(--main-color);
background: var(--main-background);

}

.standard-input:focus {
Expand Down
119 changes: 119 additions & 0 deletions templates/styles/standard-assets/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
.standard-popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
align-items: center;
justify-content: center;
min-height: 100vh;
backdrop-filter: blur(5px);
animation: fade-in 250ms ease-in-out;
z-index: 4;
}

.standard-popup.show {
display: flex;
animation: fade-in 250ms;
}

.standard-popup.closing {
animation: fade-out 250ms ease-in-out;
}

.standard-popup-content {
border-radius: var(--border-radius);
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 20px;
overflow-y: hidden;
scrollbar-width: none;
z-index: 5;
}

.standard-popup-content.add-popup {
border: var(--border-width) var(--border-style) var(--border-color);
width: 250px;
height: 330px;
box-shadow: var(--border-width) var(--border-width) var(--border-color);
background: var(--main-background);
}

.standard-popup-close {
height: 40px;
width: 40px;
position: absolute;
display: flex;
justify-content: center;
align-items: center;
z-index: 999;
transform: translate(150px, -190px);
}

.standard-popup-close:focus {
transform: translate(152px, -188px);
}

.standard-popup-close-img {
width: 35px;
}

.select-image {
border: var(--border-width) var(--border-style) var(--border-color);
position: relative;
width: calc(100% - 40px);
height: 200px;
box-shadow: var(--border-width) var(--border-width) var(--border-color);
overflow: hidden;
}

.upload-photo {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
z-index: 7;
}

.preview-image {
width: 100%;
height: 100%;
object-fit: cover;
}



.insert-name, .send-request {
width: calc(100% - 40px);
margin-top: -10px;
}

@keyframes fade-in {
0% {
opacity: 0;
}

100% {
opacity: 1;
}
}

@keyframes fade-out {
0% {
opacity: 1;
}

100% {
opacity: 0;
display: none;
}
}

0 comments on commit 886287c

Please sign in to comment.