Enhance sidebar functionality and responsiveness with new toggle features
This commit is contained in:
parent
50d243288c
commit
8d0ccbece5
39
index.html
39
index.html
|
@ -804,6 +804,16 @@
|
||||||
background-color: var(--accent-color);
|
background-color: var(--accent-color);
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@media (min-width: 400px) and (max-width: 1920px) {
|
||||||
|
.content-wrapper.closed-sidebar {
|
||||||
|
padding-left: 0px;
|
||||||
|
padding-right: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.content-wrapper {
|
.content-wrapper {
|
||||||
|
@ -813,8 +823,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-sticky {
|
.sidebar-sticky {
|
||||||
|
position: absolute;
|
||||||
|
top: 50px;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
background: #00000050;
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#closeFooter {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-sticky.closed {
|
||||||
|
transform: translateX(-600px);
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -823,6 +848,10 @@
|
||||||
border-bottom: 1px solid #e1e4e8;
|
border-bottom: 1px solid #e1e4e8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar.closed {
|
||||||
|
transform: translateX(-600px);
|
||||||
|
}
|
||||||
|
|
||||||
.dark-mode .sidebar {
|
.dark-mode .sidebar {
|
||||||
border-bottom-color: #2d2d2d;
|
border-bottom-color: #2d2d2d;
|
||||||
}
|
}
|
||||||
|
@ -831,8 +860,8 @@
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.site-header {
|
.site-header {
|
||||||
--site-header-height: 120px;
|
|
||||||
height: var(--site-header-height);
|
height: var(--site-header-height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1567,10 +1596,10 @@
|
||||||
|
|
||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<div class="prompt-count" id="promptCount">
|
<div class="prompt-count" id="promptCount">
|
||||||
<span class="count-label">All Prompts</span>
|
<span class="count-label">All Prompts</span>
|
||||||
<span class="prompts-count-label">Developer Prompts</span>
|
<span class="prompts-count-label">Developer Prompts</span>
|
||||||
<span class="count-number">0</span>
|
<span class="count-number">0</span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" id="searchInput" placeholder="Search prompts...">
|
<input type="text" id="searchInput" placeholder="Search prompts...">
|
||||||
<ul id="searchResults"></ul>
|
<ul id="searchResults"></ul>
|
||||||
|
|
44
script.js
44
script.js
|
@ -13,6 +13,17 @@ function toggleDarkMode() {
|
||||||
moonIcon.style.display = isDarkMode ? "block" : "none";
|
moonIcon.style.display = isDarkMode ? "block" : "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sidebar = document.querySelector('.sidebar');
|
||||||
|
const sidebarSticky = document.querySelector('.sidebar-sticky');
|
||||||
|
const footer = document.querySelector('.site-footer');
|
||||||
|
const contentWrapper = document.querySelector('.content-wrapper');
|
||||||
|
const collapsedSiderIcon = document.querySelector('.collapsed-sider-icon');
|
||||||
|
const expandedSiderIcon = document.querySelector('.expanded-sider-icon');
|
||||||
|
const closeSidebar = document.getElementById('closeSidebar');
|
||||||
|
const closeFooter = document.getElementById('closeFooter');
|
||||||
|
const collapsedFooterIcon = document.querySelector('.collapsed-footer-icon');
|
||||||
|
const expandedFooterIcon = document.querySelector('.expanded-footer-icon');
|
||||||
|
|
||||||
function updateHeaderHeight() {
|
function updateHeaderHeight() {
|
||||||
const siteHeader = document.querySelector('.site-header');
|
const siteHeader = document.querySelector('.site-header');
|
||||||
if (!siteHeader) return; // Eğer element yoksa hata vermemesi için
|
if (!siteHeader) return; // Eğer element yoksa hata vermemesi için
|
||||||
|
@ -32,29 +43,25 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
devModeToggle.checked = initialDevMode;
|
devModeToggle.checked = initialDevMode;
|
||||||
|
|
||||||
// Initialize sidebar toggle
|
// Initialize sidebar toggle
|
||||||
const sidebar = document.querySelector('.sidebar');
|
if (window.innerWidth <= 768) {
|
||||||
const footer = document.querySelector('.site-footer');
|
sidebar.classList.toggle('closed');
|
||||||
const contentWrapper = document.querySelector('.content-wrapper');
|
sidebarSticky.classList.toggle('closed');
|
||||||
const collapsedSiderIcon = document.querySelector('.collapsed-sider-icon');
|
}
|
||||||
const expandedSiderIcon = document.querySelector('.expanded-sider-icon');
|
|
||||||
const closeSidebar = document.getElementById('closeSidebar');
|
|
||||||
const closeFooter = document.getElementById('closeFooter');
|
|
||||||
const collapsedFooterIcon = document.querySelector('.collapsed-footer-icon');
|
|
||||||
const expandedFooterIcon = document.querySelector('.expanded-footer-icon');
|
|
||||||
|
|
||||||
closeSidebar.addEventListener('click', () => {
|
closeSidebar.addEventListener('click', () => {
|
||||||
contentWrapper.classList.toggle('closed-sidebar');
|
contentWrapper.classList.toggle('closed-sidebar');
|
||||||
sidebar.classList.toggle('closed');
|
sidebar.classList.toggle('closed');
|
||||||
|
sidebarSticky.classList.toggle('closed');
|
||||||
collapsedSiderIcon.classList.toggle('hidden');
|
collapsedSiderIcon.classList.toggle('hidden');
|
||||||
expandedSiderIcon.classList.toggle('hidden');
|
expandedSiderIcon.classList.toggle('hidden');
|
||||||
});
|
});
|
||||||
|
|
||||||
closeFooter.addEventListener('click', () => {
|
closeFooter.addEventListener('click', () => {
|
||||||
contentWrapper.classList.toggle('closed-footer');
|
contentWrapper.classList.toggle('closed-footer');
|
||||||
footer.classList.toggle('closed');
|
footer.classList.toggle('closed');
|
||||||
collapsedFooterIcon.classList.toggle('hidden');
|
collapsedFooterIcon.classList.toggle('hidden');
|
||||||
expandedFooterIcon.classList.toggle('hidden');
|
expandedFooterIcon.classList.toggle('hidden');
|
||||||
});
|
});
|
||||||
// Initialize chat button icons
|
// Initialize chat button icons
|
||||||
updateChatButtonIcons(initialDevMode);
|
updateChatButtonIcons(initialDevMode);
|
||||||
|
|
||||||
|
@ -280,6 +287,11 @@ function displaySearchResults(results) {
|
||||||
searchTitle.toLowerCase().includes(cardTitle.toLowerCase());
|
searchTitle.toLowerCase().includes(cardTitle.toLowerCase());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (window.innerWidth <= 768) {
|
||||||
|
sidebar.classList.toggle('closed');
|
||||||
|
sidebarSticky.classList.toggle('closed');
|
||||||
|
}
|
||||||
|
|
||||||
if (targetCard) {
|
if (targetCard) {
|
||||||
// Remove highlight from all cards
|
// Remove highlight from all cards
|
||||||
cards.forEach((card) => {
|
cards.forEach((card) => {
|
||||||
|
@ -306,7 +318,7 @@ function displaySearchResults(results) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// On desktop, scroll the main-content container
|
// On desktop, scroll the main-content container
|
||||||
const mainContent = document.querySelector(".main-content");
|
const mainContent = document.querySelector("html");
|
||||||
const cardRect = targetCard.getBoundingClientRect();
|
const cardRect = targetCard.getBoundingClientRect();
|
||||||
const scrollTop = mainContent.scrollTop + cardRect.top -
|
const scrollTop = mainContent.scrollTop + cardRect.top -
|
||||||
headerHeight - 20;
|
headerHeight - 20;
|
||||||
|
|
Loading…
Reference in New Issue