Skip to content

Commit cb77ae7

Browse files
committed
Move theme toggle (sun icon) into header
Signed-off-by: silvialpz <74107990+silvialpz@users.noreply.github.com>
1 parent 89ddcaf commit cb77ae7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

docs/_includes/header_custom.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,7 @@
24242424
}
24252425

24262426
// Add theme toggle button as floating button
2427-
function addThemeToggleToMainArea() {
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,8 @@
24342434

24352435
// Style the button to be clearly visible
24362436
themeButton.style.cssText = `
2437-
position: fixed !important;
24382437
top: 80px !important;
24392438
right: calc(50% - 440px) !important;
2440-
z-index: 9999 !important;
24412439
background: #6b7280 !important;
24422440
color: white !important;
24432441
border: none !important;
@@ -2446,7 +2444,6 @@
24462444
font-size: 16px !important;
24472445
cursor: pointer !important;
24482446
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
2449-
display: flex !important;
24502447
align-items: center !important;
24512448
gap: 8px !important;
24522449
font-weight: 500 !important;
@@ -2481,8 +2478,15 @@
24812478
updateMainThemeButton();
24822479
updateNavigationThemeLink();
24832480
});
2484-
2485-
document.body.appendChild(themeButton);
2481+
2482+
2483+
const auxNavList = document.querySelector('.aux-nav-list');
2484+
// Creat a list item to wrap teh themeButton with
2485+
const listItem = document.createElement('li');
2486+
listItem.className = 'aux-nav-list-item';
2487+
listItem.appendChild(themeButton);
2488+
// Append to aux navigation
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)