Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Subhajit-2023-44 committed Nov 9, 2024
1 parent bbf8b6f commit 6dc43b8
Show file tree
Hide file tree
Showing 4 changed files with 452 additions and 81 deletions.
31 changes: 27 additions & 4 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1146,10 +1146,33 @@ <h3 style="text-align: center; margin-top: 3rem; font-size: 2rem;">Follow Us</h3
<a href="../contributor/contributor.html" title="Contributors">Our Contributors</a>

<!-- Profile Icon -->

<a href="/src/testp.html" class="profile-link" style="display: flex; align-items: center; text-decoration: none;">
<img src="https://i.postimg.cc/tCL5Td4H/gold-membership-icon-default-avatar-profile-icon-membership-icon-social-media-user-image-illustratio.jpg" alt="Profile Icon" style="width: 35px; height: 35px; border-radius: 50%; margin-top: -297px;">
</a>


<a href=".\src\testp.html" class="profile-link" style="display: flex; align-items: center; text-decoration: none;">
<img id="homeProfileImage" src="https://i.postimg.cc/NFFmtc9K/xnz-Mst5-V-400x400.jpg"
alt="Profile Icon"
style="width: 35px; height: 35px; border-radius: 50%; margin-top: -310px;">
</a>




<script>

document.addEventListener("DOMContentLoaded", function() {
// Retrieve the saved avatar from localStorage
const savedAvatar = localStorage.getItem("selectedAvatar");

// If an avatar is saved, update the profile image
if (savedAvatar) {
const homeProfileImage = document.getElementById("homeProfileImage");
if (homeProfileImage) {
homeProfileImage.src = savedAvatar;
}
}
});

</script>


</div>
Expand Down
342 changes: 342 additions & 0 deletions src/profileedit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@
<!DOCTYPE html>
<html lang="en">

<head>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Profile</title>

<link rel="stylesheet" href="style.css">

<style>

body {

font-family: 'Arial', sans-serif;
background-color: #1f2937;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;

}

.container {

background: linear-gradient(135deg, #ead6ee, #a0f1ea);
padding: 20px;
border-radius: 8px;
box-shadow: 50px 50px 50px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 90%;
max-width: 800px;
margin: auto;

}

.edit-profile {

text-align: center;
margin-bottom: 20px;
width: 100%;

}

.edit-profile h3 {

margin-bottom: 10px;
color: #333;
font-size: 24px;

}

.home-link {

display: flex;
align-items: center;
color: rgb(0 0 0);
font-size: 18px;
text-decoration: none;
position: absolute;
margin-left: 20px;

}

.home-link i {

margin-right: 8px;
font-size: 24px;

}

.home-link:hover {

color: #302e2e;

}

.avatar-selection {

text-align: center;
margin-bottom: 20px;

}

.avatars {

display: flex;
justify-content: center;
gap: 20px;
margin-top: 20px;

}

.avatars img {

width: 120px;
height: 120px;
cursor: pointer;
border: 4px solid transparent;
border-radius: 50%;
transition: transform 0.3s ease-in-out, border-color 0.3s ease-in-out;

}

.avatars img:hover {

transform: scale(1.1);

}

.avatars img.selected {

border-color: #077183;

}

.profile-details {

text-align: center;
margin-bottom: 20px;
width: 100%;

}

.profile-details h4 {

margin-bottom: 10px;
color: #333;
font-size: 20px;

}

.profile-details input {

width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
box-sizing: border-box;

}

.save-button {

background: linear-gradient(135deg, #079874, #076887);
color: #fff;
border: none;
padding: 10px 20px;
font-size: 18px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease-in-out, transform 0.2s ease-in-out;
margin-top: 20px;

}

.save-button:hover {

background: linear-gradient(135deg, #079874, #076887);
transform: scale(1.05);

}

.save-button:focus {

outline: none;

}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

* {

margin: 0;
padding: 0;
box-sizing: border-box;

}

.container {

max-width: 1170px;
margin: auto;

}

.row {

display: flex;
flex-wrap: wrap;

}

ul {

list-style: none;

}

</style>

</head>

<body>

<div class="container">
<div class="edit-profile">
<!-- Home Link -->
<a href="../../index.html" class="home-link">
<i class='bx bx-home'></i> Home
</a>

<h3>Edit Profile</h3>
</div>

<div class="avatar-selection">
<h4>Select Avatar</h4>
<div class="avatars">
<img src="https://i.postimg.cc/VvvM4LLK/4140061.png" onclick="selectAvatar('https://i.postimg.cc/VvvM4LLK/4140061.png')" />
<img src="https://i.postimg.cc/g0yv2TTH/6833605.png" onclick="selectAvatar('https://i.postimg.cc/g0yv2TTH/6833605.png')" />
<img src="https://i.postimg.cc/NFFmtc9K/xnz-Mst5-V-400x400.jpg" onclick="selectAvatar('https://i.postimg.cc/NFFmtc9K/xnz-Mst5-V-400x400.jpg')" />
<img src="https://i.postimg.cc/rwKwFnfR/4139967.png" onclick="selectAvatar('https://i.postimg.cc/rwKwFnfR/4139967.png')" />
<img src="https://i.postimg.cc/dQNG3d4p/6997484.png" onclick="selectAvatar('https://i.postimg.cc/dQNG3d4p/6997484.png')" />
</div>
</div>

<div class="profile-details">
<h4>Edit Details</h4>
<input type="text" id="nameInput" placeholder="Enter Name" required required pattern="[a-zA-Z ]+" oninvalid="this.setCustomValidity('Numbers and Symbols are not allowed')" oninput="this.setCustomValidity('')">
<input type="email" id="emailInput" placeholder="Enter Email" required>
<input type="tel" id="phoneInput" placeholder="Enter Phone" required>
<input type="text" id="bioInput" placeholder="Add Bio" maxlength="150" required>
</div>
<button class="save-button" onclick="saveProfile()">Save Profile</button>
</div>

<script>

let selectedAvatar = "";

function selectAvatar(avatarSrc) {

const avatars = document.querySelectorAll('.avatars img');
avatars.forEach(img => {
img.classList.remove('selected');
});
const selectedImg = Array.from(avatars).find(img => img.src === avatarSrc);
if (selectedImg) {
selectedImg.classList.add('selected');
selectedAvatar = avatarSrc;
}

}

function saveProfile() {

const newName = document.getElementById("nameInput").value.trim();
const newEmail = document.getElementById("emailInput").value.trim();
const newPhone = document.getElementById("phoneInput").value.trim();
const newBio = document.getElementById("bioInput").value.trim();

// Check if all fields are valid before proceeding
if (!nameInput.checkValidity() || !emailInput.checkValidity() || !phoneInput.checkValidity()) {
nameInput.reportValidity();
emailInput.reportValidity();
phoneInput.reportValidity();
bioInput.reportValidity();
return; // Stop function execution if invalid
}

if (newEmail && !validateEmail(newEmail)) {
alert("Invalid email address");
return;
}

if (selectedAvatar) {
localStorage.setItem("selectedAvatar", selectedAvatar);
}
if (newName) {
localStorage.setItem("profileName", newName);
}
if (newEmail) {
localStorage.setItem("profileEmail", newEmail);
}
if (newPhone) {
localStorage.setItem("profilePhone", newPhone);
}
if (newBio) {
localStorage.setItem("profileBio", newBio);
}

// Redirect to the profile page
window.location.href = "testp.html"; // Change made here
}

function validateEmail(email) {
const re = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return re.test(email);
}

document.addEventListener("DOMContentLoaded", () => {
const savedAvatar = localStorage.getItem("selectedAvatar");
if (savedAvatar) {
const selectedImg = Array.from(document.querySelectorAll('.avatars img')).find(img => img.src === savedAvatar);
if (selectedImg) {
selectedImg.classList.add('selected');
selectedAvatar = savedAvatar;
}
}

const savedName = localStorage.getItem("profileName");
const savedEmail = localStorage.getItem("profileEmail");
const savedPhone = localStorage.getItem("profilePhone");
const savedBio = localStorage.getItem("profileBio");

if (savedName) {
document.getElementById("nameInput").value = savedName;
}
if (savedEmail) {
document.getElementById("emailInput").value = savedEmail;
}
if (savedPhone) {
document.getElementById("phoneInput").value = savedPhone;
}
if (savedBio) {
document.getElementById("bioInput").value = savedBio;
}
});

</script>

</body>

</html>
Loading

0 comments on commit 6dc43b8

Please sign in to comment.