Skip to content

Commit fa916ff

Browse files
[docs] Move theme toggle (sun icon) into header (#2090)
**Link the Issue(s) this Pull Request is related to.** Fixes #1894 **Summarize your change.** Modified header_custom.html file to append the theme button element to aux-nav-list instead of directly to the document body. This improves visibility. <img width="1165" height="339" alt="Screenshot 2025-12-02 at 11 31 27 PM" src="https://github.com/user-attachments/assets/a1c99a3c-fae1-4c11-872c-0833389778c2" /> <!-- For a step-by-step list to walk you through the pull request process, see https://www.opencue.io/contributing/. Please add unit tests for any new code. This helps our project maintain code quality and ensure future changes don't break anything. If you're stuck on this or not sure how to proceed, feel free to create a Draft Pull Request and ask one of the OpenCue committers for advice. --> [docs] Fix theme toggle issues from header migration - Add null check for aux-nav-list to prevent TypeError - Remove orphaned CSS properties (top, right, align-items, gap) that had no effect without position:fixed and display:flex - Fix typos in comments - Update function comment to reflect new behavior --------- Signed-off-by: silvialpz <[email protected]> Signed-off-by: Ramon Figueiredo <[email protected]> Co-authored-by: Ramon Figueiredo <[email protected]>
1 parent 5e374a8 commit fa916ff

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

docs/_includes/header_custom.html

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,8 +2423,8 @@
24232423
});
24242424
}
24252425

2426-
// Add theme toggle button as floating button
2427-
function addThemeToggleToMainArea() {
2426+
// Add theme toggle button to auxiliary navigation
2427+
function addThemeToggleToAuxNav() {
24282428
if (!document.getElementById('main-theme-toggle')) {
24292429
const themeButton = document.createElement('button');
24302430
themeButton.id = 'main-theme-toggle';
@@ -2434,10 +2434,6 @@
24342434

24352435
// Style the button to be clearly visible
24362436
themeButton.style.cssText = `
2437-
position: fixed !important;
2438-
top: 80px !important;
2439-
right: calc(50% - 440px) !important;
2440-
z-index: 9999 !important;
24412437
background: #6b7280 !important;
24422438
color: white !important;
24432439
border: none !important;
@@ -2446,9 +2442,6 @@
24462442
font-size: 16px !important;
24472443
cursor: pointer !important;
24482444
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
2449-
display: flex !important;
2450-
align-items: center !important;
2451-
gap: 8px !important;
24522445
font-weight: 500 !important;
24532446
transition: all 0.2s ease !important;
24542447
white-space: nowrap !important;
@@ -2481,8 +2474,19 @@
24812474
updateMainThemeButton();
24822475
updateNavigationThemeLink();
24832476
});
2484-
2485-
document.body.appendChild(themeButton);
2477+
2478+
2479+
const auxNavList = document.querySelector('.aux-nav-list');
2480+
const auxNavList = document.querySelector('.aux-nav-list');
2481+
if (!auxNavList) {
2482+
console.warn('aux-nav-list not found, cannot add theme toggle');
2483+
return;
2484+
}
2485+
// Create a list item to wrap the themeButton
2486+
const listItem = document.createElement('li');
2487+
listItem.className = 'aux-nav-list-item';
2488+
listItem.appendChild(themeButton);
2489+
auxNavList.appendChild(listItem);
24862490
updateMainThemeButton();
24872491
}
24882492
}
@@ -2506,7 +2510,7 @@
25062510
}
25072511

25082512
// Add main theme button after page loads
2509-
setTimeout(addThemeToggleToMainArea, 200);
2513+
setTimeout(addThemeToggleToAuxNav, 200);
25102514

25112515
// Function to update navigation theme link
25122516
function updateNavigationThemeLink() {

0 commit comments

Comments
 (0)