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

Update Sidebar Toggle Functionality and Sidebar position updated #333

Merged
merged 2 commits into from
Oct 13, 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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ <h2>Contact Us</h2>
</ul>
</div>
<div class="toggle-arrow" onclick="toggleSidebar()" title="Open Sidebar" style="display: none;">
<i class="fas fa-arrow-right"></i>
<i class="fas fa-arrow-left"></i>
</div>


Expand Down
18 changes: 11 additions & 7 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ window.onload = () => {

//function to remove sidebar upon clicking close button
function toggleSidebar() {
var sidebar = document.getElementById("SideBar");
var sidebarContent = document.getElementById("sidebar-content");
if (sidebar) {
// Remove the sidebar element and its content
sidebar.remove();
sidebarContent.remove();
const sidebar = document.querySelector('.social-sidebar');
const toggleArrow = document.querySelector('.toggle-arrow');

// Check if the sidebar is currently visible
if (sidebar.style.display === "none") {
// If hidden, show the sidebar and hide the toggle arrow
sidebar.style.display = "block";
toggleArrow.style.display = "none";
} else {
console.error("Sidebar element not found");
// If visible, hide the sidebar and show the toggle arrow
sidebar.style.display = "none";
toggleArrow.style.display = "block";
}
}

Expand Down
13 changes: 7 additions & 6 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ button:hover img {
.close-btn {
position: absolute;
top: -10px;
right: -10px;
left: -10px;
width: 25px;
height: 25px;
font-size: 20px;
Expand All @@ -730,29 +730,30 @@ button:hover img {
.toggle-arrow {
position: fixed;
top: 50%;
left: 0;
right: 0;
transform: translateY(-50%);
transition: transform 0.3s ease-in-out;
background-color: #333;
padding: 5px;
border-radius: 0 10px 10px 0;
border-radius: 10px 0 0 10px;
cursor: pointer;
color: white;
font-size: 25px;
padding: 12px;
z-index: 1;
}


.social-sidebar {
position: fixed;
top: 55%;
left: 0;
right: 0;
transform: translateY(-50%);
display: flex;
flex-direction: column;
gap: 15px;
background-color: #333;
padding: 3px;
border-radius: 0 15px 15px 0;
border-radius: 15px 0 0 15px;
border: none;
transition: background-color 0.3s ease, transform 0.3s ease;
z-index: 1;
Expand Down