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

Improved the UI and Conformation pop-up #342

Merged
merged 1 commit into from
Jul 1, 2024
Merged
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
133 changes: 103 additions & 30 deletions edit-profile.html
Original file line number Diff line number Diff line change
@@ -1,45 +1,118 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<head>
<meta charset="UTF-8" />
<title>Profile Dropdown and Edit Profile</title>
<link rel="stylesheet" href="profile.css">
</head>
<link rel="stylesheet" href="profile.css" />
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Include SweetAlert2 library -->
</head>

<body>
<body>
<header class="header">
<a href="index.html">About Us</a>
<div class="profile-menu">
<button class="profile-btn">
<img src="./images/profilepic.jpg" class="profile-pic" id="main-profile-pic">
</button>
<div class="dropdown-content">
<a href="edit-profile.html" id="edit-profile-link">Edit Profile</a>
<a href="#" id="dropdown-settings-link">Settings</a>
<a href="check-progress.html" id="check-progress">Check Progress</a>
<a href="#">Exit</a>
<a href="#">Sign Out</a>
</div>
<a href="index.html">About Us</a>
<div class="profile-menu">
<button class="profile-btn">
<img
src="./images/profilepic.jpg"
class="profile-pic"
id="main-profile-pic"
/>
</button>
<div class="dropdown-content">
<a href="edit-profile.html" id="edit-profile-link">Edit Profile</a>
<a href="#" id="dropdown-settings-link">Settings</a>
<a href="check-progress.html" id="check-progress">Check Progress</a>
<a href="#">Exit</a>
<a href="#">Sign Out</a>
</div>
</div>
</header>

<!-- Edit Profile Form -->
<div id="edit-profile-form">
<h1>Edit Profile</h1>
<p>You are playing as a guest now, add details to identify you.</p>
<form id="edit-profile">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<h1>Edit Profile</h1>
<p>You are playing as a guest now, add details to identify you.</p>
<form id="edit-profile">
<label for="name">Name:</label>
<input type="text" id="name" name="name" />

<label for="profile-pic">Profile Picture:</label>
<input type="file" id="profile-pic" name="profile-pic" accept="image/*">
<label for="profile-pic">Profile Picture:</label>
<input
type="file"
id="profile-pic"
name="profile-pic"
accept="image/*"
/>

<button type="submit">Save</button>
</form>
<button type="submit">Save</button>
</form>
</div>

<script src="profile.js"></script>
</body>
<script>
function submitProfile(event) {
event.preventDefault(); // Prevent default form submission

// Get form elements
var name = document.getElementById("name").value.trim();
var profilePic = document.getElementById("profile-pic").files[0];

// Check if the name is empty
if (name === "") {
// Show a SweetAlert error modal
Swal.fire({
icon: "error",
title: "Oops...",
text: "Please enter your name before submitting.",
customClass: {
popup: "swal-popup",
title: "swal-title",
content: "swal-content",
confirmButton: "swal-confirm-button",
},
});
return; // Exit the function if the name is empty
}

// Check if a profile picture is selected
if (!profilePic) {
Swal.fire({
icon: "error",
title: "Oops...",
text: "Please select a profile picture before submitting.",
customClass: {
popup: "swal-popup",
title: "swal-title",
content: "swal-content",
confirmButton: "swal-confirm-button",
},
});
return;
}

// Show a success message
Swal.fire({
icon: "success",
title: "Success!",
text: "Your profile has been updated.",
customClass: {
popup: "swal-popup",
title: "swal-title",
content: "swal-content",
confirmButton: "swal-confirm-button",
},
}).then((result) => {
// Clear the profile form after the user acknowledges the success modal
if (result.isConfirmed || result.isDismissed) {
document.getElementById("edit-profile").reset();
}
});
}

</html>
// Attach the submitProfile function to the form's submit event
document
.getElementById("edit-profile")
.addEventListener("submit", submitProfile);
</script>
</body>
</html>
92 changes: 73 additions & 19 deletions profile.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
/* Your existing CSS styles */
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:[email protected]&display=swap");

body {
font-family: "Space Grotesk", sans-serif;
background-image: url("https://png.pngtree.com/thumb_back/fh260/background/20210728/pngtree-purple-rubiks-cube-holographic-floating-geometric-abstract-background-image_752595.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
margin: 0;
padding: 0;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
}

.header {
Expand All @@ -11,6 +22,38 @@ body {
padding: 10px 20px;
color: #333;
z-index: 10;
background-color: rgba(194, 190, 190, 0.4);
width: 100%;
height: 60px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
position: fixed;
top: 0;
left: 0;
}

/* Button style for About Us link */
.header a {
display: inline-block;
padding: 10px 20px;
background: linear-gradient(rgb(231, 231, 246), rgb(180, 180, 249));
color: rgb(7, 6, 6);
text-decoration: none;
border: 2px solid #000000;
border-radius: 10px;
font-weight: bold;
transition: background-color 0.3s, transform 0.3s, box-shadow 0.3s;
box-shadow: 3px 3px 0px 0px #b3aaf7;
}

.header a:hover {
background-color: #2b74bc;
transform: translateY(-2px);
box-shadow: 5px 5px 0px 0px #090915;
}

.header a:active {
transform: translateY(1px);
box-shadow: 2px 2px 0px 0px #e99f4c;
}

.profile-menu {
Expand All @@ -22,13 +65,14 @@ body {
.profile-btn {
background-color: transparent;
border: none;
color: white;
color: rgb(10, 10, 10);
padding: 10px;
border-radius: 50%;
cursor: pointer;
outline: none;
width: 3rem;
height: 3rem;
width: 4rem;
height: 4rem;
margin-right: 80px;
}

.profile-pic {
Expand All @@ -41,15 +85,16 @@ body {
display: none;
position: absolute;
right: 0;
background-color: #f9f9f9;
background-color: transparent;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 12;
border-radius: 5px;
margin-right: 30px;
}

.dropdown-content a {
color: black;
padding: 12px 16px;
padding: 10px 30px;
text-decoration: none;
display: block;
}
Expand All @@ -65,50 +110,59 @@ body {
/* Styles for the edit profile form */

#edit-profile-form {
display: auto;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
background-color: #faeac9;
opacity: 0.6;
background-image: url("https://t4.ftcdn.net/jpg/03/30/27/41/360_F_330274196_C6mjMdPaTggBr4Jg45faWAwViexh7DoA.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
border-radius: 5px;
max-width: 400px;
margin: 20px auto;
border: 2px solid #264143;
margin-top: 180px; /* Adjust margin-top to create space below the header */
border: 2px solid #0a0b0b;
border-radius: 20px;
box-shadow: 10px 8px 0px 2px #e94c4c;
box-shadow: 10px 8px 0px 2px #0a0808;
backdrop-filter: blur(10px);
}

#edit-profile-form label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #000000;
}

#edit-profile-form input[type="text"],
#edit-profile-form input[type="file"] {
width: 85%;
padding: 8px;
background: #f1f1f1;
background: #ebedf0;
margin-bottom: 10px;
border: 1.5px solid #000000;
transform: translateY(4px);
box-shadow: 1px 2px 0px 0px #e99f4c;
box-shadow: 1px 2px 0px 0px #080604;
color: #000000;
border-radius: 3px;
}

#edit-profile-form button {
padding: 10px 20px;
background-color: #007bff;
background-color: #2d8ef6;
border: 1.5px solid #000000;
color: white;
border-radius: 3px;
color: rgb(13, 13, 13);
border-radius: 10px;
cursor: pointer;
margin-top: 15px;
border-radius: 10px;
font-weight: 800;
box-shadow: 3px 3px 0px 0px #e99f4c;
box-shadow: 3px 3px 0px 0px #0f0b07;
}

#edit-profile-form button:hover {
background-color: rgba(0, 123, 255, 0.8);
background-color: rgba(4, 4, 4, 0.8);
color: white;
border: 1.5px solid #000000;
box-shadow: 6px 6px 0px 0px #e99f4c;
box-shadow: 6px 6px 0px 0px #0f0b05;
}
Loading